Tencent/WeKnora · error
invalid file path: %s
Error message
invalid file path: %s
What it means
Path-traversal security guard in LoadSkillFile: after filepath.Clean, the caller-supplied relative path starts with ".." or is absolute. This is an intentional rejection of paths that could escape the skill's base directory — the input at fault is the relativePath argument.
Source
Thrown at internal/agent/skills/loader.go:213
// The filePath should be relative to the skill's base directory
func (l *Loader) LoadSkillFile(skillName, relativePath string) (*SkillFile, error) {
// Get the skill first
skill, ok := l.discoveredSkills[skillName]
if !ok {
// Try to load the skill
var err error
skill, err = l.LoadSkillInstructions(skillName)
if err != nil {
return nil, fmt.Errorf("skill not found: %s", skillName)
}
}
// Validate and resolve the file path
cleanPath := filepath.Clean(relativePath)
// Security: prevent path traversal
if strings.HasPrefix(cleanPath, "..") || filepath.IsAbs(cleanPath) {
return nil, fmt.Errorf("invalid file path: %s", relativePath)
}
fullPath := filepath.Join(skill.BasePath, cleanPath)
// Verify the file is within the skill directory
absSkillPath, err := filepath.Abs(skill.BasePath)
if err != nil {
return nil, err
}
absFilePath, err := filepath.Abs(fullPath)
if err != nil {
return nil, err
}
if !strings.HasPrefix(absFilePath, absSkillPath) {
return nil, fmt.Errorf("file path outside skill directory: %s", relativePath)
}
// Read the fileView on GitHub (pinned to 988cbb0330)
Solutions
- Pass a path relative to the skill's base directory, e.g. "scripts/run.sh" not "/etc/passwd" or "../../secret"
- Normalize client-supplied paths before calling and strip any leading separators or parent references
- Treat the error as a security event and log the attempted path
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/agent/skills/loader.go:213 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/41a51bc6f476ad7e.
Report an issue: GitHub.