GHSA-xj2x-f8qw-37mr: bcrypt Non-ASCII Hash Input Can Cause Vulnerability
MODERATEGHSA-xj2x-f8qw-37mr is a MODERATE (CVSS 5.3) non-ascii hash input can cause vulnerability (CWE-248: Uncaught Exception) affecting bcrypt libraries in the crates.io ecosystem. The issue involves non-ascii hash input can cause verification panic. Remediation is available by upgrading affected packages to version 0.19.2.
GHSA-xj2x-f8qw-37mr at a Glance
Security Impact
CVSS: 5.3
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:N/I:N/A:L).
How to Fix GHSA-xj2x-f8qw-37mr
To remediate this vulnerability, upgrade all affected bcrypt 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 bcrypt to 0.19.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for bcrypt
How to Check if You Are Affected
To determine whether your application is affected by GHSA-xj2x-f8qw-37mr, inspect your project dependencies for bcrypt:
inspect dependencies for bcrypt
Analyze the terminal output to locate any version of bcrypt in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.19.2), 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-248: Uncaught Exception, where an exception is thrown from a function, but it is not caught. In bcrypt, 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-xj2x-f8qw-37mr Affected bcrypt Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
bcrypt
|
crates.io |
≥ 0.19.0
< 0.19.2
|
0.19.2
|
References
Frequently Asked Questions
What is GHSA-xj2x-f8qw-37mr?
Which bcrypt versions are affected?
What version fixes GHSA-xj2x-f8qw-37mr?
Is bcrypt affected?
What is the CVSS score of GHSA-xj2x-f8qw-37mr?
What CWE is associated with GHSA-xj2x-f8qw-37mr?
How can I check crates.io dependencies for GHSA-xj2x-f8qw-37mr?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xj2x-f8qw-37mr",
"modified" : "2026-12-03T23:53:37Z",
"published" : "2026-12-03T23:53:37Z",
"aliases" : [ ],
"summary" : "bcrypt: Non-ASCII hash input can cause verification panic",
"details" : "`bcrypt::verify(password, hash)` and `HashParts::from_str(hash)` panic in `str::slice_error_fail` when given a 60-byte `&str` containing a multi-byte UTF-8 character at certain byte positions.\n\n## Impact\n\nAny Rust code that calls `bcrypt::verify` (or `HashParts::from_str`) with an attacker-controlled hash string will panic. The `bcrypt` crate is `#![forbid(unsafe_code)]`, so this is limited to a denial-of-service and cannot lead to memory corruption.\n\nRealistic attack contexts include:\n\n- Rust authentication services reading hashes from a database that was\n previously compromised via, e.g., SQL injection. The attacker can then\n crash the service on every login attempt against the tampered account.\n- CLI tools accepting hashes from stdin or command-line arguments.\n- Password managers or vault services loading hashes from untrusted\n configuration sources.\n\n## Root cause\n\n`split_hash` performed five `&str` slicing operations on the input hash: `&hash[1..3]`, `&hash[4..6]`, `&hash[7..]`, `&salt_and_hash[..22]`, and `&salt_and_hash[22..]`. None of these were char-boundary-checked. Any input where a multi-byte UTF-8 character spanned one of those byte positions caused a panic.\n\nThis is a regression of the fix originally shipped in 2021 for issue #62 (commit `0833509`). The regression was introduced in the parser rewrite in PR #95 (commit `e9a8394`, released as 0.19.0).\n\nThe pre-existing regression test `does_no_error_on_char_boundary_splitting` was not removed, but was silently rendered ineffective by the new `bytes[0] != b'$'` guard, which rejected its input earlier and prevented it from reaching the buggy slices — leaving CI green through the regression.\n\n## Fix\n\n`split_hash` now rejects any hash string containing non-ASCII bytes up front. A valid bcrypt hash is always exactly 60 ASCII bytes, so this closes the entire class of byte-boundary panics rather than guarding each slice individually.\n\nThe fix was merged in PR #103 and released as `bcrypt 0.19.2` on 2026-06-20.\n\n## Downstream impact\n\n`pyca/bcrypt` (which depended on `bcrypt 0.19.1`) is **not** affected. Its Python-side wrapper performs its own byte-level salt parsing before invoking `bcrypt::hash_with_salt`, and never reaches the buggy code path in `split_hash` or `verify`.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "bcrypt"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.19.0"
}, {
"fixed" : "0.19.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Keats/rust-bcrypt/pull/103"
}, {
"type" : "WEB",
"url" : "https://github.com/Keats/rust-bcrypt/commit/084bedde0aa5501c6d6a0287f6d6857e793fde85"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Keats/rust-bcrypt"
}, {
"type" : "WEB",
"url" : "https://github.com/Keats/rust-bcrypt/releases/tag/v0.19.2"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2026-0199.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-248" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-03T23:53:37Z",
"nvd_published_at" : null
}
}