Junglewise Threat Intelligence

SurrealDB custom API route namespace/database scope bypass

Severity: high · CVSS 8.1 · Published 2026-07-20

Technologies: surrealdb (crates.io). Vendors: SurrealDB, crates.io.

Executive brief

SurrealDB is a multi-tenant database platform that allows authenticated users to define custom API endpoints. Before version 3.2.0, the API routing mechanism failed to verify that users could only access endpoints within their authorized namespace and database scope. An attacker with valid credentials for any namespace/database could access custom API endpoints in other tenants by manipulating the URL path, potentially reading sensitive data or triggering unintended operations across tenant boundaries.

Technical details

The vulnerability is an authorization bypass affecting SurrealDB's custom API (DEFINE API) feature. The root cause is that the HTTP route handler /api/{namespace}/{database}/{endpoint} extracts the namespace and database from the URL path and applies them to the caller's session before validating that the authenticated user holds permissions for that scope. The surreal-ns and surreal-db headers and USE statement also permit session scope modification without checks. An authenticated attacker can invoke this route with a victim's namespace/database in the URL, and since custom API handlers execute with permissions disabled (definer's rights), only the endpoint's PERMISSIONS clause provides access control—which may be PERMISSIONS FULL (open to all). The api::invoke() function is similarly affected. Exploitation requires valid authentication credentials for at least one namespace/database on the instance but allows cross-tenant access within that instance. Fixed in version 3.2.0 by validating the target namespace/database against the caller's authenticated scope before endpoint resolution.

Affected products

  • SurrealDB SurrealDB < 3.2.0

Timeline

  • 2026-07-02: disclosed
  • 2026-07-20: patched: Fixed in version 3.2.0
  • 2026-07-20: advisory

References

Related threats