/

CVE-2026-69085

Severity:

CRITICAL RISK

(10.0)

SQL Injection (CWE-89) in SiYuan searchDocs endpoint

CVE-2026-69085

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary Database Read and Write via SQL Injection

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

A SQL injection flaw in SiYuan's /api/filetree/searchDocs endpoint allows attacker-controlled input in the keyword parameter to be concatenated directly into SQL without proper escaping or parameterization.

When publish mode is enabled or a RoleReader token is exposed, an attacker can issue stacked queries against a read-write SQLite database, potentially reading and modifying cleartext notebook content across the instance.

Affected context

The vulnerability occurs in SiYuan deployments that expose the /api/filetree/searchDocs endpoint, either through publish mode or RoleReader tokens.

It is relevant when the underlying database uses a read-write SQLite handle and the driver permits stacked SQL statements.

In such configurations, untrusted keyword values are concatenated directly into SQL queries used to search document metadata across cleartext notebooks.

Exploit preconditions

  • Attack surface: HTTP API endpoint /api/filetree/searchDocs
  • Required access:
  • A valid publish RoleReader token, or
  • Unauthenticated access when publish mode is enabled with Publish.Auth.Enable = false
  • Trigger point: Supplying crafted keyword input that becomes part of the SQL query string
  • Why exploitation is possible: The application builds SQL by string concatenation without parameter binding or escaping, and the SQLite driver executes stacked statements on a read-write connection

Why this happens

This issue is a classic example of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

The searchDocs logic dynamically constructs SQL using caller-supplied keyword values, directly embedding them into the query string.

Without parameterized queries or robust input neutralization, special characters such as quotes and semicolons are interpreted as part of the SQL syntax rather than data.

Because the database connection is read-write and the driver supports multiple semicolon-separated statements, injected input can alter the intended query or append additional commands, enabling arbitrary reads and writes across cleartext notebook tables.

Potential impact

  • An attacker may read sensitive content from all non-encrypted notebooks.
  • An attacker could modify, corrupt, or delete notebook entries and metadata.
  • An attacker can create or alter application-level data to impersonate users or forge content.
  • An attacker may introduce malicious records that affect downstream processing or exports.
  • An attacker could impact availability by performing destructive operations against the database.

General mitigation guidance

Mitigation typically focuses on eliminating direct string concatenation of untrusted input into SQL statements.

Secure patterns include:

  • Using parameterized queries or prepared statements for all database access paths that consume user or token-derived input.
  • Applying strict server-side validation and normalization of search parameters, treating them as data only and constraining allowable characters.
  • Structuring the data access layer so that query construction is centralized and follows a consistent, safe API that disallows ad hoc SQL assembly.
  • Restricting database permissions to the minimum necessary for the application's operations, reducing the blast radius of any injected statements.
  • Considering separation of search functionality into a read-only context where write operations are technically impossible, even if injection occurs.

How teams detect issues like this

Detection often combines static and review-based approaches:

  • Static analysis rules that flag SQL construction via string concatenation, especially where input parameters flow directly into query strings.
  • Code review practices that require developers to justify any dynamic SQL and demonstrate the use of parameter binding instead of manual escaping.
  • Centralized logging of database errors and anomalous query patterns, such as unexpected semicolons, comment markers, or suspicious predicates.
  • Security tests and fuzzing of API endpoints with crafted input designed to reveal injection paths and stacked statement execution behavior.
  • Integration of automated security scanning tools in CI pipelines that recognize common SQL injection sinks and tainted data flows.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-33jq-p8c2-q3q4
vulncheck.comvulncheck.com/advisories/siyuan-before-sql-injection-via-searchdocs

Frequently asked

questions

Exploitation is scoped to the database accessed by the vulnerable endpoint, but within that scope the attacker can issue arbitrary read and write operations against non-encrypted notebook data. Encrypted notebooks that rely on separate mechanisms may have additional protection, but cleartext content is fully exposed.

Not necessarily. If publish mode is configured with Publish.Auth.Enable = false, the endpoint can be reached without authentication. Otherwise, an attacker needs to obtain or guess a publish RoleReader token that grants access to the /api/filetree/searchDocs API.

The safest pattern is to refactor all database interactions in the affected endpoint to use parameterized queries or prepared statements. This involves treating the keyword parameter strictly as data, binding it through the database API rather than embedding it into SQL strings, and avoiding any reliance on manual escaping.

Prevention relies on combining secure coding standards with structural safeguards: enforce a policy that disallows direct concatenation of untrusted input into SQL, provide a well-designed data access layer that only exposes parameterized query primitives, add automated checks in CI to detect unsafe patterns, and require security-focused review for any code that builds dynamic queries.

Find out what's already
exploitable in your codebase.