SQL injection in siyuan-note SiYuan exposes document history

Note: This data is for reference and cybersecurity research purposes only.CyStack advises users not to use this information for unlawful purposes.

What is CVE-2026-116170?

CVE-2026-116170 is a vulnerability classified as Improper Neutralization of Special Elements used in an SQL Command, affecting siyuan (affected versions: < 3.8.7). This vulnerability is rated Medium, with a CVSS score of 6.9. Public exploit code or evidence is available for this vulnerability, but that does not confirm exploitation in the wild.

Overview

Original source data

SiYuan before v3.8.7 contains an sql injection vulnerability that allows admin-token holders to read history.db by injecting unescaped op and type=3 query values. Attackers can send crafted UNION SELECT payloads to searchHistory or getHistoryItems endpoints to exfiltrate deleted document content, titles, and paths.

Affected products and scope

  • siyuan-note/siyuan: semver versions with version set to 0 and lessThan: 3.8.7 are marked affected. The vendor advisory describes the same boundary as <= 3.8.6.
  • 3.8.7: recorded by the CNA as unaffected and identified by the vendor advisory as patched.
  • The available evidence does not establish the status of parallel branches or other builds outside these stated boundaries.

Technical details

The flaw is in SiYuan's history-search handling. Attacker-controlled fields, including op and query when type=3, are concatenated into SQL string literals without sufficient escaping and then executed against history.db.

  1. An authenticated request using an admin token reaches searchHistory, getHistoryItems, or the MCP history tool.
  2. buildSearchHistoryQueryFilter places op into the SQL condition. When type=3 is used for document-ID searches, query bypasses the stringQuery escaping path.
  3. The sql.QueryHistory and sql.SelectHistoriesRawStmt sinks execute the resulting raw SQL without the corresponding single-statement or read-only checks.
  4. The resulting read path can expose document history in bulk, including content, titles, and paths from deleted documents.

This is CWE-89, Improper Neutralization of Special Elements used in an SQL Command. The available evidence confirms the named endpoints and components; actual reachability still depends on how each deployment exposes its API and protects admin tokens.

Exploitability

The vulnerability is remotely reachable when an attacker has an admin token or equivalent authorization. No separate user interaction is required, and the vendor advisory documents direct verification against a vulnerable SiYuan kernel.

A public proof of concept has been published. It demonstrates abuse of op and the type=3 query path to read data from history.db, and documents UNION SELECT based extraction of history columns without requiring a separate application action from another user.

The admin-token requirement is material: the flaw does not itself provide that token. The available record does not identify a named campaign, victim, or confirmed in-the-wild exploitation.

Technical impact

The direct technical impact is loss of confidentiality for data stored in history.db, especially the history of deleted documents. The attacker needs an admin token, so this is not an independent privilege-escalation path from an unprivileged account.

The vendor evidence shows that history can be read in bulk and beyond the data normally returned by the structured history API. The available record does not confirm modification or denial of service in the described attack path; the advisory instead warns that the sink lacks read-only and single-statement guards needed to limit future write or statement-stacking changes.

Business impact

Successful exploitation can disclose document history beyond the data normally exposed by the structured history API. Exposed data may include content, titles, and paths from deleted documents, creating risk for internal information, personal data, or records that users believed were no longer accessible.

The attacker must already possess an admin token, so practical risk depends on token protection and network exposure of the API. The available evidence describes a read path and does not confirm data modification or service disruption.

Remediation

  1. Upgrade SiYuan to 3.8.7, the release identified as patched by both the vendor advisory and the CNA affected data.
  2. After upgrading, verify that inventory shows the patched release is actually running and that no affected instance remains. Include deployments whose history APIs are called by clients or MCP integrations.
  3. If there is evidence that an admin token was exposed or used unexpectedly, revoke or replace the relevant token as a precautionary response step. This does not replace the upgrade.
  4. If immediate upgrading is not possible, reduce network access to the administration API and history endpoints. This is temporary exposure reduction, not a vendor-confirmed fix.

The advisory also describes source-level remediation: escape op and query for every query type, and apply single-statement and read-only validation at the history SQL sinks. Organizations maintaining custom builds should verify the corresponding changes before deployment.

Detection

  1. Inventory every deployed SiYuan version and identify instances within the affected release boundary. Include direct installations and instances reached through a proxy, plugin, or MCP integration.
  2. Determine which networks can reach the history APIs, especially POST /api/history/searchHistory and POST /api/history/getHistoryItems, and review where admin tokens are stored and used.
  3. If access or audit logging is available, review requests to those endpoints for unusual op values or unusual query values used with type=3. This is precautionary monitoring, not a confirmed indicator of compromise.
  4. Correlate responses or history access with bulk retrieval of deleted document content, titles, or paths.
  5. No specific IOC is established in the available evidence. The absence of suspicious log entries does not prove that a system is safe, particularly where API logging is incomplete.
Sources (8)
Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.