Skip to content

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

:lock: Arbitrary file deletion vulnerability https://github.com/siyuan-note/siyuan/issues/13709

Danield9887aeec1b2
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 4940586f3b..3e096ed8ac 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -18,6 +18,7 @@ package model
import (
"encoding/json"
+ "errors"
"fmt"
"io/fs"
"math"
@@ -148,6 +149,13 @@ func ClearWorkspaceHistory() (err error) {
}
func GetDocHistoryContent(historyPath, keyword string, highlight bool) (id, rootID, content string, isLargeDoc bool, err error) {
+ if !util.IsAbsPathInWorkspace(historyPath) {
+ msg := "Path [" + historyPath + "] is not in workspace"
+ logging.LogErrorf(msg)
+ err = errors.New(msg)
+ return
+ }
+
if !gulu.File.IsExist(historyPath) {
logging.LogWarnf("doc history [%s] not exist", historyPath)
return
@@ -163,8 +171,7 @@ func GetDocHistoryContent(historyPath, keyword string, highlight bool) (id, root
luteEngine := NewLute()
historyTree, err := filesys.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if err != nil {
- logging.LogErrorf("parse tree from file [%s] failed, remove it", historyPath)
- os.RemoveAll(historyPath)
+ logging.LogErrorf("parse tree from file [%s] failed: %s", historyPath, err)
return
}
id = historyTree.Root.ID