CVE-2021-45696: Sha2 Incorrect Hash Vulnerability
CRITICALCVE-2021-45696 is a CRITICAL (CVSS 9.8) incorrect hash vulnerability (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) affecting Sha2 libraries in the crates.io ecosystem. The issue involves incorrect hash in sha2. Remediation is available by upgrading affected packages to version 0.9.8.
CVE-2021-45696 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-45696
To remediate this vulnerability, upgrade all affected Sha2 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 sha2 to 0.9.8
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for sha2
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-45696, inspect your project dependencies for Sha2:
inspect dependencies for sha2
Analyze the terminal output to locate any version of Sha2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.8), 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-327: Use of a Broken or Risky Cryptographic Algorithm, where the product uses a broken or risky cryptographic algorithm or protocol. In Sha2, 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
CVE-2021-45696 Affected Sha2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sha2
|
crates.io |
≥ 0.9.7
< 0.9.8
All 1 versions
0.9.7
|
0.9.8
|
References
Frequently Asked Questions
What is CVE-2021-45696?
Which Sha2 versions are affected?
What version fixes CVE-2021-45696?
Is sha2 affected?
What is the CVSS score of CVE-2021-45696?
What CWE is associated with CVE-2021-45696?
How can I check crates.io dependencies for CVE-2021-45696?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fc7x-2cmc-8j2g",
"modified" : "2023-06-13T20:41:36Z",
"published" : "2022-01-06T22:10:26Z",
"aliases" : [ "CVE-2021-45696" ],
"summary" : "Incorrect hash in sha2",
"details" : "The v0.9.7 release of the sha2 crate introduced a new AVX2-accelerated backend which was automatically enabled for all x86/x86_64 CPUs where AVX2 support was autodetected at runtime.\n\nThis backend was buggy and would miscompute results for long messages (i.e. messages spanning multiple SHA blocks).\n\nThe crate has since been yanked, but any users who upgraded to v0.9.7 should immediately upgrade to v0.9.8 and recompute any hashes which were previously computed by v0.9.7.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "sha2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.9.7"
}, {
"fixed" : "0.9.8"
} ]
} ],
"versions" : [ "0.9.7" ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-45696"
}, {
"type" : "WEB",
"url" : "https://github.com/RustCrypto/hashes/pull/314"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/RustCrypto/hashes"
}, {
"type" : "WEB",
"url" : "https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/sha2/RUSTSEC-2021-0100.md"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0100.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-327" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-01-06T14:26:28Z",
"nvd_published_at" : "2021-12-27T00:15:00Z"
}
}