Summary
Axios, a popular HTTP client for browsers and Node.js, contains a gadget-style attack chain that allows existing Prototype Pollution bugs in third‑party dependencies to be escalated into powerful network‑level attacks.
When Axios is used in polluted runtime environments, crafted requests can be turned into Remote Code Execution or full cloud compromise via AWS IMDSv2 bypass.
Affected context
This vulnerability arises when Axios is used in environments where:
- The JavaScript runtime or object prototypes can be polluted by another vulnerability
- Axios is used on the server side (Node.js) to make outbound HTTP requests to internal or cloud metadata services
- Application logic constructs requests dynamically from partially untrusted data (e.g., URLs, headers, or options coming from user-controllable sources)
The issue affects applications that treat Axios as a building block in larger systems; Axios itself acts as a gadget that can be driven by prior Prototype Pollution to reach sensitive internal services or inject crafted headers.
Exploit preconditions
- Attack surface: Server-side Axios usage (Node.js services, backends, serverless functions, or microservices) that make HTTP(S) requests to internal services or cloud infrastructure endpoints.
- Required access:
- A separate Prototype Pollution vulnerability in the application or a dependency, allowing an attacker to corrupt global or shared objects used as Axios configuration sources.
- Ability to influence request parameters (URL, headers, method, or config objects) that Axios consumes.
- Trigger point: Any code path that:
- Uses polluted objects or prototypes to build Axios request configuration, or
- Relies on Axios' default behaviors that read from polluted structures when constructing headers or target URLs.
- Why exploitation is possible: Axios' request handling and header construction can be coerced—via polluted prototypes—into:
- Issuing SSRF requests to attacker-chosen internal targets, and
- Manipulating headers in ways that bypass cloud metadata protections (e.g., IMDSv2) and potentially enable code execution on the instance.
Why this happens
The core issue is that Axios, like many HTTP abstraction libraries, assumes its configuration objects and environment are trustworthy and does not defend against Prototype Pollution by design.
In a polluted environment, inherited properties on configuration objects (e.g., Object.prototype) can be interpreted as legitimate Axios options, URLs, or headers.
This maps primarily to:
- CWE-918: Server-Side Request Forgery (SSRF), as Axios can be driven to contact internal or metadata endpoints.
- CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting'), due to unsafe use or interpretation of header values.
- CWE-444: Inconsistent Interpretation of HTTP Requests ('HTTP Request Smuggling'), where crafted header and request combinations may be interpreted differently by intermediaries.
Axios effectively becomes a gadget that an attacker can chain after a Prototype Pollution flaw to escalate from data corruption to high‑impact network‑level compromise.
Potential impact
- Remote Code Execution on cloud instances by abusing access to metadata services and credentials.
- Full cloud account or role compromise via AWS IMDSv2 bypass and subsequent credential theft.
- Server-Side Request Forgery against internal services, control planes, or management endpoints.
- Exfiltration of sensitive configuration, tokens, and secrets reachable from the vulnerable service.
- Pivoting within internal networks, enabling lateral movement and broader service compromise.
- Abuse of internal-only APIs leading to data tampering, privilege escalation, or service disruption.
General mitigation guidance
Effective mitigation typically focuses on reducing Axios' exposure to polluted configuration and hardening its use as a network primitive, rather than relying on version-specific fixes:
- Treat Axios configs as untrusted input:
- Construct Axios configuration objects using fresh, plain objects rather than merging in global or shared structures.
- Avoid
Object.assignor spread operations with data that may originate from user input or third-party libraries. - Constrain outbound network access:
- Enforce egress controls, such as network policies or firewall rules, to prevent Axios from reaching cloud metadata services and other sensitive internal endpoints.
- Use explicit allowlists for hostnames or IP ranges that Axios is permitted to contact.
- Harden header and URL handling:
- Normalize and validate URLs, methods, and headers before passing them into Axios.
- Reject or sanitize values that contain control characters, unsafe schemes, or internal-only hostnames when sourced from untrusted data.
- Reduce trust in the runtime environment:
- Limit or avoid libraries known for Prototype Pollution risk where possible; prefer well-maintained utilities that defend against polluted keys.
- Run services with least privilege and short-lived credentials so that any SSRF-based credential theft is less impactful.
- Defense-in-depth:
- Apply metadata service protections at the cloud/platform level (IMDS configuration, hop limits, or complete disablement where feasible).
- Separate roles and responsibilities so a single compromised service cannot directly administer your entire cloud environment.
How teams detect issues like this
Detecting this class of issue involves combining static analysis, code review, and runtime monitoring:
- Static analysis and linters:
- Flag patterns where Axios configuration objects are created by merging arbitrary objects (e.g.,
axios(configFromUser)or spreading request bodies/params into config). - Detect use of shared/global objects (including
process.envor app-wide config) being mutated before being passed to Axios. - Identify calls that build URLs or headers directly from user-controllable data without validation.
- Code review signals:
- Usage of generic merge utilities (
lodash.merge,deepMerge, custommergeConfig) that can propagate polluted prototypes into Axios configs. - Axios calls targeting internal URLs (e.g.,
169.254.169.254, metadata endpoints, admin services) without strict guardrails. - Patterns where the same object is reused across requests or modules, especially if it's enriched from request data.
- Runtime and operational monitoring:
- Monitor outbound traffic from services using Axios for anomalous destinations, particularly metadata endpoints and internal admin interfaces.
- Use WAFs, service meshes, or egress proxies to log and optionally block suspicious SSRF-like traffic.
- Automated review tools:
- Incorporate SAST tools into CI that understand Prototype Pollution sinks and HTTP client gadget patterns.
- Use dependency scanning and SBOM analysis to track libraries commonly associated with Prototype Pollution and ensure they're not feeding Axios configuration inadvertently.

