GHSA-x67c-8pwr-m8g3: SQL Injection

Published Sep 3, 2026
·
Updated

CVE: This vulnerability corresponds to CVE-2026-72807.

Summary

Attribute-view (AV) template columns are live-evaluated on every render and expose the queryBlocks template function, which runs raw SQL on the read-write database handle (SelectBlocksRawStmt, using ?→argument string substitution rather than parameter binding). AV mutations are admin-gated, so this is not directly reader-injectable but it is a second-order vector: an attacker distributes a SiYuan document or AV package whose template column contains .action{queryBlocks "<arbitrary SQL>"} when a victim imports the package and renders the AV, the attacker's SQL executes on the victim's kernel (read and, via statement stacking, write).

Details

Doc-level {{…}} templates are rendered at insert-time and become static, so they are not re-evaluated on reader view. The residual is AV template columns, which are live-evaluated at render. queryBlocks passes its argument to SelectBlocksRawStmt with ?→arg string substitution, not a bound parameter, on the main read-write handle (88250/go-sqlite3 fork, statement-stacking capable) so an attacker-controlled template argument becomes arbitrary SQL.

The SSTI surface is otherwise hardened: BuiltInTemplateFuncs deletes env, expandenv, and getHostByName so there is no environment/host/file/exec SSTI. queryBlocks-to-SQL is the remaining live-evaluated sink.

Proof of Concept

An AV template column set to .action{queryBlocks "<sql>"} executes <sql> against the read-write handle when the AV is rendered. Delivered second-order: a shared/imported document or AV package carrying such a column runs the embedded SQL on any kernel that imports and renders it.

Proof of Concept

Reproduced on a live instance.

1. Host doc + AV (admin, 6806): POST /api/filetree/createDocWithMd {notebook, path:"/ssti-poc", markdown:"host"} → DOC POST /api/av/renderAttributeView {id:"<AV>"} # materializes the AV

2. Plant the malicious template column (one performTransactions call): json {"reqId":1,"session":"poc","transactions":[{"doOperations":[ {"action":"addAttrViewCol","avID":"<AV>","id":"<COL>","name":"tpl","type":"template"}, {"action":"updateAttrViewColTemplate","avID":"<AV>","id":"<COL>","type":"template", "data":".action{range queryBlocks \"SELECT FROM blocks WHERE rootid='<PROTECTEDDOCID>'\"}.action{.Markdown} .action{end}"}, {"action":"insertAttrViewBlock","avID":"<AV>","isDetached":true} ]}]}

3. Trigger (render evaluates the template): POST /api/av/renderAttributeView {id:"<AV>"} Result: the template cell renders ## LockedSection TOPSECRET… the queryBlocks SQL executed and returned the password-protected document's content, arbitrary SQL via template reading across the publish/password boundary. queryBlocks uses ?→arg string substitution (not parameterized), so UNION and stacked writes are also possible. Delivered second-order, the same column executes on any kernel that imports and renders the AV.

Impact

An attacker who gets a victim to import a crafted document/AV package and render it achieves arbitrary SQL execution on the victim's kernel cross-notebook read and via stacking, write. Precondition is content delivery plus render (import of an attacker-supplied package), which bounds severity to Medium. Not directly reachable by an anonymous reader (AV creation is admin-gated); the injection travels in stored/imported template content.

Suggested fix

Parameterize queryBlocks bind the argument rather than substituting it into the SQL string or restrict the template function set available in AV columns as was done for the doc-template functions. Treat imported template content as untrusted at render time.

Affected Software

1 affected componentFixes available
go/github.com/siyuan-note/siyuan/kernel<0.0.0-20260723035036-0a176345e02a
0.0.0-20260723035036-0a176345e02a

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/siyuan-note/siyuan/kernel to a version that resolves this vulnerability.

    Fixed in 0.0.0-20260723035036-0a176345e02a
  2. Configuration

    In AV template column rendering, modify the `queryBlocks` implementation to parameterize/bind the argument (instead of using `?`→argument string substitution when calling `SelectBlocksRawStmt`), so the template argument cannot become arbitrary SQL (including UNION/statement-stacking writes).

    SiYuan Attribute-view (AV) template columns queryBlocks template function = parameterize (bind) template arguments instead of `?`→string substitution
  3. Configuration

    Restrict the template function set available in AV template columns so that `queryBlocks` is not available/usable in AV template columns (the material notes a similar restriction already exists for doc-template functions via `BuiltInTemplateFuncs`).

    SiYuan AV template columns available template function set = restrict `queryBlocks` (or remove it) from AV columns
  4. Compensating control

    Treat imported/stored template content used in Attribute-view (AV) template columns as untrusted and enforce restrictions at render time (e.g., remove or limit live-evaluated sinks such as `queryBlocks`) because AV template columns are live-evaluated on every render.

Event History

Sep 3, 2026
Advisory Published
via GitHub·10:49 PM
Data Sourced
via GitHub·10:49 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Who is realistically exposed to this issue?

Users who import an attacker-supplied SiYuan document or attribute-view package and then render an attribute view containing a malicious template column are exposed. The vector is second-order: the SQL runs on the victim's kernel after import and rendering.

2

Can an untrusted reader inject SQL directly through normal document templates?

No. Document-level {{…}} templates are rendered at insert time and become static, rather than being re-evaluated when a reader views the document. Attribute-view mutations are also admin-gated, so the issue is not directly reader-injectable.

3

What capabilities does the malicious template obtain when it is rendered?

The queryBlocks template function sends raw SQL to the main read-write database handle using string substitution rather than parameter binding. The available SQLite driver supports statement stacking, so the supplied SQL can read data and potentially perform writes.

4

What can be done before a fix is applied?

Do not import or render attribute views from untrusted SiYuan documents or AV packages. Treat template columns in imported packages as executable content because they are evaluated live during rendering.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203