Summary
SurrealDB's embedded JavaScript bridge can bypass function capability checks when it dispatches built-in functions. An authenticated user who cannot call a built-in function through SurrealQL may still be able to invoke it through surrealdb.functions when embedded JavaScript is available.
Affected context
The issue affects SurrealDB deployments in the affected version range that expose embedded JavaScript scripting. The surrealdb.functions bridge dispatches calls to internal synchronous and asynchronous function handlers without applying the capability checks used for direct SurrealQL calls. As a result, restrictions on built-in functions may not hold across this alternate call path.
Exploit preconditions
- Attack surface: SurrealDB embedded JavaScript scripting and its
surrealdb.functionsbridge - Required access: An authenticated account able to submit queries that invoke embedded JavaScript
- Trigger point: A call to a built-in function through the JavaScript bridge
- Why exploitation is possible: The bridge reaches internal function dispatchers without enforcing the relevant function capability checks
Why this happens
The underlying issue is a missing authorization check on an alternate function-dispatch path. Although SurrealQL capability controls can deny access to built-in functions, the JavaScript bridge invokes internal synchronous and asynchronous dispatchers without applying equivalent checks. This is an authorization enforcement failure mapped to CWE-862: Missing Authorization.
Potential impact
- Authenticated users may invoke built-in functions that their capabilities are meant to restrict.
- Depending on the functions available and the deployment configuration, this may expose protected operations or data.
- The bypass could undermine capability-based access controls and increase the impact of a compromised or over-permissioned account.
General mitigation guidance
Defensive patterns include enforcing authorization consistently at the shared function-dispatch boundary, regardless of which interface invokes a function. Apply deny-by-default capability checks to every call path, limit accounts to the minimum required permissions, and disable embedded JavaScript where it is not needed. Treat alternate language bridges and plugin interfaces as security boundaries that require the same policy enforcement as direct queries.
How teams detect issues like this
Review function-dispatch paths for calls that bypass centralized authorization or capability checks. Static analysis and code review can look for bridge APIs that reach internal handlers directly, and tests can verify that denied functions remain unavailable through every supported interface. Policy checks may also flag deployments that enable embedded scripting for users or workloads that do not require it.

