Skip to content

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

:lock: Prevent SQL injection in graph daily note path filter https://github.com/siyuan-note/siyuan/security/advisories/GHSA-xr4h-j7cg-q8pc

Daniel2461dfde7dee
diff --git a/kernel/model/graph.go b/kernel/model/graph.go
index 555e189f87..658644606c 100644
--- a/kernel/model/graph.go
+++ b/kernel/model/graph.go
@@ -630,7 +630,9 @@ func graphDailyNoteFilter(local bool) string {
buf := bytes.Buffer{}
for _, p := range dailyNotesPaths {
- buf.WriteString(" AND ref.hpath NOT LIKE '" + p + "%'")
+ // 转义单引号,避免日记存储路径闭合 SQL 字符串字面量造成注入
+ // https://github.com/siyuan-note/siyuan/security/advisories/GHSA-xr4h-j7cg-q8pc
+ buf.WriteString(" AND ref.hpath NOT LIKE '" + strings.ReplaceAll(p, "'", "''") + "%'")
}
return buf.String()
}