CVE-2021-23425: Uncontrolled Resource Consumption in trim-off-newlines
Summary
CVE-2021-23425: Uncontrolled Resource Consumption in trim-off-newlines. Affects trim-off-newlines versions < 1.0.3. Fixed in 1.0.3. How to fix ↓
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 trim-off-newlines package is an npm package that provides a function for removing trailing newline characters from a string. It is commonly used in JavaScript applications to sanitize user input or manipulate text data. The package is vulnerable to a Regular Expression Denial of Service (ReDoS) attack, which can lead to uncontrolled resource consumption. This vulnerability affects all versions of the trim-off-newlines package.
Vulnerability Detail
The vulnerability in trim-off-newlines arises from the way it processes strings using regular expressions. An attacker can craft a malicious input string that triggers a ReDoS attack, causing the package to enter into an infinite loop and consume excessive CPU resources. This can lead to a denial of service (DoS) condition, impacting the availability of the application or system using the vulnerable package. The severity of this vulnerability is rated as MODERATE with a CVSS score of 5.3.
How To Fix
Latest published version: 1.0.3 as of 23 Oct 2026
npm install trim-off-newlines@1.0.3
The newest release already contains this fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to update the trim-off-newlines package to the fixed version to mitigate the risk of a ReDoS attack.
Conclusion
The trim-off-newlines package is vulnerable to a ReDoS attack, which can lead to uncontrolled resource consumption and a denial of service condition. It is crucial to update the package to version 1.0.3 or later to mitigate this vulnerability. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for trim-off-newlines →
FAQ
The trim-off-newlines package is an npm package that provides a function for removing trailing newline characters from a string.
A ReDoS (Regular Expression Denial of Service) attack is a type of vulnerability where a maliciously crafted input string can cause a regular expression matching algorithm to exhibit exponential time complexity, leading to excessive CPU usage and potentially a denial of service condition.
The vulnerability in trim-off-newlines can lead to uncontrolled resource consumption, causing excessive CPU usage and potentially a denial of service condition. This can impact the availability of the application or system using the vulnerable package.
To fix the vulnerability, it is recommended to upgrade to version 1.0.3 or later of the trim-off-newlines package.
There is no known workaround for this vulnerability. It is essential to update the trim-off-newlines package to the fixed version.