/

CVE-2026-93591

Severity:

HIGH RISK

(7.6)

SQL Injection (CWE-89) in SiYuan Graph Query Endpoint

CVE-2026-93591

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database access and private data exfiltration

Severity:

HIGH RISK

(7.6)

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 SQL injection vulnerability in the graph query path, where tag values are inserted into SQL statements without adequate escaping. A publish-mode reader or anonymous visitor may be able to influence those values and execute unauthorized database queries against the read-write database.

Affected context

The vulnerability occurs in SiYuan's graph functionality when the getGraph endpoint processes tag values supplied through inline HTML span elements. Deployments are at risk when these values reach the graph.go query2Stmt function and are concatenated into SQL string literals without sufficient parameterization or escaping. The exposure may include publish-mode and anonymous access paths, depending on how the instance is configured.

Exploit preconditions

  • Attack surface: The graph data retrieval endpoint and its tag-processing logic
  • Required access: A publish-mode reader or anonymous visitor may be sufficient where those access paths are enabled
  • Trigger point: Processing attacker-influenced tag values during graph query construction
  • Why exploitation is possible: Raw values are concatenated into SQL statements, allowing input to alter query semantics instead of being treated solely as data

Why this happens

The underlying bug is an SQL injection flaw caused by constructing database queries through direct string concatenation. In the affected graph query function, tag values are incorporated into SQL string literals without reliable parameter binding or complete escaping of quote characters. This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, because externally influenced input can modify the structure and behavior of a database command.

Potential impact

  • An attacker could read private data across notebooks
  • Unauthorized SQL queries could disclose application or metadata records
  • Database contents could be modified if the database account permits writes
  • Stored content or application integrity could be altered
  • Sensitive information could be exposed to unauthenticated or low-privilege users

General mitigation guidance

Mitigation generally focuses on ensuring that user-controlled values cannot influence SQL syntax.

Common defensive patterns include:

  • Using parameterized queries or prepared statements for every externally influenced value
  • Avoiding manual SQL string construction for filters and predicates
  • Applying strict allowlist validation for tags when the application supports a constrained format
  • Treating publish-mode and anonymous input as untrusted regardless of endpoint placement
  • Restricting database credentials to the minimum required read and write permissions
  • Separating read-only workloads from databases that contain private or mutable records where feasible
  • Preserving authorization checks at the data-access layer rather than relying only on UI or publication settings

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules that flag SQL strings assembled through concatenation or interpolation
  • Code review checks for database calls receiving raw request, tag, HTML, or metadata values
  • Verification that query parameters are bound separately from SQL command text
  • Dynamic testing of graph and search endpoints using quote-containing and structurally unusual input
  • Web application firewall or API policy monitoring for anomalous database-query patterns
  • Database audit logging to identify unexpected queries, broad record access, or writes from reader-facing sessions

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-5rwv-4j4c-f954
vulncheck.comvulncheck.com/advisories/siyuan-before-3.8.3-sql-injection-via-unescaped-tag-in-graph-go

Frequently asked

questions

Where the affected graph endpoint is exposed through publish mode or anonymous access, a reader or visitor may be able to trigger the vulnerable query path without an authenticated account.

The required access depends on deployment configuration, but the described exposure includes unauthenticated or low-privilege access to graph content. The attacker must be able to cause a value processed as a graph tag to reach the database query function.

Use parameterized database queries and ensure that all externally influenced values remain data rather than becoming part of SQL syntax. Input validation should provide defense in depth, not replace parameter binding.

Enforce secure database-access patterns through code review, static analysis, automated tests, and policy checks. Limit database privileges and monitor read-facing endpoints for unexpected query behavior or unusually broad data access.

Find out what's already
exploitable in your codebase.