Regular Expression Denial-of-Service in trim-newlines Package

node-trim-newlines Updated 02 Oct 2025

Summary

28/05/2021
N/A
Yes i
High
7.5

CVE-2021-33623: The trim-newlines package before 3.0.1 and 4.x before 4.0.1 for Node.js has an issue related to regular expression denial-of-service (ReDoS) for the .end() method. Affects node-trim-newlines across 2 version ranges.

< 3.0.0-1+deb11u1 < b63718391b436e87fe9b29052c1b9274786e89fa

Fixed in 3.0.0-1+deb11u1. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The trim-newlines package is a Node.js utility designed to remove newline characters from the beginning and end of strings. It is widely used in applications that require string manipulation, ensuring clean data input and output. However, versions prior to 3.0.1 and 4.x before 4.0.1 are susceptible to a vulnerability that can be exploited through regular expressions, leading to potential denial-of-service attacks.

Vulnerability Detail

The vulnerability, identified as CVE-2021-33623, arises from a flaw in the .end() method of the trim-newlines package. This flaw allows attackers to craft specific inputs that cause excessive backtracking in the regular expression engine, leading to performance degradation and potential application crashes. The impact of this vulnerability can be severe, especially in applications that process untrusted input, as it can render the application unresponsive or slow.

How To Fix

Minimum fixed version

3.0.0-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-trim-newlines

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate updating is not feasible, consider implementing input validation to restrict the types of strings that can be processed by the trim-newlines package. This can help mitigate the risk of exploitation until the package can be updated.

Conclusion

The trim-newlines package has a significant vulnerability that can lead to denial-of-service attacks if not addressed. It is crucial for developers using this package to update to the latest version and consider implementing input validation as a temporary measure. Utilizing tools like Vulert can help in monitoring vulnerabilities effectively.

See every vulnerability recorded for node-trim-newlines →

Share this vulnerability

FAQ

CVE-2021-33623 is a vulnerability in the trim-newlines package that allows for regular expression denial-of-service attacks through the .end() method.

You can use the Vulert platform to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected without needing to sign up.

Exploitation of this vulnerability can lead to application crashes or significant slowdowns, especially when processing untrusted input.

Versions of trim-newlines prior to 3.0.1 and 4.x before 4.0.1 are affected by this vulnerability.

Yes, implementing input validation to restrict the types of strings processed by the trim-newlines package can help mitigate the risk until an update can be performed.

Related vulnerabilities

Recent vulnerabilities recorded for node-trim-newlines.

How To Fix

Minimum fixed version

3.0.0-1+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-trim-newlines

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback