siyuan-note/siyuan · warning
local asset path is not allowed
Error message
local asset path is not allowed
What it means
When inserting assets originating from HTML (InsertHTMLLocalAssets, validateHTMLPath=true), each local path is screened with util.IsSensitivePath and EncryptedRawPathBoxID. Paths that are sensitive (system dirs, workspace traversal, dotfile-like escapes) or point inside an encrypted notebook's raw storage are rejected per-file with 'local asset path is not allowed' and skipped, protecting against leaking or copying protected/system content.
Solutions
- Check the path with util.IsSensitivePath and EncryptedRawPathBoxID before the call and exclude rejected files
- Copy the file to a neutral temp/user location first and pass that path instead
- For encrypted-notebook content, go through the documented export/insert APIs rather than raw paths
- Treat the per-file failure as expected behavior: the file appears in failedFiles and the rest of the batch still succeeds
- Do not construct file:// URLs pointing at system or notebook-internal locations
Example fix
// before
model.InsertHTMLLocalAssets(id, []string{"file:///etc/passwd"})
// after
p := "/etc/passwd"
if util.IsSensitivePath(p) || model.EncryptedRawPathBoxID(p) != "" {
return errors.New("skipping disallowed path")
}
model.InsertHTMLLocalAssets(id, []string{"file://" + p}) Defensive patterns
Strategy: validation
Validate before calling
for i, p := range paths {
if strings.HasPrefix(strings.ToLower(p), "file://") { p = util.FileURLToLocalPath(p) }
if util.IsSensitivePath(p) || model.EncryptedRawPathBoxID(p) != "" {
paths = append(paths[:i], paths[i+1:]...) // or skip per-file
}
} Try / catch
succ, files, failed, err := model.InsertHTMLLocalAssets(id, paths)
for _, f := range failed {
if f.Error == "local asset path is not allowed" {
log.Printf("skipped disallowed path at index %d", f.Index) // expected, not fatal
}
} Prevention
- Pre-screen HTML-sourced paths with IsSensitivePath/EncryptedRawPathBoxID before inserting
- Copy questionable local files to a neutral temp directory and insert from there
- Never build file:// URLs pointing at system directories or other notebooks' raw storage
When it happens
Trigger: InsertHTMLLocalAssets with an assetAbsPaths entry that resolves to a sensitive location (e.g. /etc/..., the workspace data dir itself, parent-traversal like a/../..), or to an encrypted notebook's raw path; also file:// URLs whose decoded local path hits these checks.
Common situations: Pasting HTML copied from a page that referenced local disk files; web clipper passing absolute file URLs including OS/system directories; attempts to import files from another encrypted notebook's raw storage.
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
- access to sensitive workspace file is forbidden
- archive entry escapes destination
- asset path is sensitive
- invalid archive entry
- invalid history source path
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/e364334ae1c7306d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/upload.go:203
return
}
boxID = bt.BoxID
docDirLocalPath := filepath.Join(util.DataDir, boxID, path.Dir(bt.Path))
assetsDirPath = getAssetsDir(filepath.Join(util.DataDir, boxID), docDirLocalPath)
}
if !gulu.File.IsExist(assetsDirPath) {
if err = os.MkdirAll(assetsDirPath, 0755); err != nil {
return
}
}
for index, assetAbsPath := range assetAbsPaths {
if strings.HasPrefix(strings.ToLower(assetAbsPath), "file://") {
assetAbsPath = util.FileURLToLocalPath(assetAbsPath)
}
baseName := filepath.Base(assetAbsPath)
if validateHTMLPath && (util.IsSensitivePath(assetAbsPath) || EncryptedRawPathBoxID(assetAbsPath) != "") {
recordAssetUploadFailure(&failedFiles, index, baseName, errors.New("local asset path is not allowed"))
continue
}
fName := baseName
fName = util.FilterUploadFileName(fName)
ext := filepath.Ext(fName)
fName = strings.TrimSuffix(fName, ext)
ext = strings.ToLower(ext)
fName += ext
if gulu.File.IsDir(assetAbsPath) || !isUpload {
if !strings.HasPrefix(assetAbsPath, "\\\\") {
assetAbsPath = "file://" + assetAbsPath
}
recordAssetUploadSuccess(succMap, &succFiles, index, baseName, assetAbsPath)
continue
}
fi, statErr := os.Stat(assetAbsPath)
if nil != statErr {View on GitHub (pinned to 9f775e8a12)