/

CVE-2026-63763

Severity:

HIGH RISK

(8.8)

Confused Deputy (CWE-639) in SurrealDB Field Logic

CVE-2026-63763

Analyzed

Vulnerability type

Category:

Confused Deputy / Authorization Bypass

CWE:

CWE-639

Impact:

Privilege Escalation to Full Server Compromise

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 contains a confused deputy privilege escalation issue where fields with futures, functions, or closures execute under the permissions of the user who later queries them rather than the creator.

An unprivileged attacker can plant malicious logic in records that, when accessed by a higher-privileged user, runs with elevated rights and may lead to full privilege escalation and server takeover.

SurrealDB contains a confused deputy privilege escalation issue where fields with futures, functions, or closures execute under the permissions of the user who later queries them rather than the creator.

An unprivileged attacker can plant malicious logic in records that, when accessed by a higher-privileged user, runs with elevated rights and may lead to full privilege escalation and server takeover.

Affected context

This vulnerability appears in SurrealDB deployments where:

  • Application logic or users allow untrusted or semi-trusted roles (such as editor/database users) to define or modify record fields containing executable constructs (futures, functions, closures)
  • Higher-privileged users regularly read or write those records as part of normal operations
  • The execution context for these constructs is bound to the querying user's privileges rather than their original author

It is most relevant in multi-tenant or role-based environments where different users share access to the same datasets with differing privilege levels.

This vulnerability appears in SurrealDB deployments where:

  • Application logic or users allow untrusted or semi-trusted roles (such as editor/database users) to define or modify record fields containing executable constructs (futures, functions, closures)
  • Higher-privileged users regularly read or write those records as part of normal operations
  • The execution context for these constructs is bound to the querying user's privileges rather than their original author

It is most relevant in multi-tenant or role-based environments where different users share access to the same datasets with differing privilege levels.

Exploit preconditions

  • Attack surface: Database query interface (e.g., API, client SDKs, database console)
  • Required access: Ability for a lower-privileged account to create or modify records and embed futures, functions, or closures in fields
  • Trigger point: A higher-privileged user (such as an administrator or owner) later reads, evaluates, or writes the affected record, causing the embedded logic to execute
  • Why exploitation is possible: The system treats embedded logic as trusted and executes it under the privileges of the querying user, effectively allowing attacker-controlled logic to run with elevated rights (confused deputy pattern).
  • Attack surface: Database query interface (e.g., API, client SDKs, database console)
  • Required access: Ability for a lower-privileged account to create or modify records and embed futures, functions, or closures in fields
  • Trigger point: A higher-privileged user (such as an administrator or owner) later reads, evaluates, or writes the affected record, causing the embedded logic to execute
  • Why exploitation is possible: The system treats embedded logic as trusted and executes it under the privileges of the querying user, effectively allowing attacker-controlled logic to run with elevated rights (confused deputy pattern).

Why this happens

The underlying bug belongs to the confused deputy / authorization context mix-up class described by CWE-639: Authorization Bypass Through User-Controlled Key.

In this case, SurrealDB allows user-controllable fields to hold executable constructs (futures, functions, closures) that are evaluated in the context of another principal (the querying user).

Instead of binding the execution context to the originator of the code or treating embedded logic as unprivileged data, the database reuses the caller's authority, creating an implicit privilege escalation path.

This insecure pattern arises when authorization checks and execution context are not tightly coupled, allowing one user to indirectly cause another, more privileged, user to perform actions on their behalf.

The underlying bug belongs to the confused deputy / authorization context mix-up class described by CWE-639: Authorization Bypass Through User-Controlled Key.

In this case, SurrealDB allows user-controllable fields to hold executable constructs (futures, functions, closures) that are evaluated in the context of another principal (the querying user).

Instead of binding the execution context to the originator of the code or treating embedded logic as unprivileged data, the database reuses the caller's authority, creating an implicit privilege escalation path.

This insecure pattern arises when authorization checks and execution context are not tightly coupled, allowing one user to indirectly cause another, more privileged, user to perform actions on their behalf.

Potential impact

  • Attacker-controlled logic may execute with administrator or owner privileges
  • Creation or promotion of attacker accounts to root or owner roles
  • Modification or deletion of sensitive data across multiple tenants or databases
  • Unauthorized configuration changes leading to full server takeover
  • Bypass of application-level access controls that rely on database role separation
  • Attacker-controlled logic may execute with administrator or owner privileges
  • Creation or promotion of attacker accounts to root or owner roles
  • Modification or deletion of sensitive data across multiple tenants or databases
  • Unauthorized configuration changes leading to full server takeover
  • Bypass of application-level access controls that rely on database role separation

General mitigation guidance

Mitigation typically focuses on separating data from executable logic and binding execution context to the correct principal.

Common defensive patterns include:

  • Disallowing untrusted roles from defining or modifying fields that can contain executable constructs (futures, functions, closures), or treating such fields as data-only for those roles
  • Ensuring that any stored executable logic always runs in a least-privilege context that is independent of the querying user's permissions
  • Introducing explicit, centralized authorization checks before executing user-supplied logic, with clear rules about which roles may own and invoke such constructs
  • Using schema and policy constraints to distinguish between trusted system-owned fields and user-owned fields, preventing low-privileged users from influencing trusted execution paths
  • Applying the principle of least privilege to database roles and avoiding overly broad editor or maintenance roles in shared environments

Mitigation typically focuses on separating data from executable logic and binding execution context to the correct principal.

Common defensive patterns include:

  • Disallowing untrusted roles from defining or modifying fields that can contain executable constructs (futures, functions, closures), or treating such fields as data-only for those roles
  • Ensuring that any stored executable logic always runs in a least-privilege context that is independent of the querying user's permissions
  • Introducing explicit, centralized authorization checks before executing user-supplied logic, with clear rules about which roles may own and invoke such constructs
  • Using schema and policy constraints to distinguish between trusted system-owned fields and user-owned fields, preventing low-privileged users from influencing trusted execution paths
  • Applying the principle of least privilege to database roles and avoiding overly broad editor or maintenance roles in shared environments

How teams detect issues like this

Effective detection combines code, configuration, and behavioral analysis:

  • Static analysis and schema review: Identify schema definitions and migrations where fields are allowed to store executable constructs and are writable by low-privileged roles.
  • Query and audit log review: Look for patterns where editor or low-privileged accounts create or update fields with futures, functions, or closures, especially those later accessed by administrators.
  • Policy enforcement: Define and enforce security policies that flag or block changes allowing executable logic in user-controlled fields.
  • Automated review tools: Use database linting, configuration scanners, or security-focused CI checks to surface dangerous combinations of field capabilities and role permissions before deployment.

Effective detection combines code, configuration, and behavioral analysis:

  • Static analysis and schema review: Identify schema definitions and migrations where fields are allowed to store executable constructs and are writable by low-privileged roles.
  • Query and audit log review: Look for patterns where editor or low-privileged accounts create or update fields with futures, functions, or closures, especially those later accessed by administrators.
  • Policy enforcement: Define and enforce security policies that flag or block changes allowing executable logic in user-controlled fields.
  • Automated review tools: Use database linting, configuration scanners, or security-focused CI checks to surface dangerous combinations of field capabilities and role permissions before deployment.

Sources

SourceLink
github.comgithub.com/surrealdb/surrealdb/security/advisories/GHSA-3v2x-9xcv-2v2v
vulncheck.comvulncheck.com/advisories/surrealdb-before-privilege-escalation-via-future-fields

Frequently asked

questions

Exploitability depends on how roles and schemas are configured.

It becomes practically exploitable when low-privileged users can write executable logic into fields that high-privileged users routinely query.

An attacker typically needs a valid low-privileged SurrealDB account (such as an editor or database role) with permission to create or update records that can include futures, functions, or closures.

The safest pattern is to ensure untrusted roles cannot introduce executable logic, and to run any stored logic under a constrained, least-privilege context that is not automatically tied to the querying user.

Additionally, separate trusted system-owned logic from user-modifiable data fields.

Future prevention focuses on:

  • Designing schemas that clearly separate data and code
  • Applying strict role-based constraints on who can define executable constructs
  • Auditing new features for implicit context and authority escalation paths
  • Incorporating security reviews and automated checks into the development and deployment lifecycle for database schemas and access policies.

Exploitability depends on how roles and schemas are configured.

It becomes practically exploitable when low-privileged users can write executable logic into fields that high-privileged users routinely query.

An attacker typically needs a valid low-privileged SurrealDB account (such as an editor or database role) with permission to create or update records that can include futures, functions, or closures.

The safest pattern is to ensure untrusted roles cannot introduce executable logic, and to run any stored logic under a constrained, least-privilege context that is not automatically tied to the querying user.

Additionally, separate trusted system-owned logic from user-modifiable data fields.

Future prevention focuses on:

  • Designing schemas that clearly separate data and code
  • Applying strict role-based constraints on who can define executable constructs
  • Auditing new features for implicit context and authority escalation paths
  • Incorporating security reviews and automated checks into the development and deployment lifecycle for database schemas and access policies.
Find out what's already
exploitable in your codebase.