/

CVE-2026-134309

Severity:

HIGH RISK

(8.8)

Authorization Bypass (CWE-863) in SurrealDB FOR Loops

CVE-2026-134309

Deferred

Vulnerability type

Category:

Authorization Bypass

CWE:

CWE-863

Impact:

Unauthorized data access and modification

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SurrealDB has an authorization bypass in which authenticated users can bind protected variables as FOR loop variables and supply forged values. If table permissions rely on those variables, a VIEWER may be able to read, modify, or delete data beyond their authorization.

Affected context

The issue affects SurrealDB versions from 1.0.0 to before 4.0.0 when queries use nested FOR loops that bind protected variables such as $access, $auth, or $token. It becomes risky when table permission predicates rely on these variables and the query is run by an authenticated user with limited privileges, such as a VIEWER.

Exploit preconditions

  • Attack surface: SurrealDB query execution
  • Required access: An authenticated account able to submit queries, including a VIEWER role
  • Trigger point: Evaluation of a query containing nested FOR loops that bind protected variables
  • Why exploitation is possible: Forged loop-variable values can shadow protected variables used by table permission predicates

Why this happens

The authorization logic does not reliably distinguish protected context variables from user-controlled FOR loop bindings. As a result, permission predicates may evaluate attacker-supplied values instead of trusted authorization state. This is an authorization enforcement flaw mapped to CWE-863: Incorrect Authorization.

Potential impact

  • A VIEWER may be able to read records outside their permitted scope.
  • An authenticated user could modify or delete data they should not control.
  • Applications relying on table permissions may experience data exposure or integrity loss.

General mitigation guidance

Defensive patterns focus on keeping authorization context trustworthy and ensuring permissions cannot be influenced by query-local bindings.

  • Treat protected authorization variables as reserved and prevent query constructs from shadowing them.
  • Evaluate permissions using trusted server-side identity and access context.
  • Use secure-by-default permission rules that deny access unless explicitly allowed.
  • Limit query capabilities and user privileges to the minimum required.
  • Avoid relying on client-controlled or query-controlled values as the sole basis for authorization.

How teams detect issues like this

  • Review query parsing and evaluation paths for FOR bindings that can shadow protected variables.
  • Use static analysis or code review checks to flag variable-name collisions involving authorization context.
  • Test permission predicates with nested query constructs and low-privilege roles.
  • Enforce policies that reserve security-sensitive variable names and require authorization checks to use trusted context.

Automated code review tools may help identify risky binding and permission-evaluation patterns.

Sources

SourceLink
github.comgithub.com/surrealdb/surrealdb/security/advisories/GHSA-ffvm-mqh3-7986
vulncheck.comvulncheck.com/advisories/surrealdb-1.0.0-before-4.0.0-authorization-bypass-via-for-loop-variable-shadowing

Frequently asked

questions

An authenticated user who can submit queries may be able to exploit it, including a user with a VIEWER role, when affected permission predicates rely on the shadowable variables.

The described scenario does not require an administrator role, but the attacker needs query access to the database.

Ensure protected authorization context cannot be shadowed, and evaluate permissions using trusted server-side identity and access data.

Reserve security-sensitive variables, test authorization rules against nested query constructs, and apply least privilege with default-deny policies.

Find out what's already
exploitable in your codebase.