An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Restrict template removal to the templates directory https://github.com/siyuan-note/siyuan/security/advisories/GHSA-w938-w7m4-qrj8
Daniel83877148fd70
diff --git a/kernel/model/template.go b/kernel/model/template.goindex 564105df67..0a30d91501 100644--- a/kernel/model/template.go+++ b/kernel/model/template.go@@ -85,8 +85,18 @@ func RenderGoTemplateAtInBox(templateContent string, now time.Time, boxID stringreturn}+// RemoveTemplate 删除模板文件,路径必须限定在 <data>/templates/ 目录内,防止任意文件被删除func RemoveTemplate(p string) (err error) {- err = filelock.Remove(p)+ abs := p+ if !filepath.IsAbs(abs) {+ abs = filepath.Join(util.DataDir, "templates", p)+ }+ abs = filepath.Clean(abs)+ templatesRoot := filepath.Clean(filepath.Join(util.DataDir, "templates"))+ if !gulu.File.IsSubPath(templatesRoot, abs) {+ return errors.New("template path is outside templates directory")+ }+ err = filelock.Remove(abs)if err != nil {logging.LogErrorf("remove template failed: %s", err)}