Summary
SiYuan's WebSocket endpoint accepts unauthenticated connections when specific URL parameters are supplied, allowing external clients to subscribe to server push events without logging in.
When a victim has a local SiYuan instance running, a malicious website can open a cross-origin WebSocket to that endpoint and passively monitor sensitive document metadata and user activity in real time.
Affected context
This vulnerability affects SiYuan instances that:
- Expose the WebSocket endpoint
/wson a network-accessible interface (including localhost in a typical desktop setup) - Accept connections without authentication when given the parameters
?app=siyuan&id=auth&type=auth - Push document-related events over this channel, such as titles, notebook names, file paths, and CRUD operations
The risk is particularly relevant when users browse untrusted websites while SiYuan is running, because those sites can attempt cross-origin WebSocket connections to the local service.
Exploit preconditions
- Attack surface: WebSocket endpoint at
/wson the SiYuan HTTP service - Required access: Network reachability to the victim's SiYuan instance (often via
localhostfrom the victim's browser) - Trigger point: Opening a WebSocket connection using the crafted URL
/ws?app=siyuan&id=auth&type=auth - Why exploitation is possible:
- The endpoint treats connections with these parameters as implicitly authenticated to keep the kernel alive for the login page.
- No proper authentication or session verification is enforced for such connections.
- The implementation does not validate the WebSocket
Originheader, so cross-origin connections from arbitrary websites are accepted.
Why this happens
The core issue is an authentication bypass caused by trusting specific client-supplied URL parameters instead of enforcing proper authentication and authorization checks.
The server implicitly assumes that requests with app=siyuan&id=auth&type=auth originate from the internal login flow and skips normal authentication for them.
Combined with missing Origin validation, this design maps to CWE-287: Improper Authentication, where workaround or "special case" logic unintentionally creates a path that grants access without validating the user's identity or session.
Potential impact
- Exposure of document titles, notebook names, and file paths to unauthorized parties
- Real-time visibility into all CRUD operations (create, read, update, delete) performed by authenticated users
- Behavioral profiling of a user's note-taking and knowledge-management patterns
- Potential correlation of leaked metadata with other data sources to infer sensitive topics, projects, or personal information
- Increased attack surface for social engineering or targeted phishing based on observed activity
General mitigation guidance
Effective mitigation focuses on removing implicit trust and enforcing consistent authentication on real-time channels:
- Require full authentication (e.g., session or token verification) for all WebSocket connections, regardless of URL parameters or client context.
- Eliminate or strictly constrain "special" parameter-based bypasses intended for internal flows; if needed, gate them behind verifiable, server-side session checks.
- Tie WebSocket authorization to user identity and permissions, ensuring each connection only receives events allowed for that principal.
- Enforce robust origin and host validation policies for browser-initiated WebSocket connections, especially when the service can be accessed from
localhost. - Apply least-privilege to push channels by limiting event data to the minimum necessary and avoiding inclusion of sensitive metadata where possible.
How teams detect issues like this
Detection can leverage both code-centric and behavior-centric approaches:
- Static analysis and code review
- Flag WebSocket endpoints that bypass normal authentication or authorization flows based on URL parameters or query flags.
- Identify code paths where
Originor similar headers are ignored for browser-facing WebSocket endpoints. - Look for any login-related "keep-alive" or "heartbeat" logic that grants broader access than intended.
- Configuration and policy checks
- Enforce security guidelines that require authentication middleware on all real-time endpoints.
- Apply policies that mandate origin checks for local services exposed via the browser.
- Runtime monitoring
- Log WebSocket connection attempts, including remote address, query parameters, and origin.
- Alert on anomalous patterns such as frequent connections from web-browser user agents with unusual query parameters.
- Automated application security testing tools can be configured to probe WebSocket endpoints with modified parameters and missing authentication to surface similar weaknesses.

