surrealdb
Affected
- introduced
3.0.0, fixed3.1.5(semver)
Fixed versions
3.1.5
Fix
- Fixed version
3.1.5cargo update -p surrealdb --precise 3.1.5
Advisory
Also known as: CVE-2026-63309
SurrealDB: Indexed ORDER BY leaks the value ordering of a SELECT-restricted field
A field can be hidden from a user with a field-level SELECT permission (DEFINE FIELD code ON secret PERMISSIONS FOR select WHERE owner = $auth.id). When that field is indexed, a record user who cannot read it could still recover the relative ordering of its values across every record by issuing ORDER BY <field>: the field came back null as intended, but the rows were returned in the hidden values' true sorted order.
To satisfy the sort, the planner selects the field's index and walks it in value order; the field-level permission is applied later, when the row is projected, so the value is nulled but the row order already encodes it. The guard that withholds restricted fields from the WHERE path was never applied to ORDER BY.
Impact
What an attacker can do:
null, but the rows come back in the hidden values' order.What it can't do:
WHERE are still enforced, so only records the caller may already read are ordered.Patches
The query planner now applies the field-permission guard to the ORDER BY clause as well as the WHERE clause. When an ordered field is hidden from the caller by a field-level SELECT permission, the index sort pushdown is withheld and the rows are sorted after redaction instead, so the row order no longer reflects the hidden values. The dynamic-scan fallback is closed the same way, and a regression test was added.
The fix is included in SurrealDB 3.1.5.
Workarounds
Users unable to upgrade are advised to consider the following:
SURREAL_PLANNER_STRATEGY=compute-only; the sort then runs after redaction, so no ordering leaks.References
fix(planner): prevent ORDER BY value-ordering oracle on restricted SELECT fieldsfix(planner): close ORDER BY value-ordering oracle on the DynamicScan fallbackAcknowledgements
Thanks to George Chen (@geo-chen) for finding and reporting this issue.
Medium Basis: The source's own band: MODERATE
3.0.0, fixed 3.1.5 (semver)3.1.5
3.1.5cargo update -p surrealdb --precise 3.1.5Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0