Skip to content

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

:lock: Stored XSS via Attribute View name to Electron renderer RCE in SiYuan https://github.com/siyuan-note/siyuan/security/advisories/GHSA-2h64-c999-c9r6

Daniel08f3a81ae2c1
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 8398c471a8..caf5d832f9 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -117,7 +117,7 @@ export const genTabHeaderHTML = (data: IAV, showSearch: boolean, editable: boole
${data.isMirror ? ` <span data-av-id="${data.id}" data-popover-url="/api/av/getMirrorDatabaseBlocks" class="popover__block block__icon block__icon--show ariaLabel" data-position="8south" aria-label="${window.siyuan.languages.mirrorTip}">
<svg><use xlink:href="#iconSplitLR"></use></svg></span><div class="fn__space"></div>` : ""}
</div>
- <div contenteditable="${editable}" spellcheck="${window.siyuan.config.editor.spellcheck.toString()}" class="av__title${viewData.hideAttrViewName ? " fn__none" : ""}" data-title="${(data.name || "")}" data-tip="${window.siyuan.languages._kernel[267]}">${Lute.EscapeHTMLStr(data.name || "")}</div>
+ <div contenteditable="${editable}" spellcheck="${window.siyuan.config.editor.spellcheck.toString()}" class="av__title${viewData.hideAttrViewName ? " fn__none" : ""}" data-title="${Lute.EscapeHTMLStr(data.name || "")}" data-tip="${window.siyuan.languages._kernel[267]}">${Lute.EscapeHTMLStr(data.name || "")}</div>
<div class="av__counter fn__none"></div>
</div>`;
};
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index c453f74963..69b6b348f7 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -556,7 +556,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
} else if (key === "memo") {
memoHTML = `<div class="protyle-attr--memo ariaLabel" aria-label="${escapeHTML}" data-position="north"><svg><use xlink:href="#iconM"></use></svg></div>`;
} else if (key === "custom-avs" && data.new["av-names"]) {
- avHTML = `<div class="protyle-attr--av"><svg><use xlink:href="#iconDatabase"></use></svg>${Lute.EscapeHTMLStr(data.new["av-names"])}</div>`;
+ avHTML = `<div class="protyle-attr--av"><svg><use xlink:href="#iconDatabase"></use></svg>${(data.new["av-names"])}</div>`;
}
});
let nodeAttrHTML = bookmarkHTML + nameHTML + aliasHTML + memoHTML + avHTML;
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 49dd55fd11..4f27dc3631 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -3261,7 +3261,7 @@ func getAvNames(avIDs string) (ret string) {
}
tpl := strings.ReplaceAll(attrAvNameTpl, "${avID}", nodeAvID)
- tpl = strings.ReplaceAll(tpl, "${avName}", nodeAvName)
+ tpl = strings.ReplaceAll(tpl, "${avName}", util.EscapeHTML(nodeAvName))
avNames.WriteString(tpl)
avNames.WriteString("&nbsp;")
}
@@ -3535,7 +3535,7 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, viewID, groupID, previous
err = av.SaveAttributeView(attrView)
}
- msg := fmt.Sprintf(Conf.language(269), getAttrViewName(attrView))
+ msg := fmt.Sprintf(Conf.language(269), util.EscapeHTML(getAttrViewName(attrView)))
util.PushMsg(msg, 5000)
return
}