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-hjh7-r5w8-5872

Danielbb481e1290c4
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index b7f6614012..d2eb2d67bb 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -319,6 +319,11 @@ func serveExport(ginServer *gin.Engine) {
}
fullPath := filepath.Join(exportBaseDir, decodedPath)
+ if !gulu.File.IsSubPath(exportBaseDir, fullPath) {
+ c.Status(http.StatusUnauthorized)
+ return
+ }
+
if util.IsSensitivePath(fullPath) {
logging.LogErrorf("refuse to export sensitive file [%s]", c.Request.URL.Path)
c.Status(http.StatusForbidden)
diff --git a/kernel/util/path.go b/kernel/util/path.go
index f3db6aed7d..f59db14421 100644
--- a/kernel/util/path.go
+++ b/kernel/util/path.go
@@ -459,6 +459,11 @@ func IsSensitivePath(p string) bool {
return true
}
+ // *.db/*.log
+ if strings.HasSuffix(p, ".db") || strings.HasSuffix(p, ".log") {
+ return true
+ }
+
// 用户家目录下的敏感目录(小写比较)
homePrefixes := []string{
strings.ToLower(filepath.Join(HomeDir, ".ssh")),