Miggo Logo

GHSA-ccj3-5p93-8p42:
SurrealDB server-takeover via SurrealQL injection on backup import

N/A

CVSS Score

Basic Information

CVE ID
-
EPSS Score
-
Published
4/11/2025
Updated
4/11/2025
KEV Status
No
Technology
TechnologyRust

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
surrealdbrust>= 2.2.0, < 2.2.22.2.2
surrealdbrust>= 2.1.0, < 2.1.52.1.5
surrealdbrust< 2.0.52.0.5

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability occurs because table and field names, and potentially other string-like identifiers, were not properly sanitized during the export operation. This allowed SurrealQL to be injected into the export file, which would then be executed upon import. The analysis of the patch commit b86f6ac5cdb4831c0ee1ed9004293c860c4a7337 reveals two main areas of concern:

  1. The primary Transaction::export function in crates/core/src/kvs/export.rs was modified to specifically handle escaping of names within comments (using InlineCommentDisplay), indicating this was a previous weakness.
  2. Numerous Display::fmt implementations for SQL types (like Ident, Table, Id, Strand, Object keys) in crates/core/src/sql/ were changed to use new, more robust escaping mechanisms (e.g., EscapeIdent, QuoteStr, EscapeKey) instead of older, flawed functions (e.g., escape_ident, quote_str, escape_key). These fmt functions are responsible for converting the raw names/values into their string representations for the export. If these representations were not correctly escaped, they formed the basis of the injection. The identified functions are those that either directly constructed the vulnerable export output or were responsible for the faulty string serialization of elements used in that output.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

T** Surr**l** *omm*n*-lin* tool *llows *xportin* **t***s*s t*rou** t** `*xport` *omm*n*. It w*s *is*ov*r** t**t t**l* or *i*l* n*m*s *r* not prop*rly s*nitiz** in *xports, l***in* to * Surr**lQL inj**tion w**n t** ***kup is r*import**. *or t** inj**

Reasoning

T** vuln*r**ility o**urs ****us* t**l* *n* *i*l* n*m*s, *n* pot*nti*lly ot**r strin*-lik* i**nti*i*rs, w*r* not prop*rly s*nitiz** *urin* t** `*xport` op*r*tion. T*is *llow** Surr**lQL to ** inj**t** into t** *xport *il*, w*i** woul* t**n ** *x**ut**