CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-32704
6.5

CVE-2026-32704: Improper Authorization and Information Disclosure in SiYuan Template Rendering

Alon Barad
Alon Barad
Software Engineer

Mar 14, 2026·5 min read·4 visits

PoC Available

Executive Summary (TL;DR)

A missing authorization check in SiYuan's `renderSprig` API endpoint allows low-privileged authenticated users to execute arbitrary SQL queries via malicious templates, exposing all workspace data.

SiYuan versions prior to 3.6.1 contain an improper authorization vulnerability in the template rendering API. An authenticated attacker can exploit a missing access control check to execute arbitrary SQL queries against the local workspace database, leading to high-impact information disclosure.

Vulnerability Overview

SiYuan is a personal knowledge management system that utilizes a local SQLite database to store user workspaces, notes, metadata, and custom attributes. The application exposes an administrative API to facilitate various backend operations, including the evaluation of templates via the Sprig library. This template engine is designed to allow administrators to dynamically generate content and query the underlying data structures.

CVE-2026-32704 is an improper authorization vulnerability (CWE-285) located in the POST /api/template/renderSprig endpoint. This specific route handles the parsing and execution of Sprig templates submitted via HTTP requests. The vulnerability arises because the endpoint fails to verify whether the requesting user possesses administrative privileges before processing the template.

Consequently, the application processes the template using the privileges of the application process itself. Since the SiYuan template engine explicitly exposes a SQL function to the template context, an authenticated attacker can leverage this endpoint to interact directly with the backend SQLite database.

Root Cause Analysis

The root cause of CVE-2026-32704 lies in the omission of the standard authorization middleware or check function on the renderSprig API route. In the SiYuan codebase, administrative endpoints are expected to invoke model.CheckAdminRole to validate the authorization token and role of the incoming request. This function ensures that only highly privileged users can access sensitive backend features.

The renderSprig endpoint was deployed without this crucial model.CheckAdminRole invocation. When an HTTP POST request reaches the route, the application only verifies that the request contains a valid authentication token, satisfying the low-privilege requirement. It then proceeds to pass the user-supplied JSON payload directly to the Sprig template rendering engine.

The Sprig environment configured by SiYuan includes custom functions tailored for workspace management. One of these functions, typically exposed as sql, accepts a raw SQL query string, executes it against the local SQLite database, and returns the result set to the template context. Because the authorization check is absent, any authenticated user can successfully invoke this powerful internal function.

Exploitation Methodology

Exploitation of CVE-2026-32704 requires the attacker to possess valid credentials or an authentication token for a non-administrative account on the target SiYuan instance. Network access to the application's API interface is also necessary. The attack vector relies entirely on standard HTTP requests, requiring no specialized tools beyond an HTTP client.

The attacker crafts a POST request to /api/template/renderSprig with a JSON body containing the template key. The value of this key contains the malicious Sprig payload. By utilizing the pipeline operator (|) in the template syntax, the attacker passes an arbitrary SQL query string into the sql function exposed by the engine.

POST /api/template/renderSprig HTTP/1.1
Host: [siyuan-host]
Authorization: Token [user-token]
Content-Type: application/json
 
{
  "template": "{{ \"SELECT * FROM blocks LIMIT 5\" | sql }}"
}

Upon processing the request, the backend evaluates the template, executes the embedded SELECT statement, and serializes the result. The application returns this data within the HTTP response body. An attacker can systematically query the database schema and exfiltrate all tables by altering the SQL payload in subsequent requests.

Impact Assessment

The vulnerability carries a CVSS v3.1 score of 6.5 (Medium severity), calculated with the vector CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N. The primary impact is a total loss of confidentiality for the data stored within the SiYuan workspace. The attack vector is network-based and involves low complexity, making it highly reproducible.

An attacker successfully exploiting this vulnerability gains read access to the entire SQLite database. This exposes all user notes, sensitive metadata, custom attributes, and application configuration settings. If the workspace contains proprietary information, credentials, or personal data, the exposure represents a severe security breach.

The CVSS vector indicates no impact on integrity or availability. The exposed SQL function within the template engine is typically restricted to data retrieval operations, preventing the execution of INSERT, UPDATE, or DELETE statements. However, the exact limitations depend on the underlying SQLite connection configuration and the specific implementation of the sql helper function.

Remediation and Detection

The vendor addressed CVE-2026-32704 in SiYuan version 3.6.1. The patch introduces the missing model.CheckAdminRole validation within the handler for the /api/template/renderSprig endpoint. This ensures that the application verifies administrative privileges before passing the request body to the template engine, effectively closing the unauthorized access vector.

Organizations operating SiYuan instances must upgrade to version 3.6.1 or later immediately. As an interim mitigation, administrators should ensure that SiYuan instances are strictly isolated from untrusted networks. Deploying a reverse proxy equipped with an external identity provider (e.g., OIDC) can restrict baseline access to the application, reducing the available attack surface.

Security teams can detect exploitation attempts by monitoring application and reverse proxy logs. A high volume of requests to the /api/template/renderSprig endpoint from standard user accounts indicates suspicious activity. Additionally, Web Application Firewalls (WAF) can be configured to inspect the template parameter in POST requests for common SQL keywords, providing an active defense layer against exfiltration payloads.

Official Patches

siyuan-noteGitHub Security Advisory

Technical Appendix

CVSS Score
6.5/ 10
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Affected Systems

SiYuan Personal Knowledge Management System

Affected Versions Detail

Product
Affected Versions
Fixed Version
SiYuan
siyuan-note
< 3.6.13.6.1
AttributeDetail
CWE IDCWE-285
Attack VectorNetwork
CVSS Score6.5
ImpactHigh Confidentiality
Exploit StatusProof of Concept Available
AuthenticationRequired (Low Privilege)

MITRE ATT&CK Mapping

T1222File and Directory Permissions Modification
Defense Evasion
T1059.004Command and Scripting Interpreter: Unix Shell
Execution
CWE-285
Improper Authorization

The software does not perform or incorrectly performs an authorization check when an actor attempts to access a resource.

Vulnerability Timeline

Vulnerability publicly disclosed and CVE-2026-32704 assigned.
2026-03-13
GitHub Security Advisory (GHSA-4j3x-hhg2-fm2x) published.
2026-03-13

References & Sources

  • [1]GHSA-4j3x-hhg2-fm2x
  • [2]CVE-2026-32704 Record
  • [3]SiYuan GitHub Repository

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.