/

CVE-2026-32767

Severity:

CRITICAL RISK

(9.8)

SQL Injection in SiYuan Full-Text Search Endpoint

CVE-2026-32767

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89, CWE-863

Impact:

Arbitrary SQL Execution and Privilege Bypass

Severity:

CRITICAL RISK

(9.8)

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 versions 3.6.0 and below contain an authorization-bypassed SQL injection flaw in the /api/search/fullTextSearchBlock endpoint when the method parameter is set to 2, causing user input to be executed as raw SQL without proper checks.

Any authenticated user, including low-privileged Readers, can execute arbitrary SQL statements against the application's SQLite database, violating the intended security model and enabling destructive data operations.

Affected context

The vulnerability occurs in SiYuan's backend API layer, specifically within the fullTextSearchBlock search endpoint when it is invoked with method=2.

In this mode, the endpoint treats user-supplied search parameters as raw SQL passed directly to the underlying SQLite engine.

Unlike the dedicated SQL API (/api/query/sql), this search path does not apply admin or read-only middleware, so any authenticated session in an affected version that can reach this endpoint is exposed.

Exploit preconditions

  • Attack surface: HTTP(S) API endpoint /api/search/fullTextSearchBlock
  • Required access: Any authenticated account; even the lowest-privileged Reader role can trigger the issue
  • Trigger point: Calling the endpoint with method=2 and supplying SQL syntax in the relevant request parameter(s)
  • Why exploitation is possible:
  • The handler forwards user-controlled input as a raw SQL statement to SQLite
  • No parameterization, escaping, or query whitelisting is enforced in this code path
  • The endpoint omits the CheckAdminRole and CheckReadonly authorization middleware applied to the intended SQL interface

Why this happens

At its core, this is a SQL Injection (CWE-89) vulnerability combined with Missing Authorization (CWE-863) on a powerful database interface.

The implementation of fullTextSearchBlock in method=2 mode accepts user input and concatenates or forwards it directly into a SQL execution API without parameter binding or query construction safeguards.

Because this endpoint also bypasses the authorization and read-only protections present on the official SQL endpoint, low-privileged users gain the ability to execute arbitrary SQL, including write and schema-modifying statements, contrary to the intended security policy.

Potential impact

  • Arbitrary read access to database tables beyond what the user's role should permit
  • Modification or deletion of notes, documents, and other stored content via UPDATE or DELETE
  • Destruction of application data and structure using DROP TABLE or similar commands
  • Tampering with internal metadata or access control records stored in the database
  • Potential denial of service for all users by corrupting or erasing critical tables

General mitigation guidance

Effective mitigation focuses on treating all database interaction through this endpoint as untrusted and aligning it with the existing security model:

  • Avoid passing user input as raw SQL; instead, use parameterized queries, query builders, or constrained search APIs for full-text operations.
  • Enforce the same authorization and read-only checks (CheckAdminRole, CheckReadonly, or their conceptual equivalents) on any endpoint capable of executing SQL, even indirectly.
  • Design search and reporting interfaces around fixed query templates where the user can only influence parameters, not the query structure itself.
  • Apply least-privilege principles at every trust boundary, ensuring that low-privileged roles cannot access generic SQL execution paths.
  • Centralize SQL execution logic behind a vetted service or module to reduce the risk of ad-hoc raw query execution in new endpoints.

How teams detect issues like this

Teams can detect similar issues by combining code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Flag any use of functions that execute SQL where the query string includes unvalidated or concatenated request parameters.
  • Look for duplicated or alternate code paths that reach the database without passing through standard authorization middleware.
  • Require reviewers to confirm that search endpoints use parameterized or structured query APIs rather than free-form SQL text.
  • Security testing and runtime monitoring:
  • Incorporate automated tests that attempt to inject SQL control characters into API parameters and verify they are rejected or safely handled.
  • Log and monitor for suspicious SQL patterns (e.g., DROP TABLE, UPDATE, DELETE without WHERE clauses) originating from nominally read-only endpoints.
  • Policy enforcement:
  • Establish engineering guidelines that forbid direct execution of user-supplied SQL and mandate the use of shared database access layers.
  • Optionally employ SAST/DAST tools or CI hooks configured to highlight raw SQL execution patterns fed by user input.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/d5e2d0bce0dffef5f61bd8066954bc2d41181fc5
github.comgithub.com/siyuan-note/siyuan/issues/17209
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.6.1
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-j7wh-x834-p3r7

Frequently asked

questions

Yes. Any user who can authenticate to an affected SiYuan instance and send HTTP requests to /api/search/fullTextSearchBlock can attempt to exploit the issue, assuming method=2 is accepted in that deployment.

No. The flaw is that the endpoint lacks the protections applied to the dedicated SQL API, so even accounts with the Reader role can submit arbitrary SQL statements through this search path.

Route all SQL execution through a controlled interface that uses parameterized queries and enforces role-based authorization and read-only constraints.

For search endpoints, expose only structured search parameters and internally translate them into safe queries rather than allowing user-supplied SQL.

Treat any new endpoint that touches the database as high risk: require parameterized access, reuse common authorization middleware, prohibit raw SQL from user input, and subject such endpoints to targeted security review and automated testing before release.

Find out what's already
exploitable in your codebase.