Summary
Axios request configuration handling exposes prototype-pollution gadgets that can be triggered when Object.prototype has already been compromised by another flaw.
In affected versions, polluted prototype properties such as transformResponse may be interpreted as Axios configuration or validation logic, enabling attacker-influenced behavior whenever a request is created in the shared JavaScript process.
Affected context
This weakness appears in applications that:
- Use Axios versions between 0.19.0 and before 0.31.1, or before 1.15.2
- Run in environments where multiple libraries share the same JavaScript global objects
- Are already exposed to a separate vulnerability that allows modification of
Object.prototype
Under these conditions, Axios instances created after the prototype has been polluted may inherit attacker-controlled properties into their request configuration or option validation paths.
Exploit preconditions
- Attack surface: Any code path that uses Axios to make HTTP requests in a shared JavaScript runtime (browser or Node.js).
- Required access: Ability to execute JavaScript or otherwise introduce a prototype-pollution condition affecting
Object.prototype.transformResponse(or related keys) before Axios requests are constructed. - Trigger point: Creation or use of an Axios instance that processes configuration objects relying on inherited properties from
Object.prototype. - Why exploitation is possible: Axios configuration processing does not adequately guard against inherited properties on request config objects, so polluted prototype members may be treated as trusted configuration or validation callbacks.
Why this happens
The root cause is Axios relying on object properties without consistently constraining lookups to own properties, thereby creating prototype-pollution gadgets.
When another flaw has already modified Object.prototype, inherited fields such as transformResponse can be interpreted as legitimate Axios configuration or validation hooks.
This maps to:
- CWE-1321: Prototype Pollution, where shared object prototypes become implicit configuration channels.
- CWE-94: Code Injection, because attacker-controlled functions or expressions placed on the prototype may be invoked as part of Axios request processing, effectively executing injected behavior within the process.
Potential impact
- Axios may apply attacker-controlled
transformResponsefunctions to HTTP responses, enabling data tampering or exfiltration. - Malicious validation or option-processing logic could be invoked, altering request configuration, headers, or target URLs.
- Existing prototype-pollution issues could be escalated into more severe outcomes such as code injection or logic subversion in the HTTP client.
- Cross-component interference may occur, where one compromised library influences the behavior of independent Axios-based code.
General mitigation guidance
Effective mitigation focuses on reducing trust in inherited object state and isolating Axios configuration from global prototypes.
Typical defensive patterns include:
- Normalizing and cloning configuration inputs into plain objects that only consider own properties.
- Avoiding direct use of untrusted objects for options; instead, constructing configuration from validated, explicit fields.
- Running untrusted or multi-tenant code in isolated execution contexts so it cannot modify shared prototypes used by Axios.
- Adopting least-privilege coding practices, where callbacks and transformation logic are registered explicitly rather than inferred from ambient object properties.
Addressing broader prototype-pollution risks in the codebase further reduces the chance that such gadgets can be primed.
How teams detect issues like this
Detection efforts can combine code-level and runtime perspectives:
- Static analysis rules that flag use of configuration objects where inherited properties (from
Object.prototype) are consumed withouthasOwnPropertychecks or structured validation. - Code review checklists that prompt reviewers to look for libraries or helpers that interpret configuration via flexible object merging, spreading, or dynamic property access.
- Security linters or automated review tools configured to highlight uses of global prototypes in configuration paths and to detect known prototype-pollution sinks and gadgets.
- Runtime monitoring or testing strategies that intentionally contaminate prototypes in a controlled test environment to observe whether Axios-based code exhibits unexpected behavior.

