llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · siyuan

GHSA-HHVQ-JQV9-PGJQ

Stored XSS via KaTeX `\href` in SiYuan math blocks (local-kernel editor path)

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónv3.8.7
Exposición42 dDesde la divulgación, 9 oct 2026, 6:59 a. m.
Detección41 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
9 oct 26
20 nov 26
21 nov 26
9 oct 26
20 oct 26
30 oct 26
10 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-HHVQ-JQV9-PGJQ divulgada
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

Stored cross-site scripting in SiYuan Note. Math block content (`$$...$$`) written by any user with edit permission on a document is rendered by the block's editor path with KaTeX's `trust: true` and without HTML sanitization. KaTeX's TeX `\href` (and `\url`, `\includegraphics`) rules therefore preserve a `javascript:` URL in the generated `<a href>` / `<img src>` attribute, which the application then assigns via `innerHTML`. A reader who clicks the rendered link executes attacker script in the application origin.

Details

Root cause is the trust decision for KaTeX combined with a direct `innerHTML` sink, not a generic KaTeX flaw. KaTeX's `\href` rule is documented as emitting the URL as given when `trust` is enabled; the application opts into that mode by default on the local path.

Affected source locations (commit `60a4387`):

  • `app/src/protyle/render/mathRender.ts:52-59` — interpretation entry:
  • `app/src/protyle/render/mathRenderSecurity.ts:1-4` — trust/sanitize decision
  • `app/src/protyle/render/mathRender.ts:68-72` — sink: `mathElement.innerHTML = mathHTML`

Data flow:

  1. A collaborator with edit rights stores the following as math block content (`$$...$$`), through the editor or through the normal API `POST /api/block/appendBlock {"dataType":"markdown", ...}`: `$$\href{javascript:alert('xss')}{clickme}$$`
  2. Lute stores it as a math block whose `data-content` holds the TeX source verbatim.
  3. When the document is opened, `mathRender` calls `katex.renderToString(..., { trust: true })`. KaTeX's `\href` rule emits `<a href="javascript:alert('xss')">clickme</a>`.
  4. The HTML is mounted with `innerHTML` into the math block container.
  5. The victim clicks the rendered link; the `javascript:` URL runs attacker script in the application origin (`javascript:` URLs execute only on an in-document click gesture — no click, no execution).

The rendering rule was additionally reproduced in isolation (KaTeX 0.16.9, `trust: true`) to confirm step 3; the end-to-end click was executed in a real Chromium against the running application.

Proof of concept

Environment: Ubuntu / Docker (`b3log/siyuan:latest`, digest `sha256:d740a1d3ed6b850de3043caf02d3b41e57e0c79b69a8ce2e511588e5e76968c1`) / SiYuan 3.8.5, kernel reachable at `http://127.0.0.1:18083`.

  1. Plant the payload as an ordinary document editor would (only normal APIs are used):

```bash
NB=$(curl -s --noproxy '*' -X POST http://127.0.0.1:18083/api/notebook/createNotebook \
-H 'Content-Type: application/json' -d '{"name":"xsslab"}' \
| python3 -c "import json,sys;print(json.load(sys.stdin)['data']['notebook']['id'])")

DOC="xss-katex-tok-manual"
KDOC=$(curl -s --noproxy '*' -X POST http://127.0.0.1:18083/api/filetree/createDocWithMd \
-H 'Content-Type: application/json' \
-d "{\"notebook\":\"$NB\",\"path\":\"/$DOC\",\"markdown\":\"kx\"}" \
| python3 -c "import json,sys;print(json.load(sys.stdin)['data'])")

TOKEN='xss_manual_p00'
python3 -c "import json;print(json.dumps({'dataType':'markdown',
'data':\"\$\$\\\\href{javascript:alert('$TOKEN')}{clickme}\$\$\",'parentID':'$KDOC'}))" > /tmp/b.json
curl -s --noproxy '*' -X POST http://127.0.0.1:18083/api/block/appendBlock \
-H 'Content-Type: application/json' --data @/tmp/b.json
```

  1. Open `http://127.0.0.1:18083/stage/build/desktop/` → notebook `xsslab` → document `$DOC`.
  2. The math block renders a `clickme` link. Clicking it shows a native alert dialog containing `xss_manual_p00`.

Observed result (real Chromium run, payload rendered by the application, not by a test fixture): KaTeX output `<a href="javascript:alert('xss_syK1_p00')">…</a>`, click → `alert` dialog with the per-run token, i.e. the payload of the planted block executes in the application origin.

Other payload variants that survive the same rule with `trust: true` (all require the same single click): `\href` with mixed case scheme (`JaVaScRiPt:`), `\url{javascript:…}`, `\includegraphics{javascript:…}` (produces `img[src="javascript:…"]`).

Not vulnerable / checked and safe on the same workspace: ordinary paragraph `<img onerror=…>` is stored as escaped text; `<script>` is escaped by Lute; fenced code blocks render as text nodes; HTML block `data-content` is entity-encoded and not activated; `iframe[src="javascript:…"]` is emptied to `src=""` by Lute.

Impact

Stored, so every reader of the shared document is exposed. The script runs in the application origin, so it can read the page and act with the reader's session in that origin — relevant because the desktop build's UI drives local kernel APIs. Demonstrated impact is limited to proof-of-concept execution (alert dialog); no data exfiltration was performed.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida
siyuan≥ 2.10.0 < v3.8.7
2.10.0
v3.8.7
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Gosiyuan
Corregida v3.8.7 — —
Versiones corregidasv3.8.7
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/siyuan-note/siyuan/security/advisories/GHSA-hhvq-jqv9-pgjq

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.