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: XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034 https://github.com/siyuan-note/siyuan/issues/15082
Daniel289ea3aae0db
diff --git a/kernel/api/system.go b/kernel/api/system.goindex a52b76e90d..22f9c2e17f 100644--- a/kernel/api/system.go+++ b/kernel/api/system.go@@ -173,7 +173,8 @@ func getEmojiConf(c *gin.Context) {if !util.IsValidUploadFileName(html.UnescapeString(name)) {emojiFullName := filepath.Join(customConfDir, name)- fullPathFilteredName := filepath.Join(customConfDir, util.FilterUploadFileName(name))+ name = util.FilterUploadFileName(name)+ fullPathFilteredName := filepath.Join(customConfDir, name)// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", name, fullPathFilteredName)if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {@@ -194,22 +195,22 @@ func getEmojiConf(c *gin.Context) {continue}- name = subCustomEmoji.Name()- if strings.HasPrefix(name, ".") {+ subName := subCustomEmoji.Name()+ if strings.HasPrefix(subName, ".") {continue}- if !util.IsValidUploadFileName(html.UnescapeString(name)) {- emojiFullName := filepath.Join(customConfDir, name)- fullPathFilteredName := filepath.Join(customConfDir, util.FilterUploadFileName(name))+ if !util.IsValidUploadFileName(html.UnescapeString(subName)) {+ emojiFullName := filepath.Join(customConfDir, name, subName)+ fullPathFilteredName := filepath.Join(customConfDir, name, util.FilterUploadFileName(subName))// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034- logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", name, fullPathFilteredName)+ logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", subName, fullPathFilteredName)if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {logging.LogErrorf("renaming invalid custom emoji file to [%s] failed: %s", fullPathFilteredName, removeErr)}}- addCustomEmoji(customEmoji.Name()+"/"+name, &items)+ addCustomEmoji(name+"/"+subName, &items)}continue}diff --git a/kernel/model/import.go b/kernel/model/import.goindex 9f02988d96..b40376cbac 100644--- a/kernel/model/import.go+++ b/kernel/model/import.go@@ -582,8 +582,8 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {return nil}if !util.IsValidUploadFileName(d.Name()) {- emojiFullName := filepath.Join(unzipRootEmojisPath, d.Name())- fullPathFilteredName := filepath.Join(unzipRootEmojisPath, util.FilterUploadFileName(d.Name()))+ emojiFullName := path+ fullPathFilteredName := filepath.Join(filepath.Dir(path), util.FilterUploadFileName(d.Name()))// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", d.Name(), fullPathFilteredName)if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {@@ -731,8 +731,8 @@ func ImportData(zipPath string) (err error) {return nil}if !util.IsValidUploadFileName(d.Name()) {- emojiFullName := filepath.Join(tmpDataEmojisPath, d.Name())- fullPathFilteredName := filepath.Join(tmpDataEmojisPath, util.FilterUploadFileName(d.Name()))+ emojiFullName := path+ fullPathFilteredName := filepath.Join(filepath.Dir(path), util.FilterUploadFileName(d.Name()))// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034logging.LogWarnf("renaming invalid custom emoji file [%s] to [%s]", d.Name(), fullPathFilteredName)if removeErr := filelock.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {