🔒 emoji xss fix (#15041)

This commit is contained in:
syr1ne 2025-06-16 19:49:15 +05:30 committed by GitHub
parent 218bbe2000
commit 724cddf7cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 6 deletions

View file

@ -171,9 +171,14 @@ func getEmojiConf(c *gin.Context) {
}
if !util.IsValidUploadFileName(html.UnescapeString(name)) {
emojiFullName := customConfDir + "/" + name
fullPathFilteredName := customConfDir + "/" + util.FilterUploadFileName(name)
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
logging.LogWarnf("invalid custom emoji name [%s]", name)
continue
logging.LogErrorf("renaming invalid file to [%s] in emojis", fullPathFilteredName)
if removeErr := os.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
logging.LogErrorf("renaming invalid file to [%s] failed: %s", fullPathFilteredName, removeErr)
}
}
if customEmoji.IsDir() {
@ -195,9 +200,14 @@ func getEmojiConf(c *gin.Context) {
}
if !util.IsValidUploadFileName(html.UnescapeString(name)) {
emojiFullName := customConfDir + "/" + name
fullPathFilteredName := customConfDir + "/" + util.FilterUploadFileName(name)
// XSS through emoji name https://github.com/siyuan-note/siyuan/issues/15034
logging.LogWarnf("invalid custom emoji name [%s]", name)
continue
logging.LogErrorf("renaming invalid file to [%s] in emojis", fullPathFilteredName)
if removeErr := os.Rename(emojiFullName, fullPathFilteredName); nil != removeErr {
logging.LogErrorf("renaming invalid file to [%s] failed: %s", fullPathFilteredName, removeErr)
}
}
addCustomEmoji(customEmoji.Name()+"/"+name, &items)