CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-42036
5.30.05%

CVE-2026-42036: maxContentLength Bypass and Resource Exhaustion in Axios

Alon Barad
Alon Barad
Software Engineer

May 5, 2026·6 min read·10 visits

PoC Available

Executive Summary (TL;DR)

Axios fails to enforce response size limits on streams, allowing an attacker to supply infinite data streams that bypass configured boundaries and cause local resource exhaustion.

A resource exhaustion vulnerability exists in the Axios Node.js HTTP client where the maxContentLength configuration is not enforced for stream responses, potentially causing Denial of Service.

Vulnerability Overview

Axios is a promise-based HTTP client for the browser and Node.js. It provides the maxContentLength configuration option to protect applications from unbounded responses by defining a maximum acceptable response body size. This mechanism is critical for preventing resource exhaustion when interacting with untrusted external servers.

Prior to versions 1.15.1 and 0.31.1, the Axios Node.js adapter fails to enforce the maxContentLength limit when a request specifies responseType: 'stream'. The library returns the response stream to the caller without applying the byte-counting constraints that are normally enforced for buffered response types.

This vulnerability is classified under CWE-770 (Allocation of Resources Without Limits or Throttling). By serving an infinite or excessively large data stream, a malicious server can bypass the intended safety boundaries of the Axios client. This condition allows unbounded downstream consumption, leading to local resource exhaustion.

Root Cause Analysis

The root cause resides in the Axios Node.js HTTP adapter implementation (lib/adapters/http.js). The library enforces maxContentLength within the code path responsible for buffering response data. When handling standard response types like json, text, or arraybuffer, Axios aggregates data chunks into memory and continuously verifies the cumulative byte count against the configured threshold.

When responseType: 'stream' is used, the HTTP adapter delegates the request to the follow-redirects package, which acts as a wrapper for the native Node.js http and https modules. Upon receiving the initial HTTP response headers, Axios immediately resolves the request promise. This returns the raw IncomingMessage object, which implements the ReadableStream interface, directly to the calling application.

Because the promise settles before data consumption begins, Axios bypasses the buffering logic entirely. Consequently, the byte-counting enforcement mechanism is never engaged. The application receives a raw stream that continues to emit data events regardless of the maxContentLength configuration, effectively shifting the responsibility of size validation to the downstream consumer.

Code Analysis

The vulnerability is patched by updating the underlying follow-redirects dependency to version 1.16.0. Axios relies on follow-redirects for native HTTP/HTTPS handling and redirection logic. The vulnerability ultimately stems from a lack of stream-level size enforcement within this dependency chain when passing the raw socket to the caller.

In the vulnerable configuration, Axios initiates the request but does not inject stream-level constraints into the returned IncomingMessage. The fix in commit 770f5ef0811fc6ec8e7cea4ff40eb83542957bc3 bumps the follow-redirects dependency. The updated follow-redirects version implements internal byte-monitoring logic associated with its maxBodyLength parameter, which maps directly to the Axios maxContentLength configuration.

With the dependency updated, follow-redirects enforces the byte limit directly on the socket stream. When the received byte count exceeds the threshold, the library emits a 'maxBodyLength exceeded' error and proactively destroys the underlying TCP socket. This prevents the Node.js process from continuing to download the oversized payload.

// Package lock structural change reflecting the mitigation
// Vulnerable
"dependencies": {
  "follow-redirects": "^1.15.0"
}
 
// Patched
"dependencies": {
  "follow-redirects": "^1.15.6" // Resolves to >= 1.16.0 containing the fix
}

Exploitation

Exploitation requires the attacker to control the HTTP server responding to an Axios client request. The target application must explicitly configure the Axios request with responseType: 'stream' and define a maxContentLength value. This setup is common in applications that proxy downloads or process large files iteratively to save memory.

The attacker configures their malicious HTTP server to accept incoming connections and respond with an endless stream of garbage data or a payload significantly larger than the expected file size. Because the client library fails to terminate the connection upon reaching the maxContentLength limit, the server can sustain the data transmission indefinitely.

> [!NOTE] > A standard Node.js server using res.write() in a continuous loop is sufficient to trigger the vulnerability.

The Axios client resolves the response promise upon receiving the headers and passes the stream to the application logic. The application processes the incoming data chunks, resulting in sustained CPU usage, memory accumulation, or disk space consumption depending on how the application handles the emitted data.

Impact Assessment

The primary security impact is Denial of Service (DoS) through resource exhaustion. Depending on how the application handles the returned stream, an attacker can exhaust different system resources. The CVSS v3.1 base score is 5.3 (Medium), reflecting a partial loss of availability with no confidentiality or integrity impact.

If the application pipes the Axios response stream directly to the local filesystem using fs.createWriteStream, an attacker can exhaust available disk space. This can lead to system-wide instability, preventing logging mechanisms, databases, and other applications from functioning correctly.

If the downstream application buffers the stream chunks into memory, the attack will cause rapid memory consumption, eventually triggering an Out-Of-Memory (OOM) crash in the Node.js process. Continuous processing of an endless stream also monopolizes the event loop, causing CPU exhaustion and degrading the application's ability to service legitimate requests.

Remediation

The official remediation is to update the Axios library to a patched version. Maintainers released versions 1.15.1 and 0.31.1 to address the vulnerability. These releases include the necessary dependency updates to follow-redirects that introduce native stream-level size enforcement.

For environments where immediate upgrading is not feasible, developers must implement a manual stream wrapper. This involves piping the Axios response stream through a custom Transform stream that increments a byte counter on each chunk. If the counter exceeds the expected limit, the custom stream must call stream.destroy() on the incoming response to terminate the TCP connection immediately.

Developers should ensure that downstream consumers of Axios streams implement their own resource constraints. Relying solely on the HTTP client for size validation is insufficient defense-in-depth. All file system writes and memory buffers handling external data must enforce strict maximum size policies.

Official Patches

AxiosGitHub Security Advisory

Fix Analysis (1)

Technical Appendix

CVSS Score
5.3/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
EPSS Probability
0.05%
Top 84% most exploited

Affected Systems

Node.js Applications using AxiosServices utilizing Axios for streaming external resources

Affected Versions Detail

Product
Affected Versions
Fixed Version
axios
Axios
< 0.31.10.31.1
axios
Axios
>= 1.0.0, < 1.15.11.15.1
AttributeDetail
CWE IDCWE-770
Attack VectorNetwork
CVSS Score5.3
EPSS Score0.00051
ImpactDenial of Service
Exploit StatusPoC
CISA KEVFalse

MITRE ATT&CK Mapping

T1499Endpoint Denial of Service
Impact
CWE-770
Allocation of Resources Without Limits or Throttling

Allocation of Resources Without Limits or Throttling

Known Exploits & Detection

Research ReportConceptual PoC relying on a basic HTTP server returning an unbounded stream

Vulnerability Timeline

Fix identified/implemented via follow-redirects bump
2026-04-07
Vulnerability officially disclosed and CVE-2026-42036 assigned
2026-04-24
Fixed versions 1.15.1 and 0.31.1 released
2026-04-24

References & Sources

  • [1]GHSA-vf2m-468p-8v99
  • [2]NVD Record
  • [3]CVE.org Record
  • [4]Fix Commit

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.