# GHSA-4vgr-h27g-cf9p: SurrealDB: HTTP RPC Session Race Condition Allows Privilege Escalation

> Unauthenticated attackers can escalate privileges to root by racing concurrent HTTP requests against active sessions in SurrealDB.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 1 Jul 2026

## What is GHSA-4vgr-h27g-cf9p?

GHSA-4vgr-h27g-cf9p is a vulnerability in surrealdb, published on 1 Jul 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The HTTP `/rpc` endpoint has a time-of-check/time-of-use (TOCTOU) race condition on internal session state. When authenticated and unauthenticated requests are processed concurrently, the unauthenticated request can inherit the authenticated user's session and privileges. The `/rpc` endpoint is the primary interface used by all official SurrealDB SDKs.

The HTTP `/rpc` handler does not bind each incoming request to an isolated session context. Instead, concurrent requests share mutable authentication state. When an authenticated request sets the session context and an unauthenticated request races in before it is cleared, the unauthenticated request executes with the authenticated user's privileges.

The impact depends on the privilege level of the session that is hijacked. If a root or namespace-level user session is inherited, the attacker can read and modify any data, delete records, and create persistent namespace-level users. If a scoped record user session is inherited, the attacker is limited to that user's permissions.

The attack requires no credentials, tokens, or session knowledge — only the ability to send concurrent HTTP requests to the `/rpc` endpoint while legitimate authenticated traffic is active.

## Impact

An unauthenticated attacker who can reach the `/rpc` endpoint can escalate privileges by racing against any active authenticated session. The severity of the impact depends on the permissions of the user whose session was hijacked. This could include escalation to root user of SurrealDB instance

## Patches

Versions prior to SurrealDB `v3.1.0` are vulnerable.

A patch has been introduced that replaces the shared default session with per-request session isolation. Every `POST /rpc` request now allocates a fresh, server-side UUID and runs entirely within that session's scope for the duration of the request. The session-map signatures across the RPC protocol have been changed from `Option<Uuid>` to `Uuid` so the "default session" can no longer be represented at the type level, preventing future regressions of the same shape.

## Workarounds

There is no configuration-level mitigation that fully addresses this vulnerability. Network-level controls restricting access to the `/rpc` endpoint to trusted clients can reduce exposure.

## Which versions are affected by GHSA-4vgr-h27g-cf9p?

2 open source packages ship an affected version, including surrealdb.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `surrealdb` | crates.io | All versions | 3.1.0 |
| `surrealdb` | crates.io | All versions | 3.1.0 |

## How do I fix GHSA-4vgr-h27g-cf9p?

Upgrade surrealdb to 3.1.0 or later.

## Is GHSA-4vgr-h27g-cf9p being exploited?

There is no known exploitation of GHSA-4vgr-h27g-cf9p in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-4vgr-h27g-cf9p and fix it if it is affected.

What it is: GHSA-4vgr-h27g-cf9p is a vulnerability in surrealdb, published on 1 Jul 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-4vgr-h27g-cf9p in the wild and no public exploit code.

Affected packages and fixed versions:
- surrealdb (crates.io): affected all versions; fixed in 3.1.0
- surrealdb (crates.io): affected all versions; fixed in 3.1.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-4vgr-h27g-cf9p/ (Markdown: https://insights.sbomify.com/GHSA-4vgr-h27g-cf9p/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-4vgr-h27g-cf9p

---
From sbomify Insights: https://insights.sbomify.com/GHSA-4vgr-h27g-cf9p/
Summaries are generated and may contain mistakes; the official description above is the record.
