GHSA-gh9f-6xm2-c4j2: Surrealdb SurrealDB Vulnerable To Improper Authentication Vulnerability
MODERATEGHSA-gh9f-6xm2-c4j2 is a MODERATE (CVSS 6.3) surrealdb vulnerable to improper authentication vulnerability (CWE-287: Improper Authentication) affecting Surrealdb libraries in the crates.io ecosystem. The issue involves surrealdb vulnerable to improper authentication when changing databases as scope user. Remediation is available by upgrading affected packages to version 1.5.4, 2.0.0-alpha.6, 1.5.1.
GHSA-gh9f-6xm2-c4j2 at a Glance
Security Impact
CVSS: 6.3
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:L/I:L/A:L).
How to Fix GHSA-gh9f-6xm2-c4j2
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.
Upgrade surrealdb to 1.5.4
Upgrade surrealdb to 2.0.0-alpha.6
Upgrade surrealdb-core to 1.5.1
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-gh9f-6xm2-c4j2, 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.4), 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-287: Improper Authentication, where when an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct. 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
GHSA-gh9f-6xm2-c4j2 Affected Surrealdb Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
surrealdb
|
crates.io |
< 1.5.4
|
1.5.4
|
|
surrealdb
|
crates.io |
≥ 2.0.0-alpha.1
< 2.0.0-alpha.6
|
2.0.0-alpha.6
|
|
surrealdb-core
|
crates.io |
< 1.5.1
|
1.5.1
|
References
Frequently Asked Questions
What is GHSA-gh9f-6xm2-c4j2?
Which Surrealdb versions are affected?
What version fixes GHSA-gh9f-6xm2-c4j2?
Is surrealdb affected?
Is surrealdb-core affected?
What is the CVSS score of GHSA-gh9f-6xm2-c4j2?
What CWE is associated with GHSA-gh9f-6xm2-c4j2?
How can I check crates.io dependencies for GHSA-gh9f-6xm2-c4j2?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-gh9f-6xm2-c4j2",
"modified" : "2024-07-11T13:19:19Z",
"published" : "2024-07-11T13:19:19Z",
"aliases" : [ ],
"summary" : "SurrealDB vulnerable to Improper Authentication when Changing Databases as Scope User",
"details" : "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.\n\nBy 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.\n\n### Impact\n\nUnder 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.\n\nThe 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.\n\n### Patches\n\n- Version 1.5.4 and later are not affected by this issue.\n- Version 2.0.0-alpha.6 and later will not be affected by this issue.\n\n### Workarounds\n\nUsers 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.\n\n### References\n\n- https://github.com/surrealdb/surrealdb/pull/4335",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "surrealdb"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.5.4"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.5.3"
}
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "surrealdb"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0-alpha.1"
}, {
"fixed" : "2.0.0-alpha.6"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 2.0.0-alpha.5"
}
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "surrealdb-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.5.1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.5.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/surrealdb/surrealdb/security/advisories/GHSA-gh9f-6xm2-c4j2"
}, {
"type" : "WEB",
"url" : "https://github.com/surrealdb/surrealdb/pull/4335"
}, {
"type" : "WEB",
"url" : "https://github.com/surrealdb/surrealdb/commit/492f8378d57968dbdf5e63fad41b6ff59bba0b80"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/surrealdb/surrealdb"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-287" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-11T13:19:19Z",
"nvd_published_at" : null
}
}