Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: Clean up TempDir/export/repo on LockBox and TempDir/export on LockAllBoxes to prevent accessing exported decrypted files after locking https://github.com/siyuan-note/siyuan/issues/18034

Daniel88658d74ee3a
diff --git a/kernel/model/crypto.go b/kernel/model/crypto.go
index a2ebae2ce3..4f5d8cc307 100644
--- a/kernel/model/crypto.go
+++ b/kernel/model/crypto.go
@@ -750,6 +750,10 @@ func LockBox(boxID string) {
}
}
}
+ // 清理临时导出目录中的 repo 导出(无法按 box 单独区分,锁定时统一清理)
+ if rmErr := os.RemoveAll(filepath.Join(util.TempDir, "export", "repo")); rmErr != nil {
+ logging.LogWarnf("remove export/repo dir for box [%s] failed: %s", boxID, rmErr)
+ }
}
// LockAllBoxes 清除所有已缓存的 DEK 并删除所有加密 db 文件。退出登录或全局锁定时调用。
@@ -773,6 +777,10 @@ func LockAllBoxes() {
if rmErr := os.RemoveAll(filepath.Join(util.TempDir, "repo")); rmErr != nil {
logging.LogErrorf("remove repo directory failed: %s", rmErr)
}
+ // 清理临时导出目录(锁定后不应继续提供明文导出下载)
+ if rmErr := os.RemoveAll(filepath.Join(util.TempDir, "export")); rmErr != nil {
+ logging.LogErrorf("remove export directory failed: %s", rmErr)
+ }
}
// WrapNewDEK 用给定 KEK 生成随机 DEK 并包络,返回 BoxEncryption 元数据。