/

CVE-2026-42035

Severity:

HIGH RISK

(7.4)

HTTP Header Injection / Response Splitting in Axios HTTP

CVE-2026-42035

Analyzed

Vulnerability type

Category:

HTTP Header Injection / Response Splitting

CWE:

CWE-113, CWE-1321

Impact:

Arbitrary HTTP Header Injection in Outgoing Requests

Severity:

HIGH RISK

(7.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Axios' Node.js HTTP adapter contains a prototype pollution gadget that can cause attacker-controlled HTTP headers to be injected into outgoing requests when the global Object prototype has been polluted.

By abusing duck-typed detection of FormData-like objects, an attacker who can influence Object.prototype can supply a malicious getHeaders() implementation, leading Axios to merge arbitrary headers into subsequent HTTP requests under specific conditions.

Affected context

This issue affects applications that:

  • Use Axios in environments where the Node.js HTTP adapter (lib/adapters/http.js) is active
  • Rely on shared JavaScript object prototypes (e.g., in typical Node.js runtimes or bundled server-side code)
  • Include Axios alongside other libraries that may introduce a prototype pollution primitive, even if Axios itself is not directly polluting prototypes

The vulnerability manifests when Axios processes a plain object as request data and its type detection logic interacts with a polluted Object.prototype.

Exploit preconditions

  • Attack surface: Any code path that sends HTTP requests using Axios in a Node.js context (HTTP adapter).
  • Required access: Ability to introduce or trigger a prototype pollution primitive that:
  • Modifies Object.prototype (or a shared ancestor) with properties like getHeaders, append, pipe, on, once, and Symbol.toStringTag
  • Provides an attacker-controlled implementation of getHeaders().
  • Trigger point: An outgoing Axios request where:
  • The data payload is a plain object, but due to polluted prototype methods, it is misclassified as a FormData-like object
  • Axios invokes data.getHeaders() and merges the returned object into the request headers.
  • Why exploitation is possible: The HTTP adapter relies on duck-typing and inherited methods to determine whether the payload behaves like a FormData instance. When Object.prototype is polluted with specific methods, the adapter treats arbitrary objects as FormData, calling an attacker-supplied getHeaders() that returns arbitrary headers, which Axios then injects into the request.

Why this happens

The underlying bug stems from a combination of unsafe duck-typing and trust in inherited object properties in a prototype-based language.

Instead of checking for a specific, trusted type or using robust feature detection on the actual instance, the Axios HTTP adapter inspects the presence of methods such as getHeaders, append, pipe, on, once, and Symbol.toStringTag. Because JavaScript objects inherit from Object.prototype, any pollution of that prototype can cause arbitrary plain objects to present these methods.

This results in a prototype pollution gadget: once any dependency or application code introduces attacker-controlled methods on Object.prototype, Axios' type check incorrectly identifies plain objects as FormData-like. It then calls getHeaders() and merges its return value into the outgoing request headers, mapping to:

  • CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers, as arbitrary header values can be introduced into requests, potentially enabling header injection if those values are not otherwise sanitized downstream.
  • CWE-1321: Prototype Pollution, as the gadget becomes exploitable when global object prototypes are modified, enabling unintended behavior in downstream code.

Potential impact

  • Injection of arbitrary custom HTTP headers into outgoing requests from the affected application
  • Manipulation of authentication or authorization headers (e.g., cookies, tokens, or API keys) if the attacker can control their names and values
  • Bypassing of security controls such as CSRF protections, origin-based checks, or internal routing rules that depend on trusted headers
  • Facilitating SSRF-style scenarios by influencing headers that control downstream behavior (e.g., host routing, internal feature flags)
  • Interference with logging, monitoring, or auditing systems that rely on consistent header formats

General mitigation guidance

Mitigation typically focuses on breaking the gadget pattern and reducing trust in inherited object properties:

  • Prefer strict type checks over duck-typing when differentiating between payload types such as FormData and plain objects, ensuring the adapter cannot be tricked by prototype modifications.
  • Avoid reading critical behavior from Object.prototype or other shared prototypes; instead, use Object.hasOwn() or similar techniques that only consider own properties.
  • Introduce defensive coding patterns that treat prototype pollution as an assumed risk in large dependency trees, especially when working in JavaScript/TypeScript environments.
  • Constrain where and how headers are derived from application inputs by centralizing header construction logic and avoiding implicit header merging from untrusted functions.
  • Employ defense-in-depth by limiting the power of individual headers where possible (e.g., having backend services re-validate sensitive headers instead of trusting client-provided ones).

How teams detect issues like this

Detection strategies can focus on both the gadget and the broader prototype pollution risk:

  • Static analysis: Configure rules to flag:
  • Duck-typed checks that rely on methods inherited from prototypes instead of explicit type checks
  • Usage of shared prototypes (Object.prototype) where behavior decisions (like header derivation) are made based on inherited methods.
  • Code review: Look for:
  • Any logic in HTTP adapters or networking layers that merges headers returned from user-influenced functions
  • Patterns where getHeaders() or similar methods are invoked on loosely-typed objects.
  • Runtime defenses: Implement:
  • Application-level guards that freeze or lock down Object.prototype in controlled environments where feasible
  • Monitoring around outgoing HTTP requests to detect unexpected or anomalous headers being sent, especially those not constructed by known code paths.
  • Tooling: Use automated security scanners and SAST tools configured to recognize prototype pollution sinks and gadgets, particularly in widely used HTTP clients and middleware.

Sources

SourceLink
github.comgithub.com/axios/axios/security/advisories/GHSA-6chq-wfr3-2hj9

Frequently asked

questions

It can be, but only when an attacker can drive a prototype pollution primitive first. If they can influence Object.prototype through a vulnerable dependency or application endpoint, they may indirectly control headers in outgoing Axios requests.

The attacker needs a way to introduce or trigger prototype pollution in the runtime environment. This often means exploiting another vulnerability in the application stack that allows modification of shared prototypes, rather than having direct access to Axios code itself.

The safest pattern is to remove reliance on prototype-based duck-typing in security-sensitive code paths and to ensure header construction is explicit and centralized. Only trusted, well-defined types should be allowed to provide headers, and their interfaces should not be inferred from inherited methods.

To prevent similar vulnerabilities, adopt development practices that treat prototype pollution as a first-class threat: avoid mutating global prototypes, enforce strict type checking around critical operations like header generation, and incorporate security reviews and automated checks that focus on gadget creation in shared libraries.

Find out what's already
exploitable in your codebase.