GHSA-JF98-M24W-GM9M
Admin path traversal in exportBrowserHTML via folder allows out-of-workspace arbitrary-content index.html write
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:H/A:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-JF98-M24W-GM9M divulgada · CVSS 7.6 (GitHub) | |
| Remediación | Parche v3.8.4+incompatible | github.com/siyuan-note/siyuan · 7 d desde divulgación | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
## Summary
`exportBrowserHTML` (`kernel/api/export.go:842-875`) binds the request `folder` field with no `..`/containment check, then builds `tmpDir := filepath.Join(util.TempDir, "export", folder)` and writes `index.html` at that path via `filelock.WriteFile(htmlPath, []byte(htmlContent))` with fully attacker-controlled, unfiltered HTML/JS content. A `..`-laden `folder` escapes the export directory, letting an authenticated administrator write/overwrite `index.html` with arbitrary content anywhere the kernel process can write (a served web root, another workspace's export dir). This route additionally has no `CheckReadonly`, so it is exploitable even in read-only mode. This is the strongest-content-control member of the siyuan path-traversal write family (same CWE-22 root cause and admin tier as accepted advisory GHSA-94vh-rpgr-rpwc).
## Root Cause
`util.ParseJsonArgs(arg, ret, util.BindJsonArg("folder", &folder, true, true), util.BindJsonArg("html", &htmlContent, true, true), ...)` (export.go:852-855) only trims + enforces non-empty. The only conditional guard is the encrypted-box check at export.go:862 — `if parts := strings.SplitN(folder, "/", 2); len(parts) >= 1 && ast.IsNodeIDPattern(parts[0]) && model.IsEncryptedBox(parts[0])` — which sets `boxID` only when `parts[0]` is a valid NodeID. A `..`-leading `folder` fails `ast.IsNodeIDPattern(parts[0])`, so `boxID` stays `""` and the check is skipped entirely. Then `tmpDir := filepath.Join(util.TempDir, "export", folder)` (export.go:873), `htmlPath := filepath.Join(tmpDir, "index.html")` (export.go:874), and `filelock.WriteFile(htmlPath, []byte(htmlContent))` (export.go:875). `filepath.Join` cleans but does not reject `..`, so the path escapes `TempDir/export`. `htmlContent` is written verbatim with no sanitization.
## Impact
An authenticated administrator writes/overwrites `index.html` with arbitrary HTML/JS content at any pre-existing kernel-writable directory outside the workspace — e.g. deface/plant into a served web root (stored XSS against anyone served that path) or overwrite another workspace's export. Fully attacker-controlled content is the strongest of the three sibling findings. Constraint: the escaped parent directory must pre-exist (`filelock.WriteFile`→`WriteFileSafer` does not `MkdirAll`) and the filename is fixed to `index.html`. Escaping the workspace crosses a boundary SiYuan enforces elsewhere (CVSS Scope Changed), consistent with GHSA-94vh-rpgr-rpwc.
Proof of Concept
curl -X POST http://127.0.0.1:6806/api/export/exportBrowserHTML \
-H "Authorization: token <ADMIN_API_TOKEN>" -H "Content-Type: application/json" \
-d '{"folder":"../../../../var/www/html","html":"<h1>pwn</h1><script>/*...*/</script>","name":"x"}'
# -> writes /var/www/html/index.html (if /var/www/html exists)## Attack Chain
1. Entry: `POST /api/export/exportBrowserHTML`, route `CheckAuth, CheckAdminRole` (router.go:421 — no `CheckReadonly`), body `{"folder":"../../../../var/www/html","html":"<script>...</script>","name":"x"}`.
- Action: bind `folder`, `html` raw. Guard: none on `folder` traversal (export.go:852-855). Bypass proof: only conditional is the encrypted-box check at export.go:862, which requires `ast.IsNodeIDPattern(parts[0])`; a `..`-leading folder fails it → `boxID=""` → check skipped.
2. Sink: `tmpDir = Join(TempDir,"export",folder)` (export.go:873); `htmlPath = Join(tmpDir,"index.html")` (export.go:874); `filelock.WriteFile(htmlPath, htmlContent)` (export.go:875). Guard: none; `WriteFileSafer` requires parent dir to pre-exist (no MkdirAll). Bypass proof: `Join(Join(TempDir,"export","../../../../var/www/html"),"index.html")` = `/var/www/html/index.html`; `htmlContent` fully attacker-controlled and unfiltered.
3. Impact: out-of-workspace arbitrary-content `index.html` write (web-root defacement / served-HTML XSS).
## Bypass Evidence
- `filepath.Join` arithmetic re-run with `go run`: `Join(Join("/ws/temp","export","../../../../var/www/html"),"index.html")` = `/var/www/html/index.html`.
- Encrypted-box check at export.go:862 gated on `ast.IsNodeIDPattern(parts[0])`; a `..`-leading folder skips it.
- Route lacks `CheckReadonly` (router.go:421) → exploitable in read-only mode too.
- Version: HEAD `8641553a` == tag v3.8.3 (latest release); `git log v3.8.3..HEAD -- kernel/api/export.go` is empty — vulnerable on the current release.
## Affected Versions
`<= 3.8.3` (github.com/siyuan-note/siyuan, Go). Unpatched on the latest release.
## Suggested Fix
Reject `..`/absolute components in `folder` (or enforce `IsSubPath` against `filepath.Join(util.TempDir, "export")`) before building `tmpDir`.
---
Reported by zx (Jace) — GitHub: @manus-use
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/siyuan-note/siyuan |
Corregida | v3.8.4+incompatible | 7 d | v3.8.7+incompatible no afectada |
v3.8.4+incompatibleArsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/siyuan-note/siyuan/security/advisories/GHSA-jf98-m24w-gm9mLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
