Back to Blog
high SEVERITY8 min read

How Denial of Service via __proto__ Key happens in Axios and how to fix it

A high-severity denial of service vulnerability (CVE-2026-25639) was discovered in Axios versions prior to 1.13.5, where the `mergeConfig` function failed to properly sanitize the `__proto__` key in configuration objects. This prototype pollution vulnerability could allow attackers to crash Node.js applications or cause unexpected behavior by manipulating JavaScript's prototype chain. The fix involved upgrading from Axios 1.13.2 to 1.18.0, which includes enhanced input validation in the configur

O
By Orbis AppSec
Published August 18, 2026Reviewed August 18, 2026

Answer Summary

CVE-2026-25639 is a prototype pollution denial of service vulnerability in Axios (CWE-1321) affecting versions before 1.13.5 and 0.30.3. The vulnerability exists in the `mergeConfig` function, which fails to sanitize the `__proto__` key when merging configuration objects, allowing attackers to pollute JavaScript's prototype chain and cause application crashes or unexpected behavior. The fix requires upgrading Axios from 1.13.2 to 1.18.0 (or 0.30.3 for the legacy branch), which implements proper prototype key filtering and adds the `https-proxy-agent` dependency for enhanced security controls.

Vulnerability at a Glance

cweCWE-1321 (Improperly Controlled Modification of Object Prototype Attributes)
fixUpgrade to Axios 1.18.0 with enhanced prototype key filtering
riskApplication crashes, memory exhaustion, or unexpected behavior through prototype chain manipulation
languageJavaScript/Node.js
root causeAxios mergeConfig function accepts __proto__ key without sanitization
vulnerabilityPrototype Pollution leading to Denial of Service

Introduction

In a Node.js application's package-lock.json, we discovered a high-severity prototype pollution vulnerability in Axios 1.13.2. The vulnerability, tracked as CVE-2026-25639, exists in Axios's mergeConfig function, which handles the merging of HTTP client configuration objects. When processing configuration objects containing the special __proto__ key, Axios fails to sanitize this dangerous property, allowing attackers to pollute JavaScript's prototype chain and trigger denial of service conditions.

This matters because Axios is one of the most widely used HTTP clients in the JavaScript ecosystem, with millions of downloads per week. Any application using Axios to make HTTP requests with user-influenced configuration—whether through API parameters, environment variables, or configuration files—could be vulnerable to this attack pattern.

The Vulnerability Explained

Prototype pollution is a JavaScript-specific vulnerability that exploits the language's prototype-based inheritance model. In JavaScript, nearly all objects inherit from Object.prototype, and modifying this prototype affects every object in the application.

The vulnerable code path exists in Axios's configuration merging logic. When Axios merges configuration objects (for example, combining default settings with request-specific options), it performs a recursive merge without properly filtering dangerous keys. Here's what happens:

// Vulnerable pattern in Axios 1.13.2 mergeConfig
function mergeConfig(config1, config2) {
  // Simplified representation of the vulnerable logic
  const result = {};
  for (const key in config2) {
    // No check for __proto__, constructor, or prototype
    result[key] = config2[key];
  }
  return result;
}

The specific problem is that when config2 contains a __proto__ key, this code inadvertently modifies the prototype chain rather than just setting a property on the result object. An attacker could exploit this by providing a malicious configuration object:

const maliciousConfig = {
  url: 'https://api.example.com',
  __proto__: {
    isAdmin: true,
    polluted: 'This affects all objects!'
  }
};

axios.request(maliciousConfig);
// Now ALL objects in the application inherit { isAdmin: true, polluted: '...' }

Real-World Attack Scenario

Consider an application that allows users to configure HTTP request settings through an API:

// Vulnerable application code using Axios 1.13.2
app.post('/api/fetch-data', async (req, res) => {
  const userConfig = req.body.requestConfig; // User-controlled input

  try {
    const response = await axios.request({
      baseURL: 'https://internal-api.example.com',
      ...userConfig  // Merges user configuration
    });
    res.json(response.data);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

An attacker could send a POST request with this payload:

{
  "requestConfig": {
    "timeout": 5000,
    "__proto__": {
      "isAdmin": true,
      "toString": null
    }
  }
}

This attack would:
1. Pollute the prototype chain: Every object in the application now has isAdmin: true
2. Break core functionality: Setting toString to null causes crashes when any code calls .toString() on objects
3. Cause denial of service: The application becomes unstable, with errors cascading through unrelated components
4. Persist across requests: In Node.js, the polluted prototype affects all subsequent requests until the process restarts

The impact is severe because the pollution affects the entire JavaScript runtime, not just the Axios configuration. This can lead to application crashes, memory leaks, authentication bypasses (if security checks rely on object properties), and complete service disruption.

The Fix

The fix involved upgrading Axios from version 1.13.2 to 1.18.0, which implements comprehensive prototype pollution protections. Let's examine the specific changes in package-lock.json:

Before (Vulnerable):

"node_modules/axios": {
  "version": "1.13.2",
  "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz",
  "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==",
  "dependencies": {
    "follow-redirects": "^1.15.6",
    "form-data": "^4.0.4",
    "proxy-from-env": "^1.1.0"
  }
}

After (Patched):

"node_modules/axios": {
  "version": "1.18.0",
  "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.0.tgz",
  "integrity": "sha512-E32NzpYKp++W7XRe52rHiXV2ehxmh3wbdgO7MHeFM+vqxLBYHzt0ElkiImtOBxtOmyp0yoC8C6uESVV84Y2/hw==",
  "license": "MIT",
  "dependencies": {
    "follow-redirects": "^1.16.0",
    "form-data": "^4.0.5",
    "https-proxy-agent": "^5.0.1",
    "proxy-from-env": "^2.1.0"
  }
}

Key Security Improvements

The upgrade to Axios 1.18.0 introduces several critical security enhancements:

  1. Prototype Key Filtering: The mergeConfig function now explicitly checks for and rejects dangerous keys like __proto__, constructor, and prototype before performing merges.

  2. Enhanced Dependency Security:
    - follow-redirects upgraded from 1.15.6 to 1.16.0 (includes security patches)
    - form-data upgraded from 4.0.4 to 4.0.5 (improved boundary handling)
    - proxy-from-env upgraded from 1.1.0 to 2.1.0 (better environment variable parsing)
    - New dependency https-proxy-agent 5.0.1 added (provides secure proxy handling with additional validation)

  3. Safe Object Creation: The patched version uses Object.create(null) for internal configuration objects, creating objects without a prototype chain that can't be polluted.

The addition of agent-base 6.0.2 and https-proxy-agent 5.0.1 as new dependencies provides an additional security layer. These packages implement secure proxy handling with built-in validation that prevents configuration injection attacks:

"node_modules/agent-base": {
  "version": "6.0.2",
  "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
  "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
  "license": "MIT",
  "dependencies": {
    "debug": "4"
  }
}

The fix is scoped to package.json and package-lock.json, ensuring that all instances of Axios in the dependency tree are upgraded. This approach prevents version conflicts and ensures comprehensive protection across the entire application.

How the Patched Code Prevents the Attack

In Axios 1.18.0, the mergeConfig function now includes explicit prototype pollution prevention:

// Patched mergeConfig in Axios 1.18.0 (conceptual representation)
function mergeConfig(config1, config2) {
  const result = Object.create(null); // No prototype chain

  for (const key in config2) {
    // Explicitly block dangerous keys
    if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
      continue; // Skip dangerous keys
    }
    result[key] = config2[key];
  }
  return result;
}

This change ensures that even if an attacker provides a malicious configuration object with __proto__ keys, those keys are filtered out before the merge operation, completely preventing prototype pollution.

Prevention & Best Practices

To prevent prototype pollution vulnerabilities in your JavaScript applications:

1. Keep Dependencies Updated

Regularly audit and update dependencies, especially security-critical libraries like HTTP clients. Use automated tools to monitor for CVEs:

npm audit
npm outdated

2. Validate Configuration Objects

When accepting user input that influences configuration objects, implement strict validation:

function sanitizeConfig(userConfig) {
  const dangerousKeys = ['__proto__', 'constructor', 'prototype'];
  const sanitized = {};

  for (const key in userConfig) {
    if (dangerousKeys.includes(key)) {
      throw new Error(`Forbidden key: ${key}`);
    }
    sanitized[key] = userConfig[key];
  }

  return sanitized;
}

// Use sanitized config with Axios
const safeConfig = sanitizeConfig(req.body.requestConfig);
const response = await axios.request(safeConfig);

3. Use Safe Object Creation

When creating dictionary-like objects, use Object.create(null) to avoid prototype chain issues:

const config = Object.create(null);
config.timeout = 5000;
config.headers = { 'Content-Type': 'application/json' };
// This object has no prototype, preventing pollution

4. Implement Object Freezing

For critical configuration objects, use Object.freeze() to prevent modifications:

const baseConfig = Object.freeze({
  baseURL: 'https://api.example.com',
  timeout: 10000,
  headers: { 'User-Agent': 'MyApp/1.0' }
});

// Any attempt to modify this object will fail silently (or throw in strict mode)

5. Use Static Analysis Tools

Integrate tools that can detect prototype pollution patterns:

  • Semgrep: Rules for detecting unsafe object merging patterns
  • ESLint: Plugins like eslint-plugin-security for security anti-patterns
  • Snyk: Dependency vulnerability scanning with automated fix PRs
  • Trivy: Container and dependency scanning for CVEs

6. Follow OWASP Guidelines

Refer to OWASP's guidance on prototype pollution:
- Validate all external input before using it in object operations
- Use allowlists for permitted configuration keys
- Avoid recursive merge operations on untrusted data
- Implement Content Security Policy (CSP) to limit damage from successful attacks

7. Implement Defense in Depth

Combine multiple protective layers:

// Layer 1: Input validation
const allowedKeys = ['url', 'method', 'timeout', 'headers', 'data'];
const validatedConfig = Object.keys(userInput)
  .filter(key => allowedKeys.includes(key))
  .reduce((obj, key) => {
    obj[key] = userInput[key];
    return obj;
  }, {});

// Layer 2: Use patched library
const response = await axios.request(validatedConfig);

// Layer 3: Error handling
try {
  // Process response
} catch (error) {
  logger.error('Request failed', { error, config: validatedConfig });
  // Don't expose internal details to user
  throw new Error('Request failed');
}

Key Takeaways

  • Axios 1.13.2's mergeConfig function fails to sanitize __proto__ keys, allowing prototype chain pollution that affects all objects in the Node.js runtime
  • CVE-2026-25639 is exploitable through any code path that merges user-controlled data into Axios configuration objects, including API endpoints, environment variables, or configuration files
  • Upgrading to Axios 1.18.0 is essential as it implements explicit filtering of dangerous prototype keys (__proto__, constructor, prototype) in configuration merging logic
  • The fix includes critical dependency updates: follow-redirects 1.16.0, form-data 4.0.5, proxy-from-env 2.1.0, and adds https-proxy-agent 5.0.1 for enhanced security controls
  • Prototype pollution attacks can cause cascading failures across unrelated application components, making this vulnerability particularly dangerous in production environments where a single malicious request can crash the entire service

How Orbis AppSec Detected This

  • Source: User-controlled configuration objects merged into Axios request settings, potentially from HTTP request bodies, query parameters, or environment variables
  • Sink: axios.request() and related methods in application code that utilize the vulnerable mergeConfig function in Axios 1.13.2
  • Missing control: No sanitization of prototype pollution keys (__proto__, constructor, prototype) before configuration object merging; Axios 1.13.2 lacks built-in prototype key filtering
  • CWE: CWE-1321 (Improperly Controlled Modification of Object Prototype Attributes)
  • Fix: Upgraded Axios from 1.13.2 to 1.18.0, which implements explicit prototype key filtering in mergeConfig and includes enhanced proxy handling via https-proxy-agent 5.0.1

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

CVE-2026-25639 demonstrates how seemingly innocuous configuration merging logic can create severe security vulnerabilities in widely-used libraries. The prototype pollution vulnerability in Axios 1.13.2 could allow attackers to trigger denial of service conditions by polluting JavaScript's prototype chain through the __proto__ key in configuration objects.

The fix—upgrading to Axios 1.18.0—is straightforward but critical. This version implements comprehensive prototype pollution protections, including explicit filtering of dangerous keys and enhanced dependency security. Beyond applying this specific patch, developers should adopt defensive coding practices: validate all user input before using it in object operations, use safe object creation patterns, keep dependencies updated, and implement multiple layers of security controls.

Prototype pollution vulnerabilities are particularly insidious because they can affect seemingly unrelated parts of an application, making them difficult to debug and potentially catastrophic in production. By understanding this attack pattern and implementing proper protections, you can build more resilient JavaScript applications that withstand sophisticated attacks.

References

Frequently Asked Questions

What is prototype pollution in Axios?

Prototype pollution in Axios occurs when the `mergeConfig` function merges configuration objects containing the `__proto__` key without sanitization, allowing attackers to modify JavaScript's Object prototype and affect all objects in the application, potentially causing denial of service or unexpected behavior.

How do you prevent prototype pollution in JavaScript applications?

Prevent prototype pollution by validating and sanitizing object keys before merging, using `Object.create(null)` for dictionaries, implementing allowlists for permitted keys, avoiding recursive merge operations on untrusted input, and keeping dependencies like Axios updated to versions with built-in protections.

What CWE is prototype pollution?

Prototype pollution is classified as CWE-1321 (Improperly Controlled Modification of Object Prototype Attributes), which describes vulnerabilities where an attacker can modify an object's prototype attributes, affecting all instances that inherit from that prototype.

Is input validation enough to prevent prototype pollution in Axios?

While input validation helps, it's not sufficient on its own. The most reliable protection is upgrading to patched Axios versions (1.13.5+, 0.30.3+) that implement built-in prototype key filtering in `mergeConfig`. Combining library updates with application-level validation of configuration objects provides defense in depth.

Can static analysis detect prototype pollution vulnerabilities?

Yes, static analysis tools like Trivy, Snyk, and npm audit can detect known prototype pollution CVEs in dependencies by scanning package-lock.json. Advanced tools like Semgrep can also identify unsafe merge patterns in custom code, though library-level vulnerabilities like CVE-2026-25639 require dependency scanning.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #339

Related Articles

high

How Proxy-Authorization Header Leakage Happens in Axios and How to Fix It

A high-severity vulnerability (CVE-2026-44486) in Axios versions prior to 1.16.0 caused Proxy-Authorization headers to leak to redirect targets when the HTTP client re-evaluated proxy settings and switched to a direct connection. This information disclosure bug exposed sensitive proxy credentials to unintended destinations, and was fixed by upgrading from Axios 1.15.2 to 1.18.0 in the client application.

high

How Prototype Pollution Enables HTTP Header Injection in Axios and How to Fix It

Axios versions prior to 1.18.0 contained a prototype pollution vulnerability that could allow attackers to inject arbitrary HTTP headers into requests. This vulnerability was fixed by upgrading to version 1.18.0, which includes enhanced input validation and updated proxy handling dependencies. Organizations using the affected versions should update immediately to prevent potential man-in-the-middle attacks and header injection exploits.

high

How Arbitrary HTTP Header Injection via Prototype Pollution happens in JavaScript and how to fix it

A high-severity vulnerability (CVE-2026-42035) in axios version 1.13.5 allowed attackers to inject arbitrary HTTP headers through prototype pollution. The fix upgrades axios to version 1.18.0 in the frontend's dependency tree, which includes proper prototype chain validation when constructing HTTP request headers. This prevents attackers from manipulating outgoing requests to perform SSRF, session hijacking, or cache poisoning attacks.

high

How NO_PROXY bypass via crafted URL happens in Node.js axios and how to fix it

A high-severity vulnerability (CVE-2026-42043) in the axios HTTP client library allowed attackers to bypass NO_PROXY environment variable restrictions using specially crafted URLs. This could route sensitive internal traffic through attacker-controlled proxy servers. The fix upgrades axios from 1.13.6 to 1.18.0, which includes a rewritten proxy resolution mechanism using `proxy-from-env` v2.1.0 and the `https-proxy-agent` package.

critical

How Prototype Pollution Denial of Service Happens in Node.js HTTP Libraries and How to Fix It

A critical prototype pollution vulnerability in axios versions 1.12.0 and earlier could allow attackers to trigger denial of service attacks by poisoning the configuration object through the `__proto__` key. The vulnerability was fixed by upgrading axios to 1.13.5 and updating related dependencies like follow-redirects to 1.16.0, which implements stricter input validation in the mergeConfig function.

high

How Information Disclosure and DoS via malformed Cache-Control directives happens in Node.js undici and how to fix it

A high-severity vulnerability (CVE-2026-13697) in the undici HTTP client library allowed attackers to trigger information disclosure and denial of service through malformed Cache-Control directives. The @jackwener/opencli project upgraded undici from version 7.24.6 to 7.29.0, eliminating the vulnerability in their dependency chain and protecting downstream consumers from exploitation.