CVE-2026-42039 — Axios: unbounded recursion in axios — CVE Details
Axios: unbounded recursion in toFormData causes DoS via deeply nested request data
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.00%). Schedule for your next planned update.
Does your project use an affected axios version?
Paste your package-lock.json to check it for CVE-2026-42039 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
toFormData recursively walks nested objects with no depth limit, so a deeply nested value passed as request data crashes the Node.js process with a RangeError.
Details
lib/helpers/toFormData.js:210 defines an inner build(value, path) that recurses into every object/array child (line 225: build(el, path ? path.concat(key) : [key])). The only safeguard is a stack array used to detect circular references; there is no maximum depth and no try/catch around the recursion. Because build calls itself once per nesting level, a payload nested roughly 2000+ levels deep exhausts V8's call stack.
toFormData is the serializer behind FormData request bodies and AxiosURLSearchParams (used by buildURL when params is an object with URLSearchParams unavailable, see lib/helpers/buildURL.js:53 and lib/helpers/AxiosURLSearchParams.js:36). Any server-side code that forwards a client-supplied object into axios({ data, params }) therefore reaches the recursive walker with attacker-controlled depth.
The RangeError is thrown synchronously from inside forEach, escapes toFormData, and propagates out of the axios request call. In typical Express/Fastify request handlers this terminates the running request; in synchronous startup paths or worker threads it can crash the whole process.
PoC
import toFormData from 'axios/lib/helpers/toFormData.js';
import FormData from 'form-data';
function nest(depth) {
let o = { leaf: 1 };
for (let i = 0; i < depth; i++) o = { a: o };
return o;
}
try {
toFormData(nest(2500), new FormData());
} catch (e) {
console.log(e.name + ': ' + e.message);
}
// RangeError: Maximum call stack size exceeded
Server-side reachability example:
// vulnerable proxy pattern
app.post('/forward', async (req, res) => {
await axios.post('https://upstream/api', req.body); // req.body user-controlled
res.send('ok');
});
// attacker POST /forward with {"a":{"a":{"a":... 2500 deep ...}}}
// -> toFormData build() overflows -> request handler crashes
Verified on axios 1.15.0 (latest, 2026-04-10), Node.js 20, 3/3 PoC runs reproduce the RangeError at depth 2500.
Impact
A remote, unauthenticated attacker who can influence an object passed to axios as request data or params triggers an uncaught RangeError inside the synchronous recursive walker. In server-side applications that proxy or re-send client JSON through axios this crashes the request handler and, in worker/cluster setups, the process. Fix by bounding recursion depth in toFormData's build function (reject or throw on depths beyond a configurable limit, e.g. 100) or rewriting the walker iteratively.
Advisory Timeline
- First published May 5, 2026 (205 days ago).
- Last revised September 10, 2026 — 128 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install axios@1.15.1
npm install axios@0.31.1
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: npm (1).
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-674
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
- https://github.com/axios/axios/security/advisories/GHSA-62hf-57xw-28j9WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-42039ADVISORY
- https://github.com/axios/axios/commit/85132ffba1a77609ea5d101c8a413dea7174932fWEB
- https://github.com/axios/axiosPACKAGE
- https://github.com/axios/axios/releases/tag/v1.15.1WEB
Frequently Asked Questions
- What is CVE-2026-42039?
- Axios: unbounded recursion in toFormData causes DoS via deeply nested request data. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2026-42039?
- CVE-2026-42039 affects axios. It has a 1.0% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-42039 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is an above-median EPSS score — 61.9% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-42035HIGH
Axios: Header Injection via Prototype Pollution
- CVE-2026-44488HIGH
Allocation of Resources Without Limits or Throttling in Axios
- CVE-2026-101909HIGH
Axios: Prototype Pollution Gadget in axios toFormData Options
- CVE-2026-67319MEDIUM
Axios: Nested axios option objects can consume polluted prototype values
- CVE-2026-44490MEDIUM
axios has DoS & Header Injection via Prototype Pollution Read-Side Gadgets in axios merge functions
- CVE-2023-45857MEDIUM
Axios Cross-Site Request Forgery Vulnerability
- CVE-2026-67314MEDIUM
Axios: Prototype pollution auth subfields can inject Basic auth
- CVE-2026-42040LOW
Axios: Null Byte Injection via Reverse-Encoding in AxiosURLSearchParams