Junglewise Threat Intelligence

CVE-2020-7689: npm bcrypt input truncation with integer overflow

CVE-2020-7689 · Severity: low · CVSS 3.1 · Published 2020-08-20

Vendors: npm.

Executive brief

The bcrypt npm package is a widely-used password hashing library. Versions before 5.0.0 contain a data truncation flaw that affects passwords longer than 255 bytes, particularly those containing emoji or other multi-byte Unicode characters. When affected versions hash such passwords, they produce hashes that are incompatible with other bcrypt implementations, meaning legitimate users may be unable to log in if the application switches implementations, and attackers who obtain password hashes may be able to craft simpler passwords that match them.

Technical details

This vulnerability stems from an integer overflow in the input handling logic of the bcrypt npm package. When processing input data exceeding 255 bytes, a truncation operation wraps around incorrectly, causing the package to process a different subset of the input than intended. The vulnerability manifests as cross-implementation incompatibility: bcrypt hashes of long Unicode strings (e.g., 64 or more emoji characters) fail verification in PHP's password_verify() and bcryptjs, and vice versa. The attack vector is network-adjacent to local, as it requires control over password input during hashing (account creation or password change). No authentication bypass is directly possible, but the incompatibility can lead to service disruption or account lockout. The fix was applied in version 5.0.0 by correcting the overflow handling and explicitly passing the key length to the underlying bcrypt function.

Affected products

  • npm bcrypt < 5.0.0

Timeline

  • 2020-06-21: disclosed
  • 2020-07-01: advisory
  • 2020-06-01: patched

References