siyuan-note/siyuan · error
path belongs to encrypted notebook
Error message
path belongs to encrypted notebook [%s]
What it means
rejectEncryptedArchivePath checks whether an absolute archive path lands inside an encrypted notebook directory (including via symlink bypass) using model.EncryptedRawPathBoxID. The kernel refuses archive export/extract operations that would touch encrypted notebook raw files, so the operation is rejected with the owning notebook ID.
Solutions
- Choose an archive path outside any notebook directory (e.g. outside util.DataDir)
- Remove the symlink pointing into the encrypted notebook directory
- If you legitimately need the content, decrypt/export via supported UI flows instead of archive paths
Defensive patterns
Strategy: validation
Validate before calling
// Go, before requesting the archive write
if boxID := model.EncryptedRawPathBoxID(absPath); boxID != "" { return fmt.Errorf("choose another path, inside notebook %s", boxID) } Try / catch
if err := exportArchive(p); err != nil && strings.Contains(err.Error(), "encrypted notebook") { promptUserForNewPath() } Prevention
- Keep archive/temp destinations outside the data directory
- Avoid creating symlinks under the workspace data dir
- Treat any path under data/<notebook-id>/ as off-limits for raw archives
When it happens
Trigger: Exporting/importing a workspace archive whose target path, after resolution, is inside a notebook's raw directory of an encrypted notebook.
Common situations: User selects a destination folder under data/<encrypted-notebook>/; a symlink in data/ points into an encrypted notebook directory; automated scripts staging archives inside the data dir.
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
- archive entry resolves outside destination
- invalid archive entry path
- 314
- 314
- archive entry escapes destination
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/d21750adeba9cd22.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/api/archive.go:41
"io"
"io/fs"
"os"
"path/filepath"
"strings"
"unicode/utf8"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
"golang.org/x/text/encoding/simplifiedchinese"
)
// rejectEncryptedArchivePath 检查路径是否落入加密笔记本目录(含 symlink 绕过),是则返回错误。
func rejectEncryptedArchivePath(absPath string) error {
if boxID := model.EncryptedRawPathBoxID(absPath); boxID != "" {
return fmt.Errorf("path belongs to encrypted notebook [%s]", boxID)
}
resolved, err := resolveArchivePath(absPath)
if err != nil {
return err
}
dataDir, err := resolveArchivePath(util.DataDir)
if err != nil {
return err
}
if rel, relErr := filepath.Rel(dataDir, resolved); relErr == nil && filepath.IsLocal(rel) {
if boxID := model.EncryptedRawPathBoxID(filepath.Join(util.DataDir, rel)); boxID != "" {
return fmt.Errorf("path belongs to encrypted notebook [%s]", boxID)
}
}
return nil
}
// resolveArchivePath 解析最长已存在父路径的最终位置,包含 Windows 目录联接;解析失败时拒绝访问。View on GitHub (pinned to 9f775e8a12)