CVE-2024-58363
JSON

5.3medium

SurrealDB before 1.5.4 Authentication Bypass via Database Switch

Severity
5.3medium CVSS:4.0 by VulnCheck
Exploit likelihood
0.23% (higher than 15% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
VulnCheck
Also known as
GHSA-gh9f-6xm2-c4j2

Description

SurrealDB before 1.5.4 and 2.0.0-alpha.1 before 2.0.0-alpha.6 fails to properly validate authentication when a scope user switches databases using the USE clause or use method. Attackers with an authenticated session can impersonate an unrelated user in a different database if a user record with an identical identifier exists, allowing unauthorized actions if permissions rely solely on the $auth parameter.

Affected

Product or packageVersionsReported by
surrealdb surrealdbbefore 1.5.4, from 2.0.0-alpha.1 before 2.0.0-alpha.6, 2.0.0
Not affected: 1.5.4, 2.0.0-alpha.6
CVE List, NVD
surrealdb surrealdb-corebefore 1.5.1
Not affected: 1.5.1
CVE List
surrealdb (crates.io)before 1.5.4, from 2.0.0-alpha.1 before 2.0.0-alpha.6GitHub Advisory Database
surrealdb-core (crates.io)before 1.5.1GitHub Advisory Database

All scores

VulnCheck5.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N
VulnCheck6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
GitHub6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N

Classification

CWE-287

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

SurrealDB before 1.5.4 and 2.0.0-alpha.1 before 2.0.0-alpha.6 fails to properly validate authentication when a scope user switches databases using the USE clause or use method. Attackers with an authenticated session can impersonate an unrelated user in a different database if a user record with an identical identifier exists, allowing unauthorized actions if permissions rely solely on the $auth parameter.

GitHub Advisory Database

Authentication would not be properly validated when an already authenticated scope user would use the use method or USE clause to switch working databases in a session. If there was a user record in the new database with identical record identifier as the original record that the user authenticated with in the original database, this could result in the user being able to perform actions under the identity of the unrelated user in the new database. This issue does not affect system users at any level.

By default, record identifiers are randomly generated with sufficient complexity to prevent the identifier collision required to trigger this issue. However, the issue may trigger in situations where multiple databases in the same SurrealDB instance are using explicitly defined or incremental record identifiers to identify users on an identically named table.

Impact

Under the circumstances described above, a user who has an authenticated session as a scope user in a database could become authorized to query data under the identity of a specific scope user associated with an identical record identifier in a different database within the same SurrealDB instace if the PERMISSIONS clause would allow it due to relying exclusively on the $auth parameter, which would point to the impersonated user. The impact is limited to the single user with matching record identifier.

The impact of this issue is mitigated if the table PERMISSIONS clause explicitly checks for an scope that only exists in the specific database (e.g. $scope = "production") or certain claims of the authentication token (e.g. $token.email = "example@example.com"), both of which would remain unchanged in the session of the authenticated user after changing databases. Permissions will default to NONE if there is no PERMISSIONS clause, which also mitigates this impact of this issue.

Patches
  • Version 1.5.4 and later are not affected by this issue.
  • Version 2.0.0-alpha.6 and later will not be affected by this issue.
Workarounds

Users unable to update may want to ensure that table PERMISSIONS clauses explicitly check that the $scope parameter matches a scope that is uniquely named across databases in the same SurrealDB instance. Ensuring that record identifiers for users are automatically generated or explicitly generated to be unique across databases may also be sufficient to mitigate this issue, as the $auth parameter will not link to any user record and any PERMISSIONS clauses restricting authorization based on the authenticated user should fail to successfully evaluate.

References
NVD (es)

SurrealDB antes de 1.5.4 no valida correctamente la autenticación cuando un usuario de ámbito cambia de bases de datos usando la cláusula USE o el método use. Los atacantes con una sesión autenticada pueden suplantar a un usuario no relacionado en una base de datos diferente si existe un registro de usuario con un identificador idéntico, permitiendo acciones no autorizadas si los permisos dependen únicamente del parámetro $auth.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-58363 changed 2026-10-29CVE Terms of Use
GitHub Advisory DatabaseGHSA-gh9f-6xm2-c4j2 changed 2026-07-19CC-BY-4.0
NVDCVE-2024-58363 changed 2026-10-29Public domain