siyuan-note/siyuan · error

invalid archive entry path

Error message

invalid archive entry path [%s]

What it means

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.

Solutions

  1. Remove ../ sequences from archive entry names and repack
  2. Extract to a destination on the same drive/volume
  3. Verify with unzip -l that every entry is a relative path inside the archive root

Example fix

// before
entry: ../outside.sy
// after
entry: documents/outside.sy
Defensive patterns

Strategy: validation

Validate before calling

// Go pre-check per entry
rel, err := filepath.Rel(destination, entryPath)
if err != nil || !filepath.IsLocal(rel) { return fmt.Errorf("entry escapes destination: %s", entryPath) }

Try / catch

try { await unzip(src, dest) } catch (e) { if (/invalid archive entry path/.test(e)) await extractToSandbox(src) }

Prevention

When it happens

Trigger: 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.

Common situations: Archives crafted for zip-slip; entries whose backslash normalization still yields escaping names; cross-drive destinations on Windows.

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


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/f8a92fe6bd13aa93. Report an issue: GitHub.

Appendix: source

Thrown at kernel/api/archive.go:257

			return err
		}
	}
	for i, entry := range reader.File {
		// 解压前再次检查已有符号链接和加密身份,不复用预检阶段的路径判定结果。
		if err = validateArchiveEntryPath(destination, paths[i]); err != nil {
			return err
		}
		if err = extractWorkspaceArchiveEntry(entry, paths[i]); err != nil {
			return err
		}
	}
	return nil
}

func validateArchiveEntryPath(destination, entryPath string) error {
	rel, err := filepath.Rel(destination, entryPath)
	if err != nil || !filepath.IsLocal(rel) {
		return fmt.Errorf("invalid archive entry path [%s]", entryPath)
	}
	resolved, err := resolveArchivePath(entryPath)
	if err != nil {
		return err
	}
	resolvedDestination, err := resolveArchivePath(destination)
	if err != nil {
		return err
	}
	rel, err = filepath.Rel(resolvedDestination, resolved)
	if err != nil || !filepath.IsLocal(rel) {
		return fmt.Errorf("archive entry resolves outside destination [%s]", entryPath)
	}
	return rejectEncryptedArchivePath(entryPath)
}

func extractWorkspaceArchiveEntry(entry *archivezip.File, destination string) error {
	if entry.FileInfo().IsDir() {

View on GitHub (pinned to 9f775e8a12)