GHSA-64f8-pjgr-9wmr: Surrealdb Untrusted Query Object Evaluation Vulnerability

HIGH
CVSS 8.8
CWE-75
Published
Advisory Summary

GHSA-64f8-pjgr-9wmr is a HIGH (CVSS 8.8) untrusted query object evaluation vulnerability (CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)) affecting Surrealdb libraries in the crates.io ecosystem. The issue involves untrusted query object evaluation in rpc api. Remediation is available by upgrading affected packages to version 1.5.5, 1.5.2, 2.0.0-beta.3.

GHSA-64f8-pjgr-9wmr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-64f8-pjgr-9wmr
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)
Affected Product Surrealdb
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix GHSA-64f8-pjgr-9wmr

To remediate this vulnerability, upgrade all affected Surrealdb dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

surrealdb fixed: 1.5.5
Upgrade surrealdb to 1.5.5
surrealdb-core fixed: 1.5.2
Upgrade surrealdb-core to 1.5.2
surrealdb fixed: 2.0.0-beta.3
Upgrade surrealdb to 2.0.0-beta.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for surrealdb

How to Check if You Are Affected

To determine whether your application is affected by GHSA-64f8-pjgr-9wmr, inspect your project dependencies for Surrealdb:

inspect dependencies for surrealdb

Analyze the terminal output to locate any version of Surrealdb in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection), where the product does not adequately filter user-controlled input for special elements with control implications. In Surrealdb, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

During the sign in and sign up operations through the SurrealDB RPC API, an arbitrary object would be accepted in order to support a wide array of types and structures that could contain user credentials. This arbitrary object could potentially contain any SurrealDB value, including an object representing a subquery. For this to materialize, this object would need to be encoded using the bincode serialization format instead of the default JSON serialization format or the additionally supported CBOR serialization format. If a binary object containing a subquery were to be provided in this way, that subquery would be computed while executing the `SIGNIN` and `SIGNUP` queries defined by the database owner while defining a record access method. Since those queries are executed under a system user session with the editor role, an unauthenticated attacker may be able to leverage this behavior to select, create, update and delete non-IAM resources with permissions of a system user with the editor role. ### Impact If a record access method was defined with a `SIGNIN` or a `SIGNUP` query and the SurrealDB RPC API was exposed to untrusted users, an attacker could be able to craft a binary object containing a subquery to provide in place of valid credentials when calling the `signin` and `signup` operations via the RPC API with the bincode serialization format. The attacker could use that subquery to select, create, update and delete resources in SurrealDB, but they would not be able to _directly_ view the results of the query. This method cannot be used to create, update or delete IAM resources, as access to those kind of resources requires the owner role. ### Patches Objects provided as variables to the sign in and sign up methods are now recursively validated to ensure that they do not contain any non-computed values, which include subqueries and other data types that could potentially result in query execution. - Version 1.5.5 and later are not affected by this issue. - Version 2.0.0-beta.3 and later are not affected by this issue. ### Workarounds Users unable to update may want to disallow access to the SurrealDB RPC API using the affected binary serialization formats by conservatively allowing only requests to the `/rpc` endpoint of the SurrealDB HTTP server with the `application/json` content type. If the RPC API is not used at all or only used by trusted clients, disallowing or restricting access to the `/rpc` endpoint of the SurrealDB HTTP server will also prevent exploitation. Alternatively, if filtering HTTP requests is not possible, record access methods that define `SIGNIN` and `SIGNUP` clauses may be temporarily removed to completely prevent potential attacks leveraging this issue. ### References - [SurrealDB Documentation - Authentication (Record Users)](https://surrealdb.com/docs/surrealdb/security/authentication#record-users) - [SurrealDB Documentation - RPC Protocol (Signup)](https://surrealdb.com/docs/surrealdb/integration/rpc#signup) - [SurrealDB Documentation - RPC Protocol (Signin)](https://surrealdb.com/docs/surrealdb/integration/rpc#signin)

GHSA-64f8-pjgr-9wmr Affected Surrealdb Versions

3 component(s)
Fixed Versions:
1.5.51.5.22.0.0-beta.3
Product / Package Ecosystem Affected Versions Fixed Version
surrealdb
crates.io
< 1.5.5
1.5.5
surrealdb-core
crates.io
< 1.5.2
1.5.2
surrealdb
crates.io
≥ 2.0.0-beta.1
< 2.0.0-beta.3
2.0.0-beta.3

References

Frequently Asked Questions

What is GHSA-64f8-pjgr-9wmr?
GHSA-64f8-pjgr-9wmr is a security vulnerability in Surrealdb involving Untrusted Query Object Evaluation in RPC API under CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection).
Which Surrealdb versions are affected?
Affected versions include releases prior to 1.5.5, 1.5.2, 2.0.0-beta.3 across affected packages: surrealdb, surrealdb-core.
What version fixes GHSA-64f8-pjgr-9wmr?
Upgrading to 1.5.5, 1.5.2, 2.0.0-beta.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is surrealdb affected?
Yes, surrealdb is affected in releases prior to 1.5.5, 2.0.0-beta.3. Upgrade your dependency to 1.5.5, 2.0.0-beta.3 or later.
Is surrealdb-core affected?
Yes, surrealdb-core is affected in releases prior to 1.5.2. Upgrade your dependency to 1.5.2 or later.
What is the CVSS score of GHSA-64f8-pjgr-9wmr?
GHSA-64f8-pjgr-9wmr has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with GHSA-64f8-pjgr-9wmr?
GHSA-64f8-pjgr-9wmr is classified under CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection) (The product does not adequately filter user-controlled input for special elements with control implications.).
How can I check crates.io dependencies for GHSA-64f8-pjgr-9wmr?
Run the dependency tree command: 'inspect dependencies for surrealdb'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-64f8-pjgr-9wmr",
  "modified" : "2024-09-11T19:20:08Z",
  "published" : "2024-09-11T19:20:07Z",
  "aliases" : [ ],
  "summary" : "Untrusted Query Object Evaluation in RPC API",
  "details" : "During the sign in and sign up operations through the SurrealDB RPC API, an arbitrary object would be accepted in order to support a wide array of types and structures that could contain user credentials. This arbitrary object could potentially contain any SurrealDB value, including an object representing a subquery. For this to materialize, this object would need to be encoded using the bincode serialization format instead of the default JSON serialization format or the additionally supported CBOR serialization format.\n\nIf a binary object containing a subquery were to be provided in this way, that subquery would be computed while executing the `SIGNIN` and `SIGNUP` queries defined by the database owner while defining a record access method. Since those queries are executed under a system user session with the editor role, an unauthenticated attacker may be able to leverage this behavior to select, create, update and delete non-IAM resources with permissions of a system user with the editor role.\n\n### Impact\n\nIf a record access method was defined with a `SIGNIN` or a `SIGNUP` query and the SurrealDB RPC API was exposed to untrusted users, an attacker could be able to craft a binary object containing a subquery to provide in place of valid credentials when calling the `signin` and `signup` operations via the RPC API with the bincode serialization format. The attacker could use that subquery to select, create, update and delete resources in SurrealDB, but they would not be able to _directly_ view the results of the query. This method cannot be used to create, update or delete IAM resources, as access to those kind of resources requires the owner role.\n\n### Patches\n\nObjects provided as variables to the sign in and sign up methods are now recursively validated to ensure that they do not contain any non-computed values, which include subqueries and other data types that could potentially result in query execution.\n\n- Version 1.5.5 and later are not affected by this issue.\n- Version 2.0.0-beta.3 and later are not affected by this issue.\n\n### Workarounds\n\nUsers unable to update may want to disallow access to the SurrealDB RPC API using the affected binary serialization formats by conservatively allowing only requests to the `/rpc` endpoint of the SurrealDB HTTP server with the `application/json` content type. If the RPC API is not used at all or only used by trusted clients, disallowing or restricting access to the `/rpc` endpoint of the SurrealDB HTTP server will also prevent exploitation. Alternatively, if filtering HTTP requests is not possible, record access methods that define `SIGNIN` and `SIGNUP` clauses may be temporarily removed to completely prevent potential attacks leveraging this issue.\n\n### References\n\n- [SurrealDB Documentation - Authentication (Record Users)](https://surrealdb.com/docs/surrealdb/security/authentication#record-users)\n- [SurrealDB Documentation - RPC Protocol (Signup)](https://surrealdb.com/docs/surrealdb/integration/rpc#signup)\n- [SurrealDB Documentation - RPC Protocol (Signin)](https://surrealdb.com/docs/surrealdb/integration/rpc#signin)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "surrealdb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "surrealdb-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "surrealdb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0-beta.1"
      }, {
        "fixed" : "2.0.0-beta.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/surrealdb/surrealdb/security/advisories/GHSA-64f8-pjgr-9wmr"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/surrealdb/surrealdb/commit/b7583a653a2c495a60630dffd663f506426db330"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/surrealdb/surrealdb/commit/eab7ef5354168d4039f7f7b77042c99a52f770a6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/surrealdb/surrealdb"
  }, {
    "type" : "WEB",
    "url" : "https://surrealdb.com/docs/surrealdb/integration/rpc#signin"
  }, {
    "type" : "WEB",
    "url" : "https://surrealdb.com/docs/surrealdb/integration/rpc#signup"
  }, {
    "type" : "WEB",
    "url" : "https://surrealdb.com/docs/surrealdb/security/authentication#record-users"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-75" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-11T19:20:07Z",
    "nvd_published_at" : null
  }
}