Vulnerabilities in pkg:npm/lodash.trim

PACKAGE
Advisory Identifier: GHSA-29mw-wpgm-hmr9
Advisory Summary

CVE-2020-28500 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Lodash libraries in the npm ecosystem. The issue involves regular expression denial of service (redos) in lodash. Remediation is available by upgrading affected packages to version 4.17.21.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/lodash.trim

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/lodash.trim. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-29mw-wpgm-hmr9 CVE-2020-28500 MODERATE Regular Expression Denial of Service (ReDoS) in lodash

CVE-2020-28500 at a Glance

CVE Identifier CVE-2020-28500
GHSA Identifier GHSA-29mw-wpgm-hmr9
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Lodash
Package Ecosystem npm
Published Date
Last Updated

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).

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

How to Fix CVE-2020-28500

To remediate this vulnerability, upgrade all affected Lodash dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

lodash fixed: 4.17.21
npm install lodash@4.17.21
lodash-es fixed: 4.17.21
npm install lodash-es@4.17.21
lodash.trimend fixed: Latest secure release
npm install lodash.trimend@Latest secure release
lodash.trim fixed: Latest secure release
npm install lodash.trim@Latest secure release
lodash-rails fixed: 4.17.21
Upgrade lodash-rails to 4.17.21
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 lodash

How to Check if You Are Affected

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

npm ls lodash

Analyze the terminal output to locate any version of Lodash in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.17.21), your application is affected.

Note: The npm ls lodash 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Lodash, 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

All versions of package lodash prior to 4.17.21 are vulnerable to Regular Expression Denial of Service (ReDoS) via the `toNumber`, `trim` and `trimEnd` functions. Steps to reproduce (provided by reporter Liyuan Chen): ```js var lo = require('lodash'); function build_blank(n) { var ret = "1" for (var i = 0; i < n; i++) { ret += " " } return ret + "1"; } var s = build_blank(50000) var time0 = Date.now(); lo.trim(s) var time_cost0 = Date.now() - time0; console.log("time_cost0: " + time_cost0); var time1 = Date.now(); lo.toNumber(s) var time_cost1 = Date.now() - time1; console.log("time_cost1: " + time_cost1); var time2 = Date.now(); lo.trimEnd(s); var time_cost2 = Date.now() - time2; console.log("time_cost2: " + time_cost2); ```

CVE-2020-28500 Affected Lodash Versions

5 component(s)
Fixed Versions:
4.17.21
Product / Package Ecosystem Affected Versions Fixed Version
lodash
npm
≥ 4.0.0
< 4.17.21
4.17.21
lodash-es
npm
≥ 4.0.0
< 4.17.21
4.17.21
lodash.trimend
npm
≥ 4.0.0
≤ 4.5.1
lodash.trim
npm
≥ 4.0.0
≤ 4.5.1
lodash-rails
RubyGems
≥ 4.0.0
< 4.17.21
4.17.21

References

NVD — CVE-2020-28500 NVD
https://nvd.nist.gov/vuln/detail/CVE-2020-28500
Lodash Source Repository REPOSITORY
https://github.com/github/advisory-database/pull/6139
Lodash Source Repository REPOSITORY
https://github.com/lodash/lodash/pull/5065
Lodash Source Repository REPOSITORY
https://github.com/lodash/lodash/pull/5065/commits/02906b8191d3c100c193fe6f7b27d1c40f200bb7
Security Fix Commit FIX COMMIT
https://github.com/lodash/lodash/commit/c4847ebe7d14540bb28a8b932a9ce1b9ecbfee1a
Lodash Security Information SECURITY
https://www.oracle.com/security-alerts/cpuoct2021.html
Lodash Security Information SECURITY
https://www.oracle.com/security-alerts/cpujul2022.html
Lodash Security Information SECURITY
https://www.oracle.com/security-alerts/cpujan2022.html
Lodash Security Information SECURITY
https://www.oracle.com//security-alerts/cpujul2021.html
snyk.io/vuln/snyk-js-lodash... WEB
https://snyk.io/vuln/SNYK-JS-LODASH-1018905
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1074893
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBLODASH-1074895
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1074892
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1074894
snyk.io/vuln/snyk-java-orgf... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGFUJIONWEBJARS-1074896
Lodash Security Information SECURITY
https://security.netapp.com/advisory/ntap-20210312-0006
Lodash Source Repository REPOSITORY
https://github.com/rubysec/ruby-advisory-db/blob/master/gems/lodash-rails/CVE-2020-28500.yml
Lodash Source Repository REPOSITORY
https://github.com/lodash/lodash/blob/npm/trimEnd.js%23L8
Lodash Source Repository REPOSITORY
https://github.com/lodash/lodash
cert-portal.siemens.com/productcert/pdf/ssa... WEB
https://cert-portal.siemens.com/productcert/pdf/ssa-637483.pdf

Frequently Asked Questions

What is CVE-2020-28500?
CVE-2020-28500 is a security vulnerability in Lodash involving Regular Expression Denial of Service (ReDoS) in lodash under CWE-400: Uncontrolled Resource Consumption.
Which Lodash versions are affected?
Affected versions include releases prior to 4.17.21 across affected packages: lodash, lodash-es, lodash.trimend, lodash.trim, lodash-rails.
What version fixes CVE-2020-28500?
Upgrading to 4.17.21 (or the latest patched release for your respective branch) resolves the vulnerability.
Is lodash affected?
Yes, lodash is affected in releases prior to 4.17.21. Upgrade your dependency to 4.17.21 or later.
Is lodash-es affected?
Yes, lodash-es is affected in releases prior to 4.17.21. Upgrade your dependency to 4.17.21 or later.
What is the CVSS score of CVE-2020-28500?
CVE-2020-28500 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2020-28500?
CVE-2020-28500 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check npm dependencies for CVE-2020-28500?
Run the dependency tree command: 'npm ls lodash'. 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-29mw-wpgm-hmr9",
  "modified" : "2025-09-29T20:19:45Z",
  "published" : "2022-01-06T20:30:46Z",
  "aliases" : [ "CVE-2020-28500" ],
  "summary" : "Regular Expression Denial of Service (ReDoS) in lodash",
  "details" : "All versions of package lodash prior to 4.17.21 are vulnerable to Regular Expression Denial of Service (ReDoS) via the `toNumber`, `trim` and `trimEnd` functions. \n\nSteps to reproduce (provided by reporter Liyuan Chen):\n```js\nvar lo = require('lodash');\n\nfunction build_blank(n) {\n    var ret = \"1\"\n    for (var i = 0; i < n; i++) {\n        ret += \" \"\n    }\n    return ret + \"1\";\n}\nvar s = build_blank(50000) var time0 = Date.now();\nlo.trim(s) \nvar time_cost0 = Date.now() - time0;\nconsole.log(\"time_cost0: \" + time_cost0);\nvar time1 = Date.now();\nlo.toNumber(s) var time_cost1 = Date.now() - time1;\nconsole.log(\"time_cost1: \" + time_cost1);\nvar time2 = Date.now();\nlo.trimEnd(s);\nvar time_cost2 = Date.now() - time2;\nconsole.log(\"time_cost2: \" + time_cost2);\n```",
  "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" : "npm",
      "name" : "lodash"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.17.21"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash-es"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.17.21"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash.trimend"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "last_affected" : "4.5.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "lodash.trim"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "last_affected" : "4.5.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "lodash-rails"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.17.21"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-28500"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/github/advisory-database/pull/6139"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/pull/5065"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/pull/5065/commits/02906b8191d3c100c193fe6f7b27d1c40f200bb7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/commit/c4847ebe7d14540bb28a8b932a9ce1b9ecbfee1a"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuoct2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpujan2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com//security-alerts/cpujul2021.html"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-LODASH-1018905"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1074893"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBLODASH-1074895"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1074892"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1074894"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGFUJIONWEBJARS-1074896"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210312-0006"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/lodash-rails/CVE-2020-28500.yml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/lodash/lodash/blob/npm/trimEnd.js%23L8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lodash/lodash"
  }, {
    "type" : "WEB",
    "url" : "https://cert-portal.siemens.com/productcert/pdf/ssa-637483.pdf"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-19T22:45:28Z",
    "nvd_published_at" : "2021-02-15T11:15:00Z"
  }
}