Skip to content
Threat Feed
critical advisory

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

  1. An attacker identifies a prototype pollution vulnerability in a separate library (e.g., qs, minimist, lodash, body-parser) used by the application.
  2. The attacker exploits this vulnerability to inject a malicious proxy configuration into Object.prototype.proxy, specifying the attacker’s proxy server address and port.
  3. The application makes an HTTP request using Axios, without explicitly configuring a proxy.
  4. Axios’ HTTP adapter at lib/adapters/http.js attempts to resolve the config.proxy value.
  5. Due to the absence of a proxy property in Axios’ default configuration, JavaScript traverses the prototype chain and finds the polluted Object.prototype.proxy value.
  6. The setProxy() function uses the malicious proxy configuration to route the HTTP request through the attacker’s proxy server.
  7. The attacker intercepts the request, gaining access to all request headers, including sensitive information like Authorization tokens.
  8. 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.prototype property modifications (see below).
  • Update to a patched version of Axios when one becomes available with a fix addressing hasOwnProperty checks or null-prototype object usage for merged configurations.
  • As a temporary measure, if possible, ensure the proxy configuration is explicitly set in Axios configurations to prevent prototype traversal.

Detection coverage 3

Detect Prototype Pollution via Object.prototype Modification

medium

Detects attempts to modify the Object.prototype, which can be indicative of prototype pollution attacks.

sigma tactics: initial_access techniques: T1059.007, T1190 sources: process_creation, windows

Detect Inbound Network Connection to Unusual High Port

low

Detects inbound network connections to a high port (over 1024) on a host, potentially indicating an attacker-controlled proxy listening for intercepted traffic.

sigma tactics: command_and_control techniques: T1071.001 sources: network_connection, windows

Detect Proxy Setting Modification via process

medium

Detects attempts to set a proxy configuration by modifying the Object prototype, which may be indicative of prototype pollution attacks abusing proxy configuration

sigma tactics: initial_access techniques: T1190 sources: process_creation, windows

Detection queries are available on the platform. Get full rules →