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-2h2p-mvfx-868w

Daniel6feb2bc8ec2d
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index 94897546f9..81a217e23c 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -318,6 +318,11 @@ func serveExport(ginServer *gin.Engine) {
}
fullPath := filepath.Join(exportBaseDir, decodedPath)
+ if util.IsSensitivePath(fullPath) {
+ logging.LogErrorf("refuse to export sensitive file [%s]", c.Request.URL.Path)
+ c.Status(http.StatusForbidden)
+ return
+ }
fileInfo, err := os.Stat(fullPath)
if os.IsNotExist(err) {
diff --git a/kernel/util/path.go b/kernel/util/path.go
index c60d1eec1d..6e45255bf5 100644
--- a/kernel/util/path.go
+++ b/kernel/util/path.go
@@ -391,6 +391,12 @@ func IsSensitivePath(p string) bool {
}
}
+ // 工作空间/conf 目录(小写比较)
+ workspaceConfPrefix := strings.ToLower(filepath.Join(WorkspaceDir, "conf"))
+ if strings.HasPrefix(pp, workspaceConfPrefix) {
+ return true
+ }
+
homePrefixes := []string{
strings.ToLower(filepath.Join(HomeDir, ".ssh")),
strings.ToLower(filepath.Join(HomeDir, ".config")),