Summary
Siyuan versions before v3.8.2 contain an authenticated SQL injection vulnerability in the fullTextSearchBlock endpoint when the method=1 query parameter is processed. An attacker with valid access may inject SQL expressions to read document blocks and sensitive attributes beyond intended publish-access controls.
Affected context
The vulnerability occurs in Siyuan's full-text block search functionality when the fullTextSearchBlock endpoint handles the method=1 query parameter. It becomes risky when authenticated users can influence query-related input and the application incorporates that input into database statements without sufficient parameterization or equivalent controls. The exposed data may include document content and attributes from the blocks table.
Exploit preconditions
- Attack surface: The authenticated
fullTextSearchBlockapplication endpoint - Required access: A valid authenticated account capable of invoking the affected search functionality
- Trigger point: Processing the
method=1query parameter - Why exploitation is possible: User-controlled input can influence SQL statement structure, allowing query manipulation and retrieval of records outside normal publish-access restrictions
Why this happens
The underlying bug is SQL injection, mapped to CWE-89. The application appears to treat request-controlled search input as part of database query syntax rather than as data bound through a parameterized interface. This insecure pattern can allow injected query clauses, including set-based retrieval logic, to alter the intended database operation and expose records that authorization checks would otherwise restrict.
Potential impact
- An attacker may read document content from the blocks table.
- Sensitive block attributes may be disclosed.
- Publication or visibility controls could be bypassed during data retrieval.
- Stolen content could enable privacy breaches, intellectual property loss, or targeted follow-on attacks.
- Database information may be used to identify additional sensitive application data.
General mitigation guidance
Mitigation generally focuses on removing user-controlled SQL syntax from database operations and preserving authorization boundaries.
Common defensive patterns include:
- Using parameterized queries, prepared statements, or carefully maintained query builders for all search inputs.
- Applying allowlisted validation for supported search modes and query operators.
- Enforcing document-level authorization after query execution and before returning results.
- Limiting database credentials to the minimum read permissions required by the search feature.
- Avoiding broad result projections and returning only fields necessary for the request.
- Keeping sensitive data separated from query paths that are available to ordinary authenticated users.
How teams detect issues like this
Organizations commonly detect SQL injection risks through:
- Static analysis rules identifying string concatenation or interpolation in SQL construction.
- Code review checks for request parameters passed directly into database APIs.
- Dynamic testing of search endpoints with harmless query-manipulation cases and authorization-boundary tests.
- Database monitoring for unusual
UNION, comment, or schema-enumeration patterns in application-generated queries. - Policy enforcement requiring parameterized query APIs and security tests for authenticated data-access endpoints.
Automated application-security and code-review tools may help identify unsafe query construction, but findings should be validated against the application's authorization model.

