Summary
SurrealDB custom API routes before version 3.2.0 do not properly validate the namespace and database scope, allowing authenticated users to call endpoints across tenants.
An attacker with credentials for any namespace or database can craft URLs that target other tenants' scopes, potentially reading sensitive data or triggering unintended operations in those contexts.
Affected context
This vulnerability appears in SurrealDB deployments that expose custom API routes and rely on URL path parameters to determine namespace and database scope.
It is relevant where multiple tenants, applications, or environments share the same SurrealDB instance, and access control is expected to isolate namespaces and databases from one another.
The issue is most pronounced when applications assume that authenticated credentials are automatically confined to their own namespace and database, without explicit server-side validation of the requested scope.
Exploit preconditions
- Attack surface: SurrealDB HTTP API endpoints, specifically custom routes that accept namespace and database in the URL path.
- Required access: Valid credentials for any namespace or database on the affected SurrealDB instance.
- Trigger point: Issuing HTTP requests to custom API routes with manipulated URL path segments pointing to a different namespace or database.
- Why exploitation is possible: The server-side logic authorizes requests based only on authentication, without sufficiently enforcing that the requested namespace/database matches the caller's permitted scope, leading to horizontal authorization bypass (CWE-639).
Why this happens
The underlying issue is an authorization design flaw where the system trusts client-supplied scope identifiers (namespace and database) in the request path without binding them to the authenticated principal's allowed context.
Instead of verifying that the namespace/database being accessed is permitted for the current credentials, the API routes accept any valid scope string and process the request.
This maps to CWE-639: Authorization Bypass Through User-Controlled Key, where identifiers used to select resources or tenants are not validated against the user's authorization profile, enabling cross-tenant or cross-account access.
Potential impact
- Authenticated users may read sensitive data from other tenants' namespaces or databases.
- Attackers could trigger write or update operations in foreign scopes, altering or corrupting data.
- Cross-tenant information disclosure can undermine data isolation guarantees and compliance commitments.
- Misuse of management or administrative custom routes could lead to broader configuration or operational impact.
General mitigation guidance
Effective mitigation focuses on enforcing strict authorization checks around scope identifiers and reducing reliance on client-controlled keys for access decisions.
Common defensive patterns include:
- Binding authentication tokens or sessions to a specific namespace/database and rejecting requests that attempt to operate outside that bound scope.
- Implementing server-side authorization middleware that validates namespace and database parameters against the caller's allowed set before executing any custom API route logic.
- Avoiding direct trust of URL path segments or request parameters as the sole determinant of tenant or database selection; instead, derive scope from trusted authentication context.
- Applying least-privilege principles so that credentials are limited to only the required scopes and cannot be reused for broader cross-tenant access.
How teams detect issues like this
Detection typically involves a mix of code-level and runtime analysis:
- Reviewing custom route handlers and middleware for missing or insufficient authorization checks on namespace and database parameters.
- Using static analysis or policy-based code scanning to flag patterns where user-controlled identifiers (e.g., path parameters) are used to select tenant or database without corresponding permission verification.
- Analyzing logs for unusual patterns where a single principal accesses multiple namespaces/databases, especially across tenant boundaries.
- Incorporating automated security review tools in CI/CD pipelines to enforce rules around multi-tenant isolation and scope validation for new or modified API routes.

