GHSA-29mw-wpgm-hmr9 CVE-2020-28500
Regular Expression Denial of Service (ReDoS) in lodash
- Severity
- 5.3 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 7.34%
- Chance of exploitation in the next 30 days. Higher than 94.39% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
- Available
- 3 packages have a fixed version
Description
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);
Affected versions
RubyGems
| Package | Vulnerable | Fixed in |
|---|---|---|
| lodash-rails | >= 4.0.0, < 4.17.21 |
4.17.21 |
| lodash-rails | >= 4.0.0, < 4.17.21 |
4.17.21 |
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| lodash | >= 4.0.0, < 4.17.21 |
4.17.21 |
| lodash | >= 4.0.0, < 4.17.21 |
4.17.21 |
| lodash-es | >= 4.0.0, < 4.17.21 |
4.17.21 |
| lodash-es | >= 4.0.0, < 4.17.21 |
4.17.21 |
| lodash.trim | >= 4.0.0, <= 4.5.1 |
No fix yet |
| lodash.trim | >= 4.0.0, <= 4.5.1 |
No fix yet |
| lodash.trimend | >= 4.0.0, <= 4.5.1 |
No fix yet |
| lodash.trimend | >= 4.0.0, <= 4.5.1 |
No fix yet |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
lodash-rails RubyGems → 4.17.21
- bundler
bundle update lodash-rails # Gemfile: gem "lodash-rails", ">= 4.17.21"
lodash npm → 4.17.21
- npm
npm install lodash@4.17.21- yarn
yarn add lodash@4.17.21- pnpm
pnpm add lodash@4.17.21
lodash-es npm → 4.17.21
- npm
npm install lodash-es@4.17.21- yarn
yarn add lodash-es@4.17.21- pnpm
pnpm add lodash-es@4.17.21
Severity breakdown
CVSS 3.1 5.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Weakness
CWE-400: Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource.
How to prevent it
- Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
- Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
- Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
- Implementation: Ensure that all failures in resource allocation place the system into a safe posture.
CWE-1333: Inefficient Regular Expression Complexity
The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.
How to prevent it
- Architecture and Design: Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
- System Configuration: Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
- Implementation: Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
- Implementation: Limit the length of the input that the regular expression will process.
References
Advisories
Fixes and patches
Packages
Other links
- github.com/lodash/lodash/blob/npm/trimEnd.js%23L8
- snyk.io/vuln/SNYK-JS-LODASH-1018905
- snyk.io/vuln/SNYK-JAVA-ORGFUJIONWEBJARS-1074896
- snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1074894
- snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1074892
- snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBLODASH-1074895
- snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1074893
- oracle.com//security-alerts/cpujul2021.html
- oracle.com/security-alerts/cpuoct2021.html
- oracle.com/security-alerts/cpujan2022.html
- oracle.com/security-alerts/cpujul2022.html
- cert-portal.siemens.com/productcert/pdf/ssa-637483.pdf
- security.netapp.com/advisory/ntap-20210312-0006
- github.com/rubysec/ruby-advisory-db/blob/master/gems/lodash-rails/CVE-2020-2850…
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-r5fr-rjxr-66jc lodash vulnerable to Code Injection via `_.template` imports key names | Critical | Also affects lodash |
| GHSA-f23m-r3pf-42rh lodash vulnerable to Prototype Pollution via array path bypass in `_.unset` and `_.omit` | Medium | Also affects lodash |
| GHSA-xxjr-mmjv-4gpg Lodash has Prototype Pollution Vulnerability in `_.unset` and `_.omit` functions | Medium | Also affects lodash |
| GHSA-35jh-r3h4-6jhm Command Injection in lodash | High | Also affects lodash |
| GHSA-p6mc-m468-83gw Prototype Pollution in lodash | High | Also affects lodash |
| GHSA-x5rq-j2xg-h7qm Regular Expression Denial of Service (ReDoS) in lodash | Medium | Also affects lodash |
| GHSA-jf85-cpcp-j695 Prototype Pollution in lodash | Critical | Also affects lodash |
| GHSA-4xc9-xhrj-v574 Prototype Pollution in lodash | High | Also affects lodash |
Credits: DmitriyLewen, G-Rath, jkmartindale, levpachmanov, mitchell-codecov, nitaiapiiro
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor