Summary
Cloudreve incorrectly issues OAuth access tokens without a client_id claim, causing the verifier to skip loading scopes into the request context.
As a result, low-privileged OAuth tokens may be treated as fully authenticated sessions and can invoke APIs that should require higher scopes, including file, sharing, workflow, and potentially administrative actions.
Affected context
This vulnerability appears in Cloudreve deployments that:
- Use OAuth-based authentication and authorization, and
- Rely on token scopes to gate access to sensitive APIs
The issue is triggered when access tokens are issued without a client_id claim, leading the JWT verifier to treat the request as a non-scoped authenticated session.
In such environments, APIs that should be restricted to high-privilege scopes (e.g., file management, sharing, workflow, user settings, WebDAV accounts, admin operations) become accessible to holders of low-scope OAuth tokens under certain conditions.
Exploit preconditions
- Attack surface: Cloudreve HTTP(S) API endpoints and web UI protected by OAuth tokens.
- Required access: A valid OAuth access token with any scope, obtained through legitimate authorization or compromised credentials.
- Trigger point: Submitting requests to scope-protected endpoints while presenting an access token missing the client_id claim.
- Why exploitation is possible: The authorization layer fails to associate scopes with the token when client_id is absent, causing RequiredScopes to fall back to treating the session as fully authenticated without enforcing scope checks, effectively bypassing fine-grained authorization.
Why this happens
The root cause lies in incorrect authorization logic around OAuth token handling and scope evaluation.
Token issuance omits the client_id claim that the verifier expects to determine the context and load the correct scopes.
When this claim is missing, the JWT validation path does not populate scope information and the RequiredScopes mechanism degrades to a broader, session-like authentication model.
This maps to CWE-863: Incorrect Authorization, where access control decisions are made based on incomplete or incorrect contextual attributes, allowing operations beyond the intended permission set.
Potential impact
- Low-scope OAuth tokens can gain access to APIs intended for higher scopes.
- Unauthorized file management operations (upload, download, deletion, or modification) may become possible.
- Abuse of share and workflow APIs, potentially exposing or altering shared resources.
- Unauthorized changes to user settings and WebDAV account configurations.
- Potential escalation to administrative actions if those endpoints are protected only by scopes.
- Lateral movement or data exposure within a multi-user Cloudreve deployment.
General mitigation guidance
Mitigation generally focuses on hardening authorization flows and accurately binding scopes to every access token:
- Ensure that token issuance includes all claims required by the authorization layer, especially those used to derive scopes or client context.
- Design authorization checks so that they fail closed: if scopes cannot be resolved or validated, access to privileged endpoints should be denied by default.
- Implement explicit, per-endpoint authorization rules that validate scope and role information rather than relying solely on session-like authentication.
- Separate high-privilege administrative or configuration operations behind additional authorization checks, such as distinct roles or dedicated admin contexts.
- Minimize the power of generic authenticated sessions; prefer least-privilege scopes and reduce overbroad default access.
How teams detect issues like this
Effective detection typically involves both code-level and operational techniques:
- Code review: Look for authorization paths where missing or malformed claims cause the system to bypass scope evaluation or fall back to broad "authenticated user" logic.
- Static analysis: Define rules to flag authorization checks that do not verify scopes or roles on sensitive endpoints, or that conditionally skip checks based on presence of specific claims.
- Log analysis: Monitor access logs for low-privilege clients or users invoking high-risk endpoints, especially where scope evaluation logs are missing or indicate default handling.
- Security testing: Incorporate automated tests that present tokens with partial or missing claims to ensure endpoints correctly deny access when authorization context is incomplete.

