CVE-2020-28500: Regular Expression Denial of Service (ReDoS) in lodash
Summary
CVE-2020-28500: Regular Expression Denial of Service (ReDoS) in lodash. Affects lodash versions < 4.17.21. Fixed in 4.17.21. How to fix ↓
Also tracked for
- node-lodash · Debian:11
The same CVE-2020-28500 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The lodash package is a popular utility library for JavaScript that provides helpful functions for manipulating and working with arrays, objects, and other data types. It is widely used in various applications and frameworks. However, versions of lodash prior to 4.17.21 are vulnerable to a Regular Expression Denial of Service (ReDoS) attack. This vulnerability affects the toNumber, trim, and trimEnd functions in lodash.
Vulnerability Detail
The Regular Expression Denial of Service (ReDoS) vulnerability in lodash allows an attacker to exploit the toNumber, trim, and trimEnd functions by providing specially crafted input strings. When these functions are called with a malicious input string, they can enter into an inefficient regular expression matching process that can cause the application to hang or crash. This can lead to denial of service attacks, where an attacker can repeatedly send malicious requests to exhaust server resources and disrupt the normal functioning of the application.
How To Fix
Latest published version: 4.18.1 as of 22 Oct 2026
npm install lodash@4.18.1
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
4.17.21
This is the first release that contains the fix.
npm install lodash@4.17.21
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version of lodash is not immediately feasible, a possible workaround is to implement input validation and sanitization for the affected functions. By carefully validating and sanitizing user input before passing it to the toNumber, trim, and trimEnd functions, developers can reduce the risk of a successful ReDoS attack. Here is an example of how input validation can be implemented for the trim function in lodash:
var lo = require('lodash');
function safeTrim(str) {
if (typeof str !== 'string') {
throw new Error('Invalid input: expected a string');
}
// Perform the trim operation
return lo.trim(str);
}
var input = ' Hello, World! ';
var trimmed = safeTrim(input);
console.log(trimmed); // Output: 'Hello, World!'
By validating the input type and ensuring it is a string, the risk of a ReDoS attack can be mitigated.
Conclusion
The Regular Expression Denial of Service (ReDoS) vulnerability in lodash can be mitigated by upgrading to version 4.17.21 or later. Developers should also consider implementing input validation and sanitization for the affected functions as a temporary workaround. It is important to stay updated with the latest security patches and best practices to ensure the security and availability of the application. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for lodash →
FAQ
The vulnerability allows an attacker to cause a denial of service by sending specially crafted input strings to the affected functions in lodash. This can lead to application crashes or hangs, disrupting the normal functioning of the application.
No, only versions of lodash prior to 4.17.21 are vulnerable to this ReDoS vulnerability. It is recommended to upgrade to the latest version to mitigate the risk.
Yes, this vulnerability can be exploited remotely by sending malicious requests to the affected functions in lodash. It is important to update to the latest version or implement input validation to prevent such attacks.
At the time of this advisory, there are no known public exploits specifically targeting this vulnerability in lodash. However, it is always recommended to stay updated with the latest security patches and best practices to mitigate the risk of any potential exploits.
Yes, the CVSS score for this vulnerability is 5.3, indicating a moderate severity level. It is important to address this vulnerability in a timely manner to prevent any potential impact on the application's security and availability.
References
Related vulnerabilities
Recent vulnerabilities recorded for lodash.