CVE-2026-42039: Axios Unbounded Recursion in toFormData Leads to DoS via Deeply Nested Request Data
Summary
CVE-2026-42039: Axios: unbounded recursion in toFormData causes DoS via deeply nested request data. Affects axios across 2 version ranges.
< 0.31.1
>= 1.0.0, < 1.15.1
Fixed in 0.31.1 or 1.15.1, depending on the release line you run. 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
Axios is a popular JavaScript library used for making HTTP requests from both the browser and Node.js. It simplifies the process of sending asynchronous HTTP requests to REST endpoints and performing CRUD operations. Axios supports promises and provides a rich set of features, including interceptors, automatic JSON data transformation, and the ability to cancel requests. However, a recent vulnerability has been identified in its toFormData function, which can lead to denial of service (DoS) attacks when processing deeply nested request data.
Vulnerability Detail
The vulnerability arises from the toFormData function, which recursively processes nested objects without a depth limit. This lack of restriction allows an attacker to craft a deeply nested payload, potentially exceeding 2000 levels deep. When such a payload is processed, it causes a RangeError due to exhaustion of the V8 call stack, leading to a crash of the Node.js process. This vulnerability can be exploited by remote, unauthenticated attackers who can influence the data passed to Axios, resulting in a denial of service in server-side applications that utilize Axios for handling requests.
How To Fix
Latest published version: 1.20.0 as of 22 Oct 2026
npm install axios@1.20.0
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 0.31.10.31.1npm install axios@0.31.1 -
>= 1.0.0, < 1.15.11.15.1npm install axios@1.15.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, you can implement a check in your application to limit the depth of nested objects before passing them to Axios. Here is an example of how you might do this:
function limitDepth(obj, maxDepth, currentDepth = 0) {
if (currentDepth > maxDepth) {
throw new Error('Maximum nesting depth exceeded');
}
for (const key in obj) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
limitDepth(obj[key], maxDepth, currentDepth + 1);
}
}
}
// Usage
try {
limitDepth(req.body, 100);
// Limit to 100 levels
await axios.post('https://upstream/api', req.body);
} catch (e) {
console.error(e.message);
}
Conclusion
The vulnerability identified as CVE-2026-42039 in Axios poses a significant risk due to unbounded recursion in the toFormData function, which can lead to denial of service attacks. It is crucial to update to the patched version or implement workarounds to safeguard your applications.
See every vulnerability recorded for axios →
FAQ
The CVSS score of this vulnerability is 7.5, indicating a moderate severity level.
You can use Vulert to monitor and alert in real-time for open-source vulnerabilities in your software. Check your application against the vulnerability using the Vulert playground without any signup.
Axios versions prior to 1.15.1 and 0.31.0 are affected by this vulnerability.
If left unaddressed, this vulnerability can lead to denial of service attacks, causing your application to crash when processing deeply nested request data.
Yes, you can implement a depth limit check in your application to prevent deeply nested objects from being processed by Axios.
References
Related vulnerabilities
Recent vulnerabilities recorded for axios.