CVE-2026-42039: Axios: unbounded recursion in toFormData causes DoS via deeply nested request data

Published Apr 24, 2026
·
Updated

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 js 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: js // 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.

Other sources

Axios is a promise based HTTP client for the browser and Node.js. Prior to 1.15.1 and 0.31.1, 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. This vulnerability is fixed in 1.15.1 and 0.31.1.

MITRE

Affected Software

7 affected componentsFixes available
npm/axios<1.15.1, <0.31.1
npm/axios<=0.31.0
0.31.1
npm/axios>=1.0.0<1.15.1
1.15.1
Axios Axios Node.js<0.31.1
Axios Axios Node.js>=1.0.0<1.15.1
IBM Db2 Genius Hub<=1.1, 1.1.1, 1.1.2
IBM Agentics<=1.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/axios to a version that resolves this vulnerability.

    Fixed in 0.31.1
  2. Upgrade

    Upgrade npm/axios to a version that resolves this vulnerability.

    Fixed in 1.15.1
  3. Upgrade

    Upgrade axios to a version that resolves this vulnerability.

    Fixed in 1.15.1
  4. Upgrade

    Upgrade axios to a version that resolves this vulnerability.

    Fixed in 0.31.1

Event History

Apr 24, 2026
CVE Published
via MITRE·06:01 PM
Data Sourced
via MITRE·06:01 PM
DescriptionWeakness
Data Sourced
via NVD·06:16 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Red Hat·07:02 PM
DescriptionSeverityAffected Software
May 5, 2026
Advisory Published
via GitHub·12:34 AM
Data Sourced
via GitHub·12:34 AM
DescriptionSeverityWeaknessAffected Software
Jul 13, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-42039?

CVE-2026-42039 has been classified as a Denial of Service vulnerability due to unbounded recursion.

2

How do I fix CVE-2026-42039?

To fix CVE-2026-42039, update Axios to version 1.15.1 or higher, or 0.31.1 or higher.

3

What causes CVE-2026-42039?

CVE-2026-42039 is caused by the toFormData function recursively processing deeply nested objects without a depth limit.

4

Who is affected by CVE-2026-42039?

Developers using Axios versions prior to 1.15.1 or 0.31.1 are affected by CVE-2026-42039.

5

What is the impact of CVE-2026-42039?

The impact of CVE-2026-42039 is a potential Denial of Service due to application crashes from deeply nested request data.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203