CVE-2020-7689: Bcrypt Integer Overflow Or Wraparound And Vulnerability

MODERATE
Advisory Identifier: GHSA-5wg4-74h6-q47v
CVSS 5.9
CWE-190 CWE-327
Published
Advisory Summary

CVE-2020-7689 is a MODERATE (CVSS 5.9) integer overflow or wraparound and vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Bcrypt libraries in the npm ecosystem. The issue involves integer overflow or wraparound and use of a broken or risky cryptographic algorithm in bcrypt. Remediation is available by upgrading affected packages to version 5.0.0.

CVE-2020-7689 at a Glance

CVE Identifier CVE-2020-7689
GHSA Identifier GHSA-5wg4-74h6-q47v
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Bcrypt
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.9

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:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2020-7689

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.

bcrypt fixed: 5.0.0
npm install bcrypt@5.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls bcrypt

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2020-7689, inspect your project dependencies using npm:

npm ls 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 5.0.0), your application is affected.

Note: The npm ls bcrypt command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. 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

In bcrypt (npm package) before version 5.0.0, data is truncated wrong when its length is greater than 255 bytes.

CVE-2020-7689 Affected Bcrypt Versions

1 component(s)
Fixed Versions:
5.0.0
Product / Package Ecosystem Affected Versions Fixed Version
bcrypt
npm
< 5.0.0
5.0.0

References

Frequently Asked Questions

What is CVE-2020-7689?
CVE-2020-7689 is a security vulnerability in Bcrypt involving Integer Overflow or Wraparound and Use of a Broken or Risky Cryptographic Algorithm in bcrypt under CWE-190: Integer Overflow or Wraparound.
Which Bcrypt versions are affected?
Affected versions include releases prior to 5.0.0 across affected packages: bcrypt.
What version fixes CVE-2020-7689?
Upgrading to 5.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bcrypt affected?
Yes, bcrypt is affected in releases prior to 5.0.0. Upgrade your dependency to 5.0.0 or later.
What is the CVSS score of CVE-2020-7689?
CVE-2020-7689 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2020-7689?
CVE-2020-7689 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check npm dependencies for CVE-2020-7689?
Run the dependency tree command: 'npm ls bcrypt'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5wg4-74h6-q47v",
  "modified" : "2021-07-29T20:49:30Z",
  "published" : "2020-08-20T14:38:49Z",
  "aliases" : [ "CVE-2020-7689" ],
  "summary" : "Integer Overflow or Wraparound and Use of a Broken or Risky Cryptographic Algorithm in bcrypt",
  "details" : "In bcrypt (npm package) before version 5.0.0, data is truncated wrong when its length is greater than 255 bytes.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "bcrypt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-7689"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kelektiv/node.bcrypt.js/issues/776"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kelektiv/node.bcrypt.js/pull/806"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kelektiv/node.bcrypt.js/pull/807"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-BCRYPT-572911"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190", "CWE-327" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-20T14:37:17Z",
    "nvd_published_at" : "2020-07-01T14:15:00Z"
  }
}