# SurrealDB custom API route namespace/database scope bypass

Source: https://junglewise.ai/threats/surrealdb-custom-api-route-namespace-database-scope-bypass-dd7e840d  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-20. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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

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.

Technologies: [surrealdb (crates.io)](https://junglewise.ai/threats/technologies/surrealdb). Vendors: [crates.io](https://junglewise.ai/threats/vendors/crates-io).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** High severity, with a CVSS score of 8.1, published 20 July 2026.

**Which products and versions are affected?** surrealdb (crates.io) < 3.2.0.

**Is there a fix for This vulnerability?** A patch was published on 2026-07-20: Fixed in version 3.2.0 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network.

**Am I affected?** Check whether you run surrealdb (crates.io) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## 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

- [https://github.com/surrealdb/surrealdb/security/advisories/GHSA-848m-r628-vrxw](https://github.com/surrealdb/surrealdb/security/advisories/GHSA-848m-r628-vrxw)
- [https://www.vulncheck.com/advisories/surrealdb-before-authentication-bypass-via-custom-api](https://www.vulncheck.com/advisories/surrealdb-before-authentication-bypass-via-custom-api)

## Related threats

- [SurrealDB use-after-free in KV backends via affinitypool spawn_local](https://junglewise.ai/threats/cve-2026-121417-surrealdb-before-3-3-0-contains-a-use-after-free-vulnerability)
- [SurrealDB JSON parser denial of service via uncontrolled recursion](https://junglewise.ai/threats/surrealdb-json-parser-denial-of-service-via-uncontrolled-recursion-3037f8a0)
- [SurrealDB ES512 algorithm silently downgraded to ES384](https://junglewise.ai/threats/surrealdb-es512-algorithm-silently-downgraded-to-es384-f0af29b8)
- [SurrealDB permission bypass via WHERE clause evaluation](https://junglewise.ai/threats/surrealdb-permission-bypass-via-where-clause-evaluation-afa6f001)
- [SurrealDB authorization bypass in KILL statement](https://junglewise.ai/threats/surrealdb-authorization-bypass-in-kill-statement-fc230d0f)
