/

CVE-2026-59834

Severity:

HIGH RISK

(7.5)

SQL Injection (CWE-89) in SiYuan Search API Endpoint

CVE-2026-59834

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized Data Access

Severity:

HIGH RISK

(7.5)

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's block search API endpoint improperly concatenates user-controlled path values into SQL predicates, enabling SQL injection within certain search modes.

An unauthenticated visitor of a published workspace can craft requests that inject UNION queries and exfiltrate rows from otherwise hidden documents.

Affected context

The vulnerability appears in SiYuan deployments that expose the full-text block search API (POST /api/search/fullTextSearchBlock) to publish visitors or other unauthenticated users.

It specifically affects non-SQL search modes where the backend builds SQL predicates by concatenating path values derived from the request body.

When hidden or private documents share the same underlying database as visible content, injected predicates can cause sensitive rows to be returned through otherwise allowed search responses.

Exploit preconditions

  • Attack surface: HTTP API endpoint POST /api/search/fullTextSearchBlock on a SiYuan instance.
  • Required access: Ability to act as an unauthenticated publish visitor or any user allowed to invoke the block search endpoint.
  • Trigger point: Submitting search requests containing specially crafted paths or related parameters that are concatenated into SQL predicates.
  • Why exploitation is possible: The application directly embeds attacker-controlled path values into SQL fragments without robust parameterization or validation, allowing UNION SELECT and other injected clauses to influence query results.

Why this happens

This issue stems from constructing SQL predicates by string concatenation using untrusted input from the search request.

Instead of using parameterized queries or safely constrained expressions, the backend treats path components as trusted fragments and appends them to the query used in non-SQL search modes.

This pattern maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where user-supplied data is interpreted as part of the SQL syntax rather than as data.

Potential impact

  • Unauthorized reading of rows from hidden or private documents.
  • Disclosure of internal metadata about documents, boxes, or paths not intended for publish visitors.
  • Potential exposure of sensitive personal notes or knowledge base content.
  • Information useful for further attacks, such as understanding data structure or internal identifiers.

General mitigation guidance

Mitigation focuses on treating all search parameters, including paths and box identifiers, strictly as data rather than query syntax.

Common defensive patterns include:

  • Using parameterized queries or query builders that separate SQL logic from data values.
  • Restricting allowed path values to a fixed, validated set and rejecting or normalizing unexpected input.
  • Applying server-side authorization checks that filter results by the caller's visibility rules, independent of client-supplied predicates.
  • Designing search modes so that higher-level filters (like visible boxes and paths) are applied after core query execution, not merged as raw SQL fragments.

How teams detect issues like this

Detection typically involves a combination of code and behavior analysis:

  • Static analysis rules that flag manual SQL string construction using request-derived fields (e.g., path, box, filter) concatenated into WHERE or UNION clauses.
  • Code review checklists that require parameterized queries for all search and filtering operations, especially in public or unauthenticated endpoints.
  • Dynamic testing and fuzzing of search endpoints with payloads containing quotes, parentheses, and UNION patterns to observe anomalous responses.
  • Automated security testing integrated into CI/CD that scans for SQL injection patterns and enforces policies against ad-hoc query building.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/57bcad4b331836880bfe6be25d4180bdcf10db0d
github.comgithub.com/siyuan-note/siyuan/commit/d0f0fe146fb07d594fcadc4f48d4f7c30ac01d1e
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.7.1
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-h89q-4j2h-7h88

Frequently asked

questions

Yes. Any party that can reach the exposed SiYuan publish interface or block search API over the network can attempt to exploit the SQL injection, without needing authentication.

Exploitation requires only the privileges of a publish visitor or equivalent unauthenticated role that can call the fullTextSearchBlock endpoint; no elevated backend access is needed.

The most robust fix is to refactor the search implementation to use fully parameterized queries or safe query builders, ensuring that path and box values are bound as parameters and never concatenated into SQL syntax, while also enforcing strict authorization on returned rows.

Establish a development standard that forbids manual SQL string concatenation with user input, enforce code review checks for search and filtering logic, and adopt automated static analysis or security linters that detect SQL injection patterns across the codebase.

Find out what's already
exploitable in your codebase.