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: Sanitize clipboard HTML before paste insertion https://github.com/siyuan-note/siyuan/security/advisories/GHSA-9rr9-pxr4-gcgc
Daniel9ce660652de2
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex e7192d362d..a06e71ce71 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -793,6 +793,11 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven}}+ // 外部网页可通过 copy 事件伪造 text/siyuan 或 ZWSP 结尾的 text/plain,与内部数据混同,粘贴前统一消毒 https://github.com/siyuan-note/siyuan/security/advisories/GHSA-9rr9-pxr4-gcgc+ if (siyuanHTML) {+ siyuanHTML = Lute.Sanitize(siyuanHTML);+ }+if (!siyuanHTML && textHTML) {const officeList = convertOfficeLists(textHTML);textHTML = officeList.html;@@ -838,37 +843,20 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenreturn;} else if (siyuanHTML) {async function streamInsert(container: HTMLElement, bigHtmlString: string) {- const iframe = document.createElement("iframe");- iframe.style.display = "none";- document.body.appendChild(iframe);- try {- const doc = iframe.contentWindow.document;- doc.open();-- const chunkSize = 102400;- let offset = 0;- while (offset < bigHtmlString.length) {- const chunk = bigHtmlString.substring(offset, offset + chunkSize);- doc.write(chunk);- offset += chunkSize;- await new Promise(resolve => setTimeout(resolve, 0));- if (!isPasteInsertPositionAvailable()) {- return false;- }- }-- doc.close();-- const fragment = document.createDocumentFragment();- while (doc.body.firstChild) {- fragment.appendChild(doc.body.firstChild);- }-- container.appendChild(fragment);- return true;- } finally {- iframe.remove();+ // 大段内容使用惰性解析避免将 HTML 写入同源 iframe,防止 script 执行+ const doc = new DOMParser().parseFromString(bigHtmlString, "text/html");+ if (!doc.body || !doc.body.firstChild) {+ return false;+ }+ if (!isPasteInsertPositionAvailable()) {+ return false;+ }+ const fragment = document.createDocumentFragment();+ while (doc.body.firstChild) {+ fragment.appendChild(doc.body.firstChild);}+ container.appendChild(fragment);+ return true;}// 编辑器内部粘贴