Axios Prototype Pollution Leads to Man-in-the-Middle Vulnerability
Axios is vulnerable to a Prototype Pollution attack that can be escalated into a full Man-in-the-Middle (MITM) attack by injecting a malicious proxy configuration via `Object.prototype.proxy`, allowing attackers to intercept, read, and modify all HTTP traffic, including authentication credentials.
The Axios library is vulnerable to a critical Prototype Pollution attack that allows an attacker to achieve a full Man-in-the-Middle (MITM) position. By polluting the Object.prototype.proxy property, an attacker can force Axios to route all HTTP requests through an attacker-controlled proxy server, enabling the interception, reading, and modification of all HTTP traffic, including sensitive information like authentication credentials. This vulnerability exists because the proxy property is not defined in Axios’ default configuration, causing the library to traverse the prototype chain when resolving the config.proxy value. This allows an attacker to inject a malicious proxy configuration, leading to the MITM attack. All versions of Axios are affected.
Attack Chain
- An attacker identifies a prototype pollution vulnerability in a separate library (e.g.,
qs,minimist,lodash,body-parser) used by the application. - The attacker exploits this vulnerability to inject a malicious proxy configuration into
Object.prototype.proxy, specifying the attacker’s proxy server address and port. - The application makes an HTTP request using Axios, without explicitly configuring a proxy.
- Axios’ HTTP adapter at
lib/adapters/http.jsattempts to resolve theconfig.proxyvalue. - Due to the absence of a
proxyproperty in Axios’ default configuration, JavaScript traverses the prototype chain and finds the pollutedObject.prototype.proxyvalue. - The
setProxy()function uses the malicious proxy configuration to route the HTTP request through the attacker’s proxy server. - The attacker intercepts the request, gaining access to all request headers, including sensitive information like
Authorizationtokens. - The attacker can modify the request or response before forwarding it to the intended destination, completing the MITM attack.
Impact
Successful exploitation of this vulnerability allows an attacker to intercept all HTTP traffic generated by the Axios library within an application. This includes sensitive information such as Authorization headers containing credentials, cookies, API keys, and request bodies. The attacker can also modify responses, inject malicious data, and redirect authentication flows. The attack is invisible to the developer, as requests appear to complete normally with attacker-controlled responses. This could lead to complete compromise of application data, including internal API keys, session tokens, and user passwords.
Recommendation
- Apply mitigations to prevent prototype pollution in your application’s dependencies to prevent this issue from being exploitable (CWE-1321).
- Deploy the Sigma rule to detect prototype pollution attempts by monitoring
Object.prototypeproperty modifications (see below). - Update to a patched version of Axios when one becomes available with a fix addressing
hasOwnPropertychecks or null-prototype object usage for merged configurations. - As a temporary measure, if possible, ensure the
proxyconfiguration is explicitly set in Axios configurations to prevent prototype traversal.
Detection coverage 3
Detect Prototype Pollution via Object.prototype Modification
mediumDetects attempts to modify the Object.prototype, which can be indicative of prototype pollution attacks.
Detect Inbound Network Connection to Unusual High Port
lowDetects inbound network connections to a high port (over 1024) on a host, potentially indicating an attacker-controlled proxy listening for intercepted traffic.
Detect Proxy Setting Modification via process
mediumDetects attempts to set a proxy configuration by modifying the Object prototype, which may be indicative of prototype pollution attacks abusing proxy configuration
Detection queries are available on the platform. Get full rules →