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

This commit is contained in:
Daniel 2025-01-03 09:48:08 +08:00
parent 98819ca4c7
commit d9887aeec1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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