siyuan-note/siyuan · error
asset path is sensitive
Error message
asset path is sensitive: %s
What it means
validateAssetUploadPaths rejects any asset upload path that util.IsSensitivePath classifies as sensitive (e.g. paths pointing into the workspace's system/configuration directories or other protected locations). The absolute, trimmed path is echoed in the error and the whole upload fails.
Solutions
- Upload only files located in ordinary user data/asset directories, not workspace system or config paths
- Check the path with util.IsSensitivePath(filepath.Abs(path)) client-side before invoking the upload
- Remove directory components or traversal segments (..) from supplied paths before calling
- Verify the working directory used for relative paths does not cause Abs() to land in a protected tree
Example fix
// before
upload("conf/appearance.json") // sensitive after Abs
// after
upload("assets/note-attachment.png") Defensive patterns
Strategy: validation
Validate before calling
abs, err := filepath.Abs(strings.TrimSpace(path))
if err != nil {
return err
}
if util.IsSensitivePath(abs) {
return fmt.Errorf("refusing sensitive path: %s", abs)
} Try / catch
result, err := assetUpload(fileList)
if err != nil && strings.Contains(err.Error(), "asset path is sensitive") {
// relocate the file outside protected directories and retry
} Prevention
- Pre-validate every upload path with util.IsSensitivePath after making it absolute
- Never upload files from conf/, system temp, or kernel data directories
- Reject '..' segments and resolve relative paths against a known-safe base directory
When it happens
Trigger: assetUpload receives a file list containing a path that, after filepath.Abs, resolves under a sensitive directory — such as workspace conf/, temp/system paths, or other reserved prefixes.
Common situations: A client passing workspace configuration or kernel data directories as 'assets'; relative paths that accidentally resolve near protected roots once made absolute; plugins or scripts uploading system files; path traversal attempts.
Understand the failure class
Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.
Related errors
- Path [ ] is not in workspace
- access to sensitive workspace file is forbidden
- archive entry escapes destination
- boxID mismatch: param=
- invalid archive entry
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/603df1b276538284.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/mcp/tools/asset.go:242
_, succFiles, failedFiles, err := model.InsertLocalAssets(id, fileList, true)
if err != nil {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: "upload assets failed: " + err.Error()}}, IsError: true}, nil
}
return newAssetUploadToolResult(succFiles, failedFiles), nil
}
// validateAssetUploadPaths 将上传路径归一化为绝对路径,并拒绝敏感路径,
// 防止通过 AI 提示注入诱导上传本地凭据等敏感文件(如 SSH 私钥、云服务凭据)后外泄。
// 非敏感的工作区外绝对路径仍然允许上传,与 globalCopyFiles 等接受工作区外路径的接口保持一致。
func validateAssetUploadPaths(fileList []string) ([]string, error) {
for i, f := range fileList {
abs, err := filepath.Abs(strings.TrimSpace(f))
if err != nil {
return nil, err
}
if util.IsSensitivePath(abs) {
return nil, fmt.Errorf("asset path is sensitive: %s", abs)
}
fileList[i] = abs
}
return fileList, nil
}
func assetUnused(args map[string]any) (CallToolResult, error) {
items := model.UnusedAssets(true)
if len(items) == 0 {
return CallToolResult{Content: []ContentItem{{Type: "text", Text: "no unused assets found"}}}, nil
}
var sb strings.Builder
sb.WriteString(fmt.Sprintf("Unused assets (%d):\n\n", len(items)))
for _, item := range items {
sb.WriteString(fmt.Sprintf("- %s (%s)\n", item.Item, item.Name))
}
return CallToolResult{Content: []ContentItem{{Type: "text", Text: sb.String()}}}, nil
}View on GitHub (pinned to 9f775e8a12)