/

CVE-2026-101091

Severity:

HIGH RISK

(7.1)

SQL Injection (CWE-89) in SiYuan Block Query Embeds

CVE-2026-101091

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database modification and data integrity compromise

Severity:

HIGH RISK

(7.1)

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 improperly validates SQL statements in block query embed blocks, allowing malicious documents to contain non-read-only queries that execute against the application database.

When the document is automatically indexed, rendered, or exported, the embedded statements may run without authentication and could modify or damage stored data.

Affected context

The vulnerability occurs in SiYuan deployments using versions before v3.8.4 when a document contains block query embed content that is executed against siyuan.db. Risk increases when untrusted .sy documents can be imported, opened, indexed, rendered, or exported, because these background or document-processing operations may trigger SQL execution without an interactive authorization step.

Exploit preconditions

  • Attack surface: Block query embed SQL processing in document-handling workflows
  • Required access: Ability to supply, import, or otherwise cause SiYuan to process a malicious .sy document
  • Trigger point: Background indexing, rendering, or export of the document
  • Why exploitation is possible: SQL statements are not sufficiently restricted to read-only operations before execution

Why this happens

The underlying bug is inadequate validation and authorization of SQL statements embedded in block query content. The application treats document-provided SQL as an allowable query without reliably enforcing a read-only grammar or equivalent database permission boundary, enabling statements that can alter database state. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL Injection.

Potential impact

  • Stored application data may be modified or deleted
  • Document and workspace integrity could be compromised
  • Indexing, rendering, or export operations could produce altered or misleading results
  • Availability may be affected if destructive or resource-intensive statements execute
  • Sensitive database information could potentially be accessed, depending on query permissions

General mitigation guidance

Mitigation generally focuses on treating document-embedded SQL as untrusted input and enforcing a read-only execution boundary.

Common defensive patterns include:

  • Allowing only a narrowly defined, read-only SQL grammar for query embeds
  • Using parameterized query interfaces for values rather than concatenating document content into SQL
  • Parsing and validating statements before execution, with explicit rejection of write, schema, administrative, and multi-statement operations
  • Executing query embeds through a read-only database account or read-only connection where supported
  • Separating document rendering and export privileges from database modification privileges
  • Requiring explicit authorization before processing untrusted documents in high-privilege contexts
  • Applying resource limits and transaction isolation appropriate to document-driven queries

How teams detect issues like this

Detection approaches may include:

  • Static analysis for SQL construction from document content and execution paths lacking parameterization or allowlists
  • Code review checks for query execution during indexing, rendering, preview, and export workflows
  • Tests that submit non-read-only statements and confirm they are rejected before reaching the database
  • Database auditing for unexpected write, schema, or administrative statements from document-processing components
  • Policy enforcement requiring read-only credentials for embedded-query features
  • Automated security review tools configured to flag SQL execution involving untrusted document fields

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/e8ace0c89182c7ee1a1298ff2a849bb6a83dfdec
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-67p9-hm94-xwf3
vulncheck.comvulncheck.com/advisories/siyuan-before-3.8.4-sql-injection-via-block-query-embed

Frequently asked

questions

It may be exploitable without direct network access when an attacker can deliver or cause the application to process a malicious .sy document. The exact scope depends on how documents are imported and processed in the deployment.

The vulnerable SQL may execute without authentication during automatic processing, but an attacker still generally needs a way to introduce or trigger processing of a malicious document.

Treat embedded SQL as untrusted, permit only explicitly validated read-only query forms, and enforce read-only database permissions independently of application-side checks.

Combine strict query allowlists, parameterized database access, read-only credentials, adversarial tests for document-processing workflows, and auditing of database statements generated from untrusted content.

Find out what's already
exploitable in your codebase.