SiYuan Publish-Mode Reader Configuration and Index Mutation Vulnerability
SiYuan publish-mode Reader can mutate Conf and SQL index via 8 ungated APIs, leading to configuration changes, denial of service, data corruption, and information disclosure by manipulating cloud sync intervals, graph configurations, SQL block content, and recent-documents lists.
SiYuan is vulnerable to unauthorized modification of server-side state due to missing authorization checks on eight API endpoints: /api/graph/getGraph, /api/graph/getLocalGraph, /api/sync/setSyncInterval, /api/storage/updateRecentDocViewTime, /api/storage/updateRecentDocCloseTime, /api/storage/updateRecentDocOpenTime, /api/storage/batchUpdateRecentDocCloseTime, and /api/search/updateEmbedBlock. These endpoints lack model.CheckAdminRole and model.CheckReadonly checks, allowing any authenticated user, including publish-service RoleReader and RoleEditor with Editor.ReadOnly = true, to write to the server. This can lead to atomic rewrites of the <workspace>/conf/conf.json file and modifications to the SQL index. This vulnerability affects all SiYuan versions up to and including v3.6.5. This is similar to previously patched vulnerabilities GHSA-6r88-8v7q-q4p2 and GHSA-4j3x-hhg2-fm2x, indicating a recurring pattern of missing authorization checks.
Attack Chain
- Attacker authenticates to the SiYuan application, obtaining a JWT that passes
CheckAuth. This can be as a publish-serviceRoleReader(anonymous publish visitor) or aRoleEditoragainst a workspace whereEditor.ReadOnly = true. - Attacker sends a POST request to
/api/sync/setSyncIntervalwith a crafted JSON payload containing a malicious interval value (e.g., 30 or 43200). - The server receives the request and updates the
Conf.Sync.Intervalvalue based on the attacker-provided interval, persisting the change toconf.jsonviaConf.Save(). - Attacker sends a POST request to
/api/graph/getGraphwith a crafted JSON payload containing a malicious graph configuration. - The server receives the request and overwrites
model.Conf.Graph.Globalfrom the attacker-supplied JSON and persists the entire workspaceconf.json. - Attacker sends a POST request to
/api/search/updateEmbedBlockwith a crafted JSON payload, specifying an embed-block ID and malicious content. - The server receives the request and updates the
blockstable in the SQL database, rewriting thecontentcolumn for the specified embed-block ID. - Other users accessing the SiYuan application will now see the poisoned content when the embedded block is displayed or searched.
Impact
Successful exploitation allows unauthorized users to modify the SiYuan configuration and data, potentially leading to denial-of-service, data corruption, and information disclosure. Specifically, attackers can:
- Cause a denial-of-service by setting a minimal cloud sync interval (30 seconds), causing excessive battery drain and bandwidth consumption on connected clients.
- Effectively pause cloud sync by setting a maximal sync interval (43200 seconds), increasing the risk of data divergence.
- Corrupt graph rendering by providing extreme values for
maxBlocks,minRefs, ornodeSizein the/api/graph/getGraphor/api/graph/getLocalGraphendpoints. - Poison search results by injecting malicious content into embed blocks via the
/api/search/updateEmbedBlockendpoint. - Manipulate the admin’s recently-opened-documents list, potentially disclosing information about publish-private notebooks via the
updateRecentDoc*endpoints.
Recommendation
- Deploy the Sigma rule “Detect SiYuan Unauthorized Sync Interval Modification” to monitor for unauthorized modifications to the sync interval using the
/api/sync/setSyncIntervalendpoint. - Deploy the Sigma rule “Detect SiYuan Unauthorized Graph Configuration Modification” to monitor for unauthorized modifications to the graph configuration using the
/api/graph/getGraphendpoint. - Apply the patch described in the advisory by adding
model.CheckAdminRoleandmodel.CheckReadonlyto the affectedginServer.Handlecalls inkernel/api/router.goto restrict access to these API endpoints to authorized users. - Monitor web server logs for POST requests to the listed API endpoints (
/api/graph/getGraph,/api/graph/getLocalGraph,/api/sync/setSyncInterval,/api/storage/updateRecentDocViewTime,/api/storage/updateRecentDocCloseTime,/api/storage/updateRecentDocOpenTime,/api/storage/batchUpdateRecentDocCloseTime,/api/search/updateEmbedBlock) without corresponding administrative actions.
Detection coverage 2
Detect SiYuan Unauthorized Sync Interval Modification
mediumDetects unauthorized modification of the SiYuan sync interval via the /api/sync/setSyncInterval endpoint, potentially leading to denial of service or data divergence.
Detect SiYuan Unauthorized Graph Configuration Modification
mediumDetects unauthorized modification of the SiYuan graph configuration via the /api/graph/getGraph endpoint, potentially disrupting graph rendering.
Detection queries are available on the platform. Get full rules →