GHSA-64f8-pjgr-9wmr CVE-2024-58362 GHSA-xw2c-hrr9-4xwr
Untrusted Query Object Evaluation in RPC API
- Severity
- 0.0 / 10
- High · CVSS 4.0
- Exploit chance (EPSS)
- 0.64%
- Chance of exploitation in the next 30 days. Higher than 50.52% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-75 Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)
- Fix
- Available
- 2 packages have a fixed version
Description
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
Affected versions
crates.io
| Package | Vulnerable | Fixed in |
|---|---|---|
| surrealdb | < 1.5.5 |
1.5.5 |
| surrealdb | >= 2.0.0-beta.1, < 2.0.0-beta.3 |
2.0.0-beta.3 |
| surrealdb | all versions |
No fix yet |
| surrealdb-core | < 1.5.2 |
1.5.2 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
surrealdb crates.io → 1.5.5
- cargo
cargo update -p surrealdb --precise 1.5.5
surrealdb-core crates.io → 1.5.2
- cargo
cargo update -p surrealdb-core --precise 1.5.2
Severity breakdown
CVSS 4.0 0.0
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
- Attack vector
- Network
- Attack complexity
- Low
- Attack requirements
- None
- Privileges required
- Low
- User interaction
- None
- Confidentiality (vulnerable system)
- High
- Integrity (vulnerable system)
- High
- Availability (vulnerable system)
- High
- Confidentiality (subsequent systems)
- None
- Integrity (subsequent systems)
- None
- Availability (subsequent systems)
- None
CVSS 3.1 8.8
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- Low
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
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 to prevent it
- Requirements: Programming languages and supporting technologies might be chosen which are not subject to these issues.
- Implementation: Utilize an appropriate mix of allowlist and denylist parsing to filter special element syntax from all input.
References
Advisories
Packages
Other links
- github.com/surrealdb/surrealdb/security/advisories/GHSA-64f8-pjgr-9wmr
- github.com/surrealdb/surrealdb/commit/b7583a653a2c495a60630dffd663f506426db330
- github.com/surrealdb/surrealdb/commit/eab7ef5354168d4039f7f7b77042c99a52f770a6
- surrealdb.com/docs/surrealdb/integration/rpc
- surrealdb.com/docs/surrealdb/integration/rpc
- surrealdb.com/docs/surrealdb/security/authentication
- vulncheck.com/advisories/surrealdb-before-query-injection-via-rpc-api
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-8rw6-p7m8-63jp SurrealDB: Array element-level (field.*) SELECT permissions leak denied elements to record users | High | Also affects surrealdb |
| GHSA-848m-r628-vrxw SurrealDB: Custom API route lets authenticated callers override namespace/database scope via URL path | High | Also affects surrealdb |
| GHSA-66r2-5gwj-gxm2 SurrealDB: Writes in a PERMISSIONS clause bypass table permissions | Medium | Also affects surrealdb-core |
| GHSA-m3c3-78fh-w3w7 SurrealDB allows bypass of deny-net flags via DNS resolution | High | Also affects SurrealDB |
| GHSA-whwg-vh4f-pmmf SurrealDB: Edge PERMISSIONS FOR delete bypassed when a connected node is deleted | Medium | Also affects surrealdb |
| GHSA-fwg2-gr34-q3w8 SurrealDB: ES512 silently downgraded to ES384 due to jsonwebtoken crate limitation | Medium | Also affects surrealdb |
| GHSA-c8jx-96c9-8xrp SurrealDB: Field-level SELECT permissions bypassed via indexed COUNT fast paths | Medium | Also affects surrealdb |
| GHSA-wp87-mgvq-5j93 SurrealDB: USE NS/DB implicit creation bypasses DEFINE authorization | Medium | Also affects surrealdb |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor