CVE-2026-42039: Axios Unbounded Recursion in toFormData Leads to DoS via Deeply Nested Request Data

axios Updated 05 May 2026

Summary

05/05/2026
Yes i
Moderate
7.5

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 ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

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.1 0.31.1
    npm install axios@0.31.1
  • >= 1.0.0, < 1.15.1 1.15.1
    npm 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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for axios.

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.1 0.31.1
    npm install axios@0.31.1
  • >= 1.0.0, < 1.15.1 1.15.1
    npm 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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback