/

CVE-2026-40259

Severity:

HIGH RISK

(8.1)

Improper Authorization in SiYuan Attribute View Deletion API

CVE-2026-40259

Analyzed

Vulnerability type

Category:

Improper Authorization

CWE:

CWE-285

Impact:

Unauthorized Data Destruction and Integrity Loss

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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/removeUnusedAttributeView endpoint 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 id corresponding 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 id into 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 id as 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.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.6.4
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-7m5h-w69j-qggg

Frequently asked

questions

Yes, it can be exploited remotely against any SiYuan instance where the vulnerable endpoint is reachable over the network and an attacker can obtain or control a valid publish-service token with RoleReader-level access.

The attacker needs authenticated access as a publish-service reader or similar low-privileged account. Full write or administrative permissions are not required; the flaw is that a read-oriented role is allowed to invoke a destructive deletion endpoint.

The safest approach is to enforce strict, action-specific authorization checks for all state-changing endpoints. Only roles explicitly granted delete privileges for attribute views should be allowed to call the deletion API, and the server must independently verify that the target attribute view is unused and within the caller's scope before performing the operation.

Adopt a centralized, consistent access-control model where every API endpoint declares its required permissions, and ensure that destructive operations cannot be reached using generic or read-only roles. Combine this with regular security-focused code reviews, automated detection for endpoints missing authorization checks, and a design culture that treats authentication and authorization as distinct concerns.

Find out what's already
exploitable in your codebase.