Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS1xM2dnLW04aHItaDR4NM4AA5Zu
Externally Controlled Format String in Scripting Functions
The rquickjs
crate used by SurrealDB implements Rust bindings to the QuickJS C library and is used to execute SurrealDB scripting functions. The rquickjs
function Exception::throw_type
takes a string and returns an error object. Prior to version 0.4.2
of the crate, this string would be fed directly into printf
, which will receive the error string as a format string with no additional arguments, leading to undefined behavior. This issue triggers when a SurrealDB scripting function returns an error and its input contains a format string such as %s
or %d
.
This vulnerability can only affect SurrealDB servers explicitly enabling the scripting capability with --allow-scripting
or --allow-all
and equivalent environment variables SURREAL_CAPS_ALLOW_SCRIPT=true
and SURREAL_CAPS_ALLOW_ALL=true
.
Impact
An attacker with privileges to execute scripting functions with arbitrary inputs may be able to exploit this format string vulnerability in order read arbitrary memory from the remote SurrealDB process. A format string vulnerability may also be further exploited to execute arbitrary code with the privileges of the SurrealDB process.
The fact that error messages are limited to 256 bytes coupled with exploit mitigation features supported in Rust executables may somewhat increase the complexity of exploiting this vulnerability to reliably achieve remote code execution in practice.
Patches
- Version 1.1.1 and later are not affected by this issue.
Workarounds
Users unable to update should restrict access from untrusted users to define and execute scripting functions. This can be achieved by removing the scripting capability by default or with --deny-scripting
and equivalent environment variable SURREAL_CAPS_DENY_SCRIPT=true
. If not possible, network access should be limited to trusted users.
References
- https://github.com/surrealdb/surrealdb/issues/3327
- https://github.com/surrealdb/surrealdb/pull/3332
- https://github.com/DelSkayn/rquickjs/pull/247
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1xM2dnLW04aHItaDR4NM4AA5Zu
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 10 months ago
Updated: 10 months ago
CVSS Score: 8.6
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
Identifiers: GHSA-q3gg-m8hr-h4x4
References:
- https://github.com/surrealdb/surrealdb/security/advisories/GHSA-q3gg-m8hr-h4x4
- https://github.com/surrealdb/surrealdb/issues/3327
- https://github.com/surrealdb/surrealdb/pull/3332
- https://github.com/advisories/GHSA-q3gg-m8hr-h4x4
Blast Radius: 18.9
Affected Packages
cargo:surrealdb
Dependent packages: 42Dependent repositories: 158
Downloads: 256,478 total
Affected Version Ranges: < 1.1.1
Fixed in: 1.1.1
All affected versions: 1.0.0, 1.0.1, 1.0.2, 1.1.0
All unaffected versions: 1.1.1, 1.2.0, 1.2.2, 1.3.0, 1.3.1, 1.4.0, 1.4.2, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.1.4