GHSA-wq9x-qwcq-mmgf: Diesel Diesel Vulnerable To Binary Protocol Vulnerability
HIGHGHSA-wq9x-qwcq-mmgf is a HIGH (CVSS 8.1) diesel vulnerable to binary protocol vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Diesel libraries in the crates.io ecosystem. The issue involves diesel vulnerable to binary protocol misinterpretation caused by truncating or overflowing casts. Remediation is available by upgrading affected packages to version 2.2.3.
GHSA-wq9x-qwcq-mmgf at a Glance
Security Impact
CVSS: 8.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix GHSA-wq9x-qwcq-mmgf
To remediate this vulnerability, upgrade all affected Diesel 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 diesel to 2.2.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for diesel
How to Check if You Are Affected
To determine whether your application is affected by GHSA-wq9x-qwcq-mmgf, inspect your project dependencies for Diesel:
inspect dependencies for diesel
Analyze the terminal output to locate any version of Diesel in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.3), 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Diesel, 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-wq9x-qwcq-mmgf Affected Diesel Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
diesel
|
crates.io |
< 2.2.3
|
2.2.3
|
References
Frequently Asked Questions
What is GHSA-wq9x-qwcq-mmgf?
Which Diesel versions are affected?
What version fixes GHSA-wq9x-qwcq-mmgf?
Is diesel affected?
What is the CVSS score of GHSA-wq9x-qwcq-mmgf?
What CWE is associated with GHSA-wq9x-qwcq-mmgf?
How can I check crates.io dependencies for GHSA-wq9x-qwcq-mmgf?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wq9x-qwcq-mmgf",
"modified" : "2024-08-23T18:51:20Z",
"published" : "2024-08-23T18:51:20Z",
"aliases" : [ ],
"summary" : "Diesel vulnerable to Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts",
"details" : "The following presentation at this year's DEF CON was brought to our attention on the Diesel Gitter Channel:\n\n> SQL Injection isn't Dead: Smuggling Queries at the Protocol Level \n> <http://web.archive.org/web/20240812130923/https://media.defcon.org/DEF%20CON%2032/DEF%20CON%2032%20presentations/DEF%20CON%2032%20-%20Paul%20Gerste%20-%20SQL%20Injection%20Isn't%20Dead%20Smuggling%20Queries%20at%20the%20Protocol%20Level.pdf> \n> (Archive link for posterity.)\nEssentially, encoding a value larger than 4GiB can cause the length prefix in the protocol to overflow, \ncausing the server to interpret the rest of the string as binary protocol commands or other data.\n\nIt appears Diesel _does_ perform truncating casts in a way that could be problematic, \nfor example: <https://github.com/diesel-rs/diesel/blob/ae82c4a5a133db65612b7436356f549bfecda1c7/diesel/src/pg/connection/stmt/mod.rs#L36>\n\nThis code has existed essentially since the beginning, \nso it is reasonable to assume that all published versions `<= 2.2.2` are affected.\n\n## Mitigation\n\nThe prefered migration to the outlined problem is to update to a Diesel version newer than 2.2.2, which includes \nfixes for the problem. \n\nAs always, you should make sure your application is validating untrustworthy user input. \nReject any input over 4 GiB, or any input that could _encode_ to a string longer than 4 GiB. \nDynamically built queries are also potentially problematic if it pushes the message size over this 4 GiB bound.\n\nFor web application backends, consider adding some middleware that limits the size of request bodies by default.\n\n## Resolution\n\nDiesel now uses `#[deny]` directives for the following Clippy lints:\n\n* [`cast_possible_truncation`](https://rust-lang.github.io/rust-clippy/master/#/cast_possible_truncation)\n* [`cast_possible_wrap`](https://rust-lang.github.io/rust-clippy/master/#/cast_possible_wrap)\n* [`cast_sign_loss`](https://rust-lang.github.io/rust-clippy/master/#/cast_sign_loss)\n\nto prevent casts that will lead to precision loss or other trunctations. Additionally we performed an \naudit of the relevant code.\n\nA fix is included in the `2.2.3` release.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "diesel"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.2.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/diesel-rs/diesel/pull/4170"
}, {
"type" : "WEB",
"url" : "https://github.com/diesel-rs/diesel/commit/9eccd7d6d705ac53618bfd478152e32ec3b4536c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/diesel-rs/diesel"
}, {
"type" : "WEB",
"url" : "https://github.com/diesel-rs/diesel/blob/ae82c4a5a133db65612b7436356f549bfecda1c7/diesel/src/pg/connection/stmt/mod.rs#L36"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2024-0365.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-08-23T18:51:20Z",
"nvd_published_at" : null
}
}