/

CVE-2026-72807

Severity:

HIGH RISK

(8.0)

SQL Injection (CWE-89) in SiYuan Template View Columns

CVE-2026-72807

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database access and data modification

Severity:

HIGH RISK

(8.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SiYuan contains a second-order SQL injection vulnerability in attribute-view template columns that expose the queryBlocks function. When a crafted document or package is imported and rendered, raw SQL may be executed on the victim's kernel, potentially allowing unauthorized reading or modification of notebook data.

Affected context

The issue can arise in SiYuan deployments that support attribute-view template columns and execute the queryBlocks function while rendering imported content. Risk is higher when users import documents or packages from untrusted sources and the rendering process reaches the affected template logic.

Exploit preconditions

  • Attack surface: Imported SiYuan documents or packages containing attribute-view template columns
  • Required access: The victim must import the crafted content into a SiYuan instance
  • Trigger point: Rendering or processing the template column after import
  • Why exploitation is possible: The queryBlocks function constructs SQL through string substitution rather than parameterized query handling, allowing attacker-controlled template data to influence database queries

Why this happens

The vulnerability is caused by constructing SQL statements through direct string substitution of attacker-influenced values. Because the resulting query is executed without reliable parameter binding or equivalent input separation, crafted second-order data can become SQL syntax when the document is later rendered. This behavior maps to CWE-89, Improper Neutralization of Special Elements used in an SQL Command.

Potential impact

  • An attacker may read notebook or application database contents
  • An attacker could modify, corrupt, or delete stored notebook data
  • Sensitive information may be exposed to an importing user or an external party
  • Application integrity and trust in shared document packages could be reduced
  • Follow-on compromise could occur if database contents influence other application behavior

General mitigation guidance

Mitigation generally focuses on separating SQL code from all document- or

template-controlled values.

Common defensive patterns include:

  • Using parameterized queries or prepared statements for every dynamic value
  • Avoiding SQL construction through string concatenation or substitution
  • Applying strict allowlists for selectable fields, operators, and query modes
  • Validating template structures before storage and again before execution
  • Treating imported documents and packages as untrusted input
  • Restricting database permissions to only the operations required by the feature
  • Isolating application data stores and maintaining recoverable backups

How teams detect issues like this

Detection approaches can include:

  • Static analysis for SQL strings assembled with concatenation, interpolation, or substitution
  • Code review checks around queryBlocks and other template-exposed database functions
  • Tests using hostile metacharacters and unexpected query values to verify parameter binding
  • Runtime logging of query construction failures, anomalous database access, and unusual write activity
  • Policy enforcement requiring prepared statements for application database access
  • Automated security review tools that flag unparameterized SQL execution paths

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-x67c-8pwr-m8g3
vulncheck.comvulncheck.com/advisories/siyuan-before-sql-injection-via-queryblocks-template

Frequently asked

questions

It may be exploitable through distributed or shared documents and packages, but

exploitation depends on a victim importing and rendering the crafted content in

an affected SiYuan environment.

The attacker generally needs a way to distribute malicious SiYuan content and

persuade or otherwise cause a victim to import it. Direct access to the

victim's database is not necessarily required.

Replace raw SQL string substitution with parameterized queries, and constrain

template-controlled inputs through strict validation and allowlists.

Treat imported content as untrusted, limit database privileges, review

template-exposed functions, and enforce secure SQL construction rules in code

review and automated testing.

Find out what's already
exploitable in your codebase.