/

CVE-2026-72811

Severity:

CRITICAL RISK

(10.0)

SQL Injection (CWE-89) in SiYuan Backlink Search Query

CVE-2026-72811

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution with Cross-Notebook Data Access

Severity:

CRITICAL RISK

(10.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 critical SQL injection vulnerability in its backlink and mention search query, where user-supplied keywords and stored document metadata are incorporated into a SQL search statement without sufficient escaping. An anonymous or RoleReader user reaching the publish surface may be able to execute arbitrary SQL, potentially reading or modifying data across notebooks.

Affected context

The vulnerability occurs in SiYuan's backlink and mention search functionality when:

  • Search keywords are accepted from the publish-facing interface
  • Stored block metadata, such as titles, names, aliases, or anchor text, is included in the query
  • Those values are concatenated into a SQL MATCH or search statement
  • The application uses the main read-write database connection for the operation

Both directly supplied keywords and previously stored metadata may become part of the affected query.

Exploit preconditions

  • Attack surface: Backlink or mention search exposed through the publish surface
  • Required access: Anonymous access or RoleReader-level access may be sufficient, depending on deployment configuration
  • Trigger point: Construction and execution of the backlink or mention search query
  • Why exploitation is possible: The query concatenates untrusted values while escaping only double quotes, allowing single-quote characters in client input or stored metadata to alter SQL statement structure
  • Database conditions: Exploitation is more consequential when the application uses a read-write database handle and a driver that permits stacked statements

Why this happens

The underlying flaw is SQL query construction through string concatenation rather than parameter binding. The application combines client-controlled keywords and stored metadata with a SQL search expression, applying incomplete escaping that does not safely delimit all relevant input characters. This allows data intended as search content to be interpreted as SQL syntax, mapping to CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).

Potential impact

  • An attacker may read data across notebooks
  • An attacker could modify or delete database records
  • Sensitive document content may be disclosed
  • Application integrity and stored metadata may be compromised
  • Database-level changes can cause service disruption or data loss
  • Compromised data may affect users or downstream integrations

General mitigation guidance

Mitigation generally focuses on separating query structure from all variable data and reducing the privileges available to search operations.

Common defensive patterns include:

  • Use parameterized queries or prepared statements for search terms and metadata
  • Avoid constructing SQL statements through string concatenation
  • Apply context-appropriate validation and length limits to search input
  • Treat stored metadata as untrusted input when it is reused in database queries
  • Use a database account with only the permissions required for the search feature
  • Prefer read-only database access for read-only search operations where architecture permits
  • Restrict publish-surface access and isolate administrative or write-capable interfaces
  • Add regression tests covering quotes, delimiters, and unexpected metadata values

How teams detect issues like this

Detection can combine source review, automated analysis, and runtime monitoring:

  • Search code for SQL strings assembled with concatenation, interpolation, or formatting
  • Review database calls that place request parameters or stored fields directly into query text
  • Flag custom escaping logic that handles only selected quote characters
  • Verify that search and filter APIs use bound parameters or an equivalent safe abstraction
  • Monitor database logs for unexpected statement stacking, schema access, or cross-notebook query patterns
  • Enforce secure database-access policies through CI checks and code-review gates
  • Use neutral automated review tools to identify tainted data flows into SQL execution APIs

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-q2vg-7qgx-x5fc
vulncheck.comvulncheck.com/advisories/siyuan-before-sql-injection-via-backlink-search

Frequently asked

questions

Potentially. The affected search functionality is reachable through the publish surface, and the description indicates that anonymous or RoleReader access may be sufficient when that surface is exposed.

No. A client-supplied search keyword may be sufficient for first-order exploitation. Stored titles, aliases, names, or anchor text can also create a second-order path if they later enter the vulnerable query.

Use parameterized statements or prepared queries for every client-supplied and stored value, and avoid relying on partial manual escaping to protect SQL syntax.

Treat stored content as untrusted, enforce least-privilege database access, test search features with adversarial delimiters, and require secure query-construction patterns during code review and CI validation.

Find out what's already
exploitable in your codebase.