Listen to this Post
The /api/search/fullTextSearchAssetContent endpoint exposes two SQL injection flaws. Both flaws affect the asset-content database. They are reachable by the publish RoleReader token. They are also reachable anonymously if Publish.Auth.Enable is false. Method 2 passes a client-supplied SQL statement to the read-write DB. It lacks the admin guard that its sibling fullTextSearchBlock applies. No CheckSingleStatement or CheckReadonlyStatement guards the query. Method 3 constructs a REGEXP clause by concatenating user input. It does not escape single quotes, unlike the block-search builder. A single quote breaks out of the literal into the SQL context. Both run on a read-write handle through the 88250/go-sqlite3 driver. The driver supports statement stacking via semicolons and ATTACH. The asset-content store spans across all notebooks in the instance. parseSearchAssetContentArgs reads method and query unfiltered from JSON. fullTextSearchAssetContent does not check IsAdminRoleContext for method 2. filterQueryInvisibleChars only removes invisible ASCII characters. It does not strip quotes, semicolons, or SQL syntax tokens. The post-hoc FilterAssetContentByPublishAccess runs after execution. Thus it cannot prevent the SQL statement from executing. An attacker can read asset-content data from any notebook. The read-write handle permits modification of database content. Attackers can use ATTACH DATABASE to read or write external files. No admin or write permission is required via the normal API. The sibling endpoint fullTextSearchBlock correctly rejects SQL for readers. The assetContentFieldRegexp function omitted the proper escaping step. This omission directly enables the SQL breakout vulnerability. The vulnerable code is located in router.go with CheckAuth only. The DSN does not set mode=ro or _query_only for the assetContentDB. Code execution is not reachable as load_extension is disabled. However, arbitrary SQL execution and data modification are viable. This constitutes a critical risk requiring an urgent fix.
DailyCVE Form:
Platform: SiYuan Note
Version: All prior builds
Vulnerability: Remote SQL Injection
Severity: Critical
date: 2026-09-04
Prediction: Patch within weeks
What Undercode Say:
Create notebook as admin
curl -s -X POST http://127.0.0.1:6806/api/notebook/createNotebook -H "Content-Type: application/json" -H "Authorization: Token g4wj3r04ntobe9m4" -d "{\"name\":\"F3\"}"
Create secret doc (use returned BOX and DOC IDs)
curl -s -X POST http://127.0.0.1:6806/api/filetree/createDocWithMd -H "Content-Type: application/json" -H "Authorization: Token g4wj3r04ntobe9m4" -d "{\"notebook\":\"BOX\",\"path\":\"/f3-secret\",\"markdown\":\" SecretSection\n\nUNIQUE_MARKER_99 hidden body text\"}"
Get heading block ID
curl -s -X POST http://127.0.0.1:6806/api/query/sql -H "Content-Type: application/json" -H "Authorization: Token g4wj3r04ntobe9m4" -d "{\"stmt\":\"SELECT id,type,content FROM blocks WHERE type='h'\"}"
Disable doc from publishing
curl -s -X POST http://127.0.0.1:6806/api/filetree/setPublishAccess -H "Content-Type: application/json" -H "Authorization: Token g4wj3r04ntobe9m4" -d "{\"id\":\"DOC\",\"visible\":false,\"password\":\"\",\"disable\":true}"
Reader proof of concept (retrieve hidden content)
curl -i -X POST http://127.0.0.1:6808/api/block/getHeadingChildrenDOM -H "Content-Type: application/json" -d "{\"id\":\"HEADING\"}"
Exploit: (Educational Purposes!)
An attacker with only publish RoleReader access or no authentication (if auth disabled) exploits two paths. Using method 2, the attacker injects raw SQL via the “query” parameter to modify or read data. Using method 3, the attacker injects a single quote into the “query” parameter breaking the REGEXP literal, allowing stacked SQL statements. The provided curl sequence creates a privileged secret document, disables its public visibility, and then retrieves the full HTML containing “UNIQUE_MARKER_99” as an anonymous user, proving the filter bypass works against disabled documents.
Protection: from this CVE
Apply the missing admin guard by adding `method == 2 && !IsAdminRoleContext` rejection to fullTextSearchAssetContent. Route the raw-SQL path through CheckSingleStatement and CheckReadonlyStatement to enforce read-only constraints. Add `ReplaceAll(exp, “‘”, “””)` in assetContentFieldRegexp to match the safe escaping in fieldRegexp. Deploy a separate `_query_only=1` database handle for all reader-reachable asset-content queries to prevent ATTACH and write operations.
Impact:
Unauthenticated remote SQL injection granting arbitrary read/write access to the asset-content database, cross-notebook data disclosure, modification of stored content, and file system interaction via ATTACH, all without requiring any admin privileges.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

