Summary
SiYuan's publish service contains an authorization logic flaw that exposes bookmarked blocks from password-protected documents to unauthenticated users.
When the bookmark API is called in read-only publish mode with a nil context, the password check is skipped, allowing anyone who can reach the publish service to read content from documents marked as Protected if they contain at least one bookmark.
Affected context
This vulnerability affects SiYuan instances using the publish/read-only mode with documents configured as Protected and containing bookmarked blocks.
The issue arises specifically in the /api/bookmark/getBookmark endpoint, where the access-control filter assumes a nil request context is authorized and omits the publish password verification.
Environments that expose the publish service to untrusted networks or the public internet are at heightened risk of unauthorized data disclosure.
Exploit preconditions
- Attack surface: HTTP API of the SiYuan publish service, particularly the
/api/bookmark/getBookmarkendpoint. - Required access: Network access to the publish service; no valid credentials or publish password are required.
- Trigger point: An attacker invokes the bookmark retrieval API while the server is in publish/read-only mode and target documents have at least one bookmarked block.
- Why exploitation is possible: The authorization filter
FilterBlocksByPublishAccess(nil, ...)interprets a nil context as already authorized and bypasses the password protection check for Protected documents.
Why this happens
The core issue is an authorization logic error where the system incorrectly treats the absence of an authentication/authorization context as equivalent to a trusted, authorized state.
In the affected code path, the filter function responsible for enforcing publish-time access control is invoked with a nil context, which leads it to skip the password verification for Protected documents.
This maps to CWE-863: Incorrect Authorization, where the system fails to correctly enforce access rules on a protected resource, resulting in confidential content being returned to unauthorized callers.
Potential impact
- Unauthorized reading of content from password-protected documents that contain bookmarked blocks
- Exposure of sensitive notes, personal records, or confidential knowledge base entries
- Leakage of internal project information, credentials, or other secrets inadvertently stored in Protected documents
- Erosion of user trust due to perceived confidentiality guarantees not being honored
General mitigation guidance
Mitigation generally centers on ensuring that authorization checks are consistently enforced and cannot be bypassed through special or default contexts.
Recommended defensive patterns include:
- Treating a missing or nil security context as unauthenticated by default, requiring explicit validation before granting access
- Centralizing authorization decisions in a unified access-control layer rather than duplicating checks in individual endpoints
- Applying explicit checks for document protection state (e.g., Protected vs. public) on all read paths, including bookmark and search features
- Designing APIs such that every request path must successfully pass both authentication and authorization stages before content retrieval
- Using secure defaults where any ambiguity in context or user identity results in denial of access rather than implicit allow
How teams detect issues like this
Organizations can detect similar authorization flaws through a combination of design review, testing, and automated analysis:
- Code review: Examine all entry points to protected content (bookmarks, search, previews, exports) to confirm they invoke a common authorization routine and do not special-case nil or anonymous contexts as authorized.
- Static analysis: Configure rules to flag authorization checks that depend on nullable context objects, or that bypass checks when context is nil or missing.
- Security testing: Perform access-control testing against the publish/read-only endpoints to verify that Protected resources are not accessible without valid credentials or passwords.
- Policy enforcement: Use automated code scanning in CI to require explicit authorization calls on any API handler that returns document content or metadata that could be sensitive.

