{"record":{"id":"221fe7093580923d","repo":"Tencent/WeKnora","slug":"sandbox-install-file-path-q-is-outside-s","errorCode":null,"errorMessage":"sandbox: install file path %q is outside %s","messagePattern":"sandbox: install file path %q is outside (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_manager.go","lineNumber":650,"sourceCode":"\treturn m.client.ReadFile(ctx, handle, filePath)\n}\n\n// WriteSessionFile writes an install/maintenance file into the session's live\n// sandbox. It is deliberately narrower than a general remote write: only the\n// tenant skills image root is accepted, because ordinary attachments must keep\n// using WriteSessionInputFile and its /workspace/input guard.\nfunc (m *SessionBoundManager) WriteSessionFile(\n\tctx context.Context, sessionID, filePath string, content []byte,\n) error {\n\tif err := m.requireRemoteBackend(); err != nil {\n\t\treturn err\n\t}\n\tif strings.TrimSpace(sessionID) == \"\" {\n\t\treturn errors.New(\"sandbox: session ID required for file staging\")\n\t}\n\tclean := path.Clean(strings.TrimSpace(filePath))\n\tif clean != SkillsImageRoot && !strings.HasPrefix(clean, SkillsImageRoot+\"/\") {\n\t\treturn fmt.Errorf(\"sandbox: install file path %q is outside %s\", filePath, SkillsImageRoot)\n\t}\n\thandle, err := m.resolveSession(ctx, sessionID)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// resetSkillDir already created this folder with mkdir -p. Cube's MakeDir\n\t// then reports the existing directory as an error; ignoreExistingDir keeps\n\t// that from aborting the seed of SKILL.md.\n\tif err := ignoreExistingDir(m.client.MakeDir(ctx, handle, path.Dir(clean))); err != nil {\n\t\treturn fmt.Errorf(\"sandbox: create install directory: %w\", err)\n\t}\n\tif err := m.client.WriteFile(ctx, handle, clean, content); err != nil {\n\t\treturn fmt.Errorf(\"sandbox: write install file %s: %w\", clean, err)\n\t}\n\treturn nil\n}\n\n// ShellExecOptions carries per-call shell execution knobs. The install-only","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_manager.go#L632-L668","documentation":"Returned by WriteSessionFile when the requested install/maintenance filePath escapes the tenant skills image root. This write path is deliberately restricted to that root (ordinary attachments must go through WriteSessionFile's /workspace/input-guarded sibling), so an out-of-root path — including traversal attempts — is rejected before touching the sandbox.","triggerScenarios":"Thrown at internal/sandbox/session_manager.go:650 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Place install files under the tenant skills image root and use root-relative paths","Route general file uploads through WriteSessionInputFile instead","Reject or sanitize caller-supplied paths before calling WriteSessionFile"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}