Junglewise Threat Intelligence

SiYuan SQL injection via queryBlocks template

Severity: high · CVSS 8 · Published 2026-08-12

Executive brief

SiYuan is a note-taking and knowledge management application. A second-order SQL injection vulnerability in attribute-view template columns allows attackers to execute arbitrary SQL queries by distributing malicious documents or packages that execute when imported and rendered by victims, potentially exposing or modifying sensitive data across notebooks.

Technical details

The vulnerability exists in attribute-view (AV) template columns, which are live-evaluated on every render and expose the queryBlocks template function. The queryBlocks function executes raw SQL using string substitution (? → argument) rather than parameterized query binding against the read-write database handle (SelectBlocksRawStmt). This is a second-order injection: while AV mutations are admin-gated and not directly reader-injectable, an attacker can distribute a malicious SiYuan document or AV package containing a template column with crafted SQL (e.g., `.action{queryBlocks "<arbitrary SQL>"}`) that executes on any victim kernel that imports and renders the package. Because the underlying sqlite3 handle supports statement stacking, attackers can perform both reads across the publish/password boundary and writes via UNION queries. The fix is to parameterize queryBlocks or restrict the template function set available in AV columns.

Affected products

  • SiYuan SiYuan < 3.7.4

Timeline

  • 2026-07-23: disclosed
  • 2026-08-12: advisory

References

Related threats