{"record":{"id":"f8a92fe6bd13aa93","repo":"siyuan-note/siyuan","slug":"invalid-archive-entry-path-s","errorCode":null,"errorMessage":"invalid archive entry path [%s]","messagePattern":"invalid archive entry path \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/api/archive.go","lineNumber":257,"sourceCode":"\t\t\treturn err\n\t\t}\n\t}\n\tfor i, entry := range reader.File {\n\t\t// 解压前再次检查已有符号链接和加密身份，不复用预检阶段的路径判定结果。\n\t\tif err = validateArchiveEntryPath(destination, paths[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err = extractWorkspaceArchiveEntry(entry, paths[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateArchiveEntryPath(destination, entryPath string) error {\n\trel, err := filepath.Rel(destination, entryPath)\n\tif err != nil || !filepath.IsLocal(rel) {\n\t\treturn fmt.Errorf(\"invalid archive entry path [%s]\", entryPath)\n\t}\n\tresolved, err := resolveArchivePath(entryPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresolvedDestination, err := resolveArchivePath(destination)\n\tif err != nil {\n\t\treturn err\n\t}\n\trel, err = filepath.Rel(resolvedDestination, resolved)\n\tif err != nil || !filepath.IsLocal(rel) {\n\t\treturn fmt.Errorf(\"archive entry resolves outside destination [%s]\", entryPath)\n\t}\n\treturn rejectEncryptedArchivePath(entryPath)\n}\n\nfunc extractWorkspaceArchiveEntry(entry *archivezip.File, destination string) error {\n\tif entry.FileInfo().IsDir() {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/api/archive.go#L239-L275","documentation":"validateArchiveEntryPath computes filepath.Rel(destination, entryPath) and requires the relative path to be IsLocal. If the entry path escapes the extraction destination (or Rel fails, e.g. different drives), extraction is aborted with this error.","triggerScenarios":"A zip entry whose computed absolute path under destination falls outside destination — e.g. entries containing .. segments that survive the earlier name check, or paths on another Windows drive.","commonSituations":"Archives crafted for zip-slip; entries whose backslash normalization still yields escaping names; cross-drive destinations on Windows.","solutions":["Remove ../ sequences from archive entry names and repack","Extract to a destination on the same drive/volume","Verify with unzip -l that every entry is a relative path inside the archive root"],"exampleFix":"// before\nentry: ../outside.sy\n// after\nentry: documents/outside.sy","handlingStrategy":"validation","validationCode":"// Go pre-check per entry\nrel, err := filepath.Rel(destination, entryPath)\nif err != nil || !filepath.IsLocal(rel) { return fmt.Errorf(\"entry escapes destination: %s\", entryPath) }","typeGuard":null,"tryCatchPattern":"try { await unzip(src, dest) } catch (e) { if (/invalid archive entry path/.test(e)) await extractToSandbox(src) }","preventionTips":["Sanitize entry names (strip leading slashes and ..) before repacking","Extract on the same volume as the destination","Validate archives at ingestion time, not extraction time"],"tags":["archive","path-safety","zip-slip"],"backgroundTag":"path-traversal-blocked","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}