Axios HTTP Adapter Prototype Pollution Vulnerability
A prototype pollution vulnerability in the Axios HTTP adapter allows an attacker to inject arbitrary HTTP headers into outgoing requests by polluting the Object prototype with specific properties, leading to potential authentication bypass and privilege escalation.
A prototype pollution gadget exists within the Axios HTTP adapter (specifically in lib/adapters/http.js) that enables attackers to inject arbitrary HTTP headers into outgoing HTTP requests. The vulnerability arises from Axios’s reliance on duck-type checking of the data payload. If the Object.prototype is polluted with properties like getHeaders, append, pipe, on, once, and Symbol.toStringTag, Axios incorrectly identifies any plain object payload as a FormData instance. Consequently, Axios invokes the attacker-controlled getHeaders() function, merging the resulting headers into the outgoing request. The vulnerability affects Axios versions greater than or equal to 1.0.0 and less than 1.15.1, as well as versions 0.31.0 and earlier. Exploitation requires a prototype pollution primitive existing somewhere in the application’s dependency chain. Successful exploitation can lead to authentication bypass, session fixation, privilege escalation, and IP spoofing.
Attack Chain
- The attacker identifies a prototype pollution vulnerability within a dependency used by the target application (e.g., using
lodash.merge,qs, orJSON5). - The attacker injects malicious JavaScript code that pollutes the
Object.prototypewith the following properties and corresponding values:Symbol.toStringTagset to'FormData',appendas an empty function,getHeadersas a function returning attacker-controlled headers,pipeas a function, andonandonceas functions that returnthis. - The target application uses Axios to make an HTTP request (POST, PUT, or PATCH) with a data payload.
- Axios’s
lib/adapters/http.jsprocesses the data payload and performs duck-type checks usingutils.isFormDataandutils.isFunction(data.getHeaders). - Due to the prototype pollution, the
utils.isFormDatafunction incorrectly identifies the data payload as a FormData instance. - Axios then calls the attacker-controlled
getHeaders()function. - The attacker’s
getHeaders()function returns a set of malicious HTTP headers. - Axios merges these malicious headers into the outgoing HTTP request, potentially overwriting or adding sensitive headers. The request is sent to the target server.
Impact
Successful exploitation of this vulnerability can have significant consequences. Attackers can bypass authentication mechanisms by injecting arbitrary Authorization headers or escalate privileges by injecting X-Role or X-User-ID headers. Session fixation is also possible. IP spoofing and WAF bypass can also occur due to header injection. The potential impact could extend beyond a single service if Axios is used for service-to-service communication, where downstream services trust identity headers forwarded from upstream API gateways.
Recommendation
- Upgrade Axios to a patched version (>= 1.15.1 or > 0.31.0) to remediate CVE-2026-42035.
- Apply the provided patch to
lib/adapters/http.jsto include an explicit own-property check ongetHeadersas a short-term mitigation. - Implement input validation and sanitization to prevent prototype pollution vulnerabilities in the application’s dependencies, focusing on libraries like
lodash.merge,qs, andJSON5. - Review and restrict the usage of deep-merge utilities that process attacker-controlled input to minimize the risk of prototype pollution.
- If Axios is used in service-to-service communication, carefully evaluate the trust boundaries and the potential impact of injected headers on downstream services, considering a Scope Change as outlined in the advisory.
Detection coverage 2
Detect Prototype Pollution Gadget in Axios HTTP Requests
highDetects potential exploitation of the Axios prototype pollution vulnerability by monitoring outgoing HTTP requests for injected headers based on the vulnerable adapter code.
Detect Potential Prototype Pollution Attempts via getHeaders Modification
mediumDetects modifications to the getHeaders property of the Object prototype, indicative of a potential prototype pollution attempt targeting Axios.
Detection queries are kept inside the platform. Get full rules →