# SurrealDB Affected by Confused Deputy Privilege Escalation through Future Fields and Functions

Low-privileged SurrealDB users can plant function/future fields that execute with a privileged user's permissions, enabling full privilege escalation to root owner.

- Payout: Research
- Severity: high
- Program: SurrealDB
- Found by: cure53, geraname
- Disclosed: 2026-01-22
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-3v2x-9xcv-2v2v
- Library page: http://bugbountylibrary.com/r/ghsa%3AGHSA-3v2x-9xcv-2v2v
- Tags: area:cloud domain:infra impact:ato impact:data-leak impact:privesc kind:research platform:ghsa sev:high tech:rust technique:source-review vuln:access-control vuln:business-logic vuln:privilege-escalation

**Target:** SurrealDB database engine (function/future/computed fields, closures, defined APIs and events)
**Root cause:** Futures, function fields and stored closures are evaluated in the context of the invoking/querying user rather than the user who defined them, so attacker-planted logic runs with a privileged user's permissions.
**Steps:**
1. As a low-privileged user (e.g. database editor), create or modify a record field containing a function or `future` that performs privileged actions (e.g. creating a root owner).
2. Wait for a higher-privileged user (root owner or namespace admin) to query or write the record touching that field.
3. The future/function executes in the privileged user's context, performing the planted privileged action.
4. On write-touch: full privilege escalation (create root owner, take over server). On read-touch: limited DoS, or data exfiltration over network if network capability enabled and unrestricted.
**How found:** Reporters analyzed that futures are computed at query time and closures/function fields execute under the invoking user's privileges rather than the definer's, identifying the confused-deputy gap between definition and execution context.
**Exploitation:** Attacker with editor role plants malicious future/function field logic; when a privileged user reads or writes the record, the logic runs under their auth level, letting the attacker create a root owner and take over the server.
**Escalation:** Read-only touch yields limited DoS or network exfiltration when network capability is unrestricted; write touch yields full root-owner takeover.
**Insight:** In databases with deferred/computed fields and stored closures, check whose auth context evaluates the expression at query time versus who defined it; low-privilege schema/record writes that plant logic executed later by admins are a confused-deputy escalation path.

