Summary
SiYuan versions 3.6.3 and below expose an API endpoint that allows authenticated publish-service readers to delete attribute view files without proper authorization checks.
By supplying crafted attribute view IDs, a low-privileged user can permanently remove arbitrary attribute view definitions, disrupting database views and workspace rendering until the data is manually restored.
Affected context
This vulnerability affects SiYuan deployments that:
- Expose the
/api/av/removeUnusedAttributeViewendpoint through the publish service or similar interfaces - Assign RoleReader or equivalent low-privileged tokens that are accepted by this endpoint
- Store attribute view definitions as files within the workspace that are directly mapped from a caller-supplied
id
The issue manifests when users with read-oriented roles can reach management endpoints that perform destructive operations on attribute view files.
Exploit preconditions
- Attack surface: HTTP(S) API endpoint
/api/av/removeUnusedAttributeView - Required access: Valid publish-service authentication token with RoleReader (or equivalent) privileges; no write permission is required
- Trigger point: Sending a request with a chosen
idcorresponding to an attribute view file - Why exploitation is possible:
- The endpoint relies on generic authentication and does not enforce fine-grained authorization or role-based access control for destructive operations
- The handler directly forwards the caller-controlled
idinto a model function that unconditionally deletes the corresponding file - The implementation does not verify that the target attribute view is actually unused or belongs to the requesting principal's scope
Why this happens
The core issue is an improper authorization pattern where authentication is treated as sufficient for a destructive operation, without validating the caller's privileges or the resource's state.
Specifically, the /api/av/removeUnusedAttributeView handler:
- Accepts RoleReader tokens intended for read-only access
- Treats a user-supplied
idas fully trusted - Invokes a model-layer delete operation that unconditionally removes the associated attribute view file
This aligns with CWE-285: Improper Authorization, where the system fails to enforce permission checks that distinguish between read and write capabilities and does not confirm that the target attribute view is unused, leading to unauthorized data modification and deletion.
Potential impact
- Permanent deletion of arbitrary attribute view definitions by low-privileged users
- Breakage of database-style views, filters, and derived data in affected workspaces
- Inconsistent or failed workspace rendering for documents that depend on deleted attribute views
- Loss of productivity and data integrity until backups or manual restoration are performed
- Potential abuse as a targeted sabotage vector against specific users or shared workspaces
General mitigation guidance
Effective mitigation focuses on enforcing least-privilege access and resource-aware authorization for destructive operations:
- Require distinct, higher-privilege roles or capabilities for endpoints that modify or delete workspace resources, separate from read-oriented roles such as RoleReader.
- Implement explicit authorization checks at the handler level that verify:
- The caller's role or permission set includes deletion rights for attribute views.
- The targeted attribute view belongs to the caller's tenant, workspace, or ownership scope.
- The attribute view is actually unused according to server-side criteria before allowing deletion.
- Avoid treating user-controlled identifiers as implicitly trusted resource handles; introduce internal resource lookup and validation layers.
- Apply defense-in-depth by centralizing authorization decisions in a reusable access-control module or service, rather than embedding ad hoc checks in each endpoint.
- Where feasible, prefer soft-deletion or versioned deletion for critical configuration artifacts so that accidental or malicious deletions can be reversed.
How teams detect issues like this
Detection strategies can combine code-centric and operational approaches:
- Static analysis and code review:
- Flag HTTP handlers that:
- Accept low-privilege or generic tokens
- Call delete, update, or destructive file operations without role/permission checks
- Look for controller functions that pass user-supplied identifiers directly into model or filesystem delete operations.
- Enforce patterns where all state-changing endpoints call a common authorization utility with explicit action and resource parameters (e.g.,
authorize(user, "delete", "attribute_view", id)). - Policy and CI/CD checks:
- Introduce linting or policy-as-code rules (e.g., using Semgrep, Open Policy Agent, or similar tools) to detect endpoints lacking authorization middleware or annotations.
- Require security review for new or modified endpoints that perform file or configuration deletions.
- Runtime monitoring:
- Log all calls to destructive endpoints with caller identity, role, and target resource
id. - Set alerts for unusual patterns, such as many deletions initiated by read-only roles or from atypical IPs or tokens.

