Skip to main content

CVE-2022-31150: CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') in nodejs undici

Medium
Published: Tue Jul 19 2022 (07/19/2022, 20:40:10 UTC)
Source: CVE
Vendor/Project: nodejs
Product: undici

Description

undici is an HTTP/1.1 client, written from scratch for Node.js. It is possible to inject CRLF sequences into request headers in undici in versions less than 5.7.1. A fix was released in version 5.8.0. Sanitizing all HTTP headers from untrusted sources to eliminate `\r\n` is a workaround for this issue.

AI-Powered Analysis

AILast updated: 06/22/2025, 00:13:22 UTC

Technical Analysis

CVE-2022-31150 is a vulnerability classified under CWE-93, which pertains to improper neutralization of CRLF (Carriage Return Line Feed) sequences, commonly known as CRLF injection. This specific vulnerability affects the 'undici' HTTP/1.1 client library for Node.js, which is designed as a high-performance HTTP client written from scratch. Versions of undici prior to 5.7.1 are vulnerable to CRLF injection attacks, which allow an attacker to inject CRLF sequences into HTTP request headers. This injection can manipulate the structure of HTTP requests, potentially enabling HTTP response splitting, header injection, or other HTTP protocol-level attacks. The vulnerability arises because undici does not properly sanitize or neutralize CRLF characters in headers sourced from untrusted input, allowing attackers to insert malicious headers or manipulate existing ones. The issue was addressed and fixed starting with version 5.8.0 of undici. As a workaround, it is recommended to sanitize all HTTP headers from untrusted sources to remove any '\r\n' sequences before they are processed by undici. There are no known exploits in the wild reported for this vulnerability, and no direct patch links were provided in the source information. The vulnerability was publicly disclosed on July 19, 2022, and has been enriched by CISA for awareness. Given that undici is a widely used HTTP client in Node.js environments, this vulnerability could affect any Node.js application or service that uses vulnerable versions of undici and processes untrusted HTTP headers without proper sanitization.

Potential Impact

For European organizations, the impact of this vulnerability can vary depending on the extent of undici usage in their Node.js applications. If exploited, CRLF injection can lead to HTTP response splitting attacks, which may allow attackers to perform web cache poisoning, cross-site scripting (XSS), session fixation, or redirect users to malicious sites. This can compromise the confidentiality and integrity of web applications and potentially lead to data leakage or unauthorized access. Additionally, manipulation of HTTP headers could disrupt application availability or functionality. Organizations in sectors such as finance, healthcare, e-commerce, and government, which rely heavily on web applications and APIs built with Node.js, could face reputational damage, regulatory penalties (e.g., GDPR violations), and operational disruptions if this vulnerability is exploited. The lack of known exploits in the wild suggests a lower immediate risk, but the potential for exploitation remains significant if untrusted input is not properly sanitized. Given the widespread adoption of Node.js in modern web development across Europe, the vulnerability poses a moderate risk that requires timely mitigation to prevent exploitation.

Mitigation Recommendations

1. Upgrade undici to version 5.8.0 or later immediately to apply the official fix for this vulnerability. 2. Implement strict input validation and sanitization on all HTTP headers derived from untrusted sources to remove any CRLF sequences ('\r\n'). This should be done at the application layer before headers are passed to undici. 3. Conduct a thorough audit of all Node.js applications and services to identify usage of undici and verify the version in use. 4. Employ web application firewalls (WAFs) with rules designed to detect and block HTTP header injection and response splitting attempts. 5. Monitor application logs for unusual HTTP header patterns or anomalies that could indicate attempted exploitation. 6. Educate development teams on secure coding practices related to HTTP header handling and the risks of CRLF injection. 7. For organizations using third-party Node.js modules or frameworks that depend on undici, ensure those dependencies are also updated to versions that include the fix. 8. Consider implementing Content Security Policy (CSP) headers and other browser security mechanisms to mitigate the impact of potential XSS attacks resulting from HTTP response splitting.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-05-18T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9849c4522896dcbf6700

Added to database: 5/21/2025, 9:09:29 AM

Last enriched: 6/22/2025, 12:13:22 AM

Last updated: 8/4/2025, 9:32:47 PM

Views: 14

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats