Axios: Excessive recursion in formDataToJSON can cause denial of service
Axios versions 0.28.0 and later contain a vulnerability in the formDataToJSON helper function that causes uncontrolled recursion when processing FormData field names with deeply nested bracket segments. This can lead to a denial of service by exhausting the JavaScript call stack and throwing a RangeError. The issue affects applications that convert attacker-controlled FormData to JSON, particularly when using axios.formToJSON() or sending FormData with Content-Type application/json. Normal multipart FormData requests without JSON serialization are not affected. The vulnerability can cause request failures and potentially process termination if exceptions are not handled.
AI Analysis
Technical Summary
Axios introduced a helper function formDataToJSON in version 0.28.0 that converts FormData to JSON by parsing field names into path segments and recursively building the JSON object. The recursion depth is unbounded, so a FormData field name with thousands of nested bracket segments causes excessive recursion, leading to a RangeError due to maximum call stack size exceeded. This vulnerability affects axios.formToJSON(), the default transformRequest when sending FormData as application/json, and the public formToJSON API. Axios does not currently enforce a maximum recursion depth in formDataToJSON, unlike its inverse serializer which has a maxDepth guard. The vulnerability primarily risks server-side applications processing untrusted FormData field names. Exploitation results in denial of service by crashing or rejecting requests before network I/O.
Potential Impact
Denial of service against applications that process untrusted FormData field names through axios' FormData-to-JSON conversion. Requests with deeply nested FormData keys cause a RangeError that can fail the request or terminate the process if unhandled. Normal FormData usage without JSON serialization is unaffected. The vulnerability does not allow code execution or data leakage but disrupts service availability.
Mitigation Recommendations
No official patch or fix is currently available. Applications should avoid converting attacker-controlled FormData to JSON using axios.formToJSON() or by sending FormData with Content-Type application/json. Validate and reject FormData field names with excessive nesting depth before conversion or sending. Avoid setting Content-Type to application/json for untrusted FormData to bypass the vulnerable code path. Catching the RangeError can prevent process termination but does not fix the underlying recursion issue and should not be relied on as the primary mitigation.
Axios: Excessive recursion in formDataToJSON can cause denial of service
Description
Axios versions 0.28.0 and later contain a vulnerability in the formDataToJSON helper function that causes uncontrolled recursion when processing FormData field names with deeply nested bracket segments. This can lead to a denial of service by exhausting the JavaScript call stack and throwing a RangeError. The issue affects applications that convert attacker-controlled FormData to JSON, particularly when using axios.formToJSON() or sending FormData with Content-Type application/json. Normal multipart FormData requests without JSON serialization are not affected. The vulnerability can cause request failures and potentially process termination if exceptions are not handled.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Axios introduced a helper function formDataToJSON in version 0.28.0 that converts FormData to JSON by parsing field names into path segments and recursively building the JSON object. The recursion depth is unbounded, so a FormData field name with thousands of nested bracket segments causes excessive recursion, leading to a RangeError due to maximum call stack size exceeded. This vulnerability affects axios.formToJSON(), the default transformRequest when sending FormData as application/json, and the public formToJSON API. Axios does not currently enforce a maximum recursion depth in formDataToJSON, unlike its inverse serializer which has a maxDepth guard. The vulnerability primarily risks server-side applications processing untrusted FormData field names. Exploitation results in denial of service by crashing or rejecting requests before network I/O.
Potential Impact
Denial of service against applications that process untrusted FormData field names through axios' FormData-to-JSON conversion. Requests with deeply nested FormData keys cause a RangeError that can fail the request or terminate the process if unhandled. Normal FormData usage without JSON serialization is unaffected. The vulnerability does not allow code execution or data leakage but disrupts service availability.
Mitigation Recommendations
No official patch or fix is currently available. Applications should avoid converting attacker-controlled FormData to JSON using axios.formToJSON() or by sending FormData with Content-Type application/json. Validate and reject FormData field names with excessive nesting depth before conversion or sending. Avoid setting Content-Type to application/json for untrusted FormData to bypass the vulnerable code path. Catching the RangeError can prevent process termination but does not fix the underlying recursion issue and should not be relied on as the primary mitigation.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-42h9-826w-cgv3
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["npm"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 4.0
Threat ID: 6a5e79ee2a4a8d59899bbfdd
Added to database: 07/20/2026, 19:41:34 UTC
Last enriched: 07/20/2026, 19:48:43 UTC
Last updated: 07/21/2026, 05:08:54 UTC
Views: 8
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.