Skip to content

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

:lock: https://github.com/siyuan-note/siyuan/security/advisories/GHSA-rjhh-m223-9qqv

Daniel13b6d3d45e83
diff --git a/kernel/api/import.go b/kernel/api/import.go
index 6aa4596070..24dab78254 100644
--- a/kernel/api/import.go
+++ b/kernel/api/import.go
@@ -17,6 +17,7 @@
package api
import (
+ "fmt"
"io"
"net/http"
"os"
@@ -188,6 +189,23 @@ func importStdMd(c *gin.Context) {
notebook := arg["notebook"].(string)
localPath := arg["localPath"].(string)
toPath := arg["toPath"].(string)
+
+ if util.IsSubPath(util.WorkingDir, localPath) {
+ msg := fmt.Sprintf("import from local path [%s] failed: local path is sub path of working dir", localPath)
+ logging.LogErrorf(msg)
+ ret.Code = -1
+ ret.Msg = msg
+ return
+ }
+
+ if util.IsSensitivePath(localPath) {
+ msg := fmt.Sprintf("import from local path [%s] failed: local path is sensitive path", localPath)
+ logging.LogErrorf(msg)
+ ret.Code = -1
+ ret.Msg = msg
+ return
+ }
+
err := model.ImportFromLocalPath(notebook, localPath, toPath)
if err != nil {
ret.Code = -1