{"record":{"id":"8201f1980a5bdf9b","repo":"Tencent/WeKnora","slug":"file-path-outside-skill-directory-s","errorCode":null,"errorMessage":"file path outside skill directory: %s","messagePattern":"file path outside skill directory: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/skills/loader.go","lineNumber":228,"sourceCode":"\n\t// Security: prevent path traversal\n\tif strings.HasPrefix(cleanPath, \"..\") || filepath.IsAbs(cleanPath) {\n\t\treturn nil, fmt.Errorf(\"invalid file path: %s\", relativePath)\n\t}\n\n\tfullPath := filepath.Join(skill.BasePath, cleanPath)\n\n\t// Verify the file is within the skill directory\n\tabsSkillPath, err := filepath.Abs(skill.BasePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tabsFilePath, err := filepath.Abs(fullPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !strings.HasPrefix(absFilePath, absSkillPath) {\n\t\treturn nil, fmt.Errorf(\"file path outside skill directory: %s\", relativePath)\n\t}\n\n\t// Read the file\n\tcontent, err := os.ReadFile(fullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read file: %w\", err)\n\t}\n\n\treturn &SkillFile{\n\t\tName:     relativePath,\n\t\tPath:     absFilePath, // Use absolute path for sandbox execution\n\t\tContent:  string(content),\n\t\tIsScript: IsScript(relativePath),\n\t}, nil\n}\n\n// ListSkillFiles lists all files in a skill directory\nfunc (l *Loader) ListSkillFiles(skillName string) ([]string, error) {","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/skills/loader.go#L210-L246","documentation":"Second-layer containment guard in LoadSkillFile: even after Clean passes the first check, the absolutized fullPath does not lie under the absolutized skill BasePath (symlinks or join tricks can escape). Defense-in-depth rejection of any resolved path outside the skill directory.","triggerScenarios":"Thrown at internal/agent/skills/loader.go:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the requested file physically resides inside the skill's base directory","Remove or replace symlinks in the skill directory that point outside it","Verify BasePath itself resolves to the intended absolute directory"],"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"}