{"id":"CVE-2026-42035","aliases":["CVE-2026-42035","GHSA-6chq-wfr3-2hj9"],"related":[],"kind":"vulnerability","state":"published","title":"Axios: Header Injection via Prototype Pollution","summary":"Axios is a promise based HTTP client for the browser and Node.js. Prior to 1.15.1 and 0.31.1, a prototype pollution gadget exists in the Axios HTTP adapter (lib/adapters/http.js) that allows an attacker to inject arbitrary HTTP headers into outgoing requests. The vulnerability exploits duck-type checking of the data payload, where if Object.prototype is polluted with getHeaders, append, pipe, on, once, and Symbol.toStringTag, Axios misidentifies any plain object payload as a FormData instance and calls the attacker-controlled getHeaders() function, merging the returned headers into the outgoing request. The vulnerable code resides exclusively in lib/adapters/http.js. The prototype pollution source does not need to originate from Axios itself — any prototype pollution primitive in any dependency in the application's dependency tree is sufficient to trigger this gadget. This vulnerability is fixed in 1.15.1 and 0.31.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Axios is a promise based HTTP client for the browser and Node.js. Prior to 1.15.1 and 0.31.1, a prototype pollution gadget exists in the Axios HTTP adapter (lib/adapters/http.js) that allows an attacker to inject arbitrary HTTP headers into outgoing requests. The vulnerability exploits duck-type checking of the data payload, where if Object.prototype is polluted with getHeaders, append, pipe, on, once, and Symbol.toStringTag, Axios misidentifies any plain object payload as a FormData instance and calls the attacker-controlled getHeaders() function, merging the returned headers into the outgoing request. The vulnerable code resides exclusively in lib/adapters/http.js. The prototype pollution source does not need to originate from Axios itself — any prototype pollution primitive in any dependency in the application's dependency tree is sufficient to trigger this gadget. This vulnerability is fixed in 1.15.1 and 0.31.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nA prototype pollution gadget exists in the Axios HTTP adapter (lib/adapters/http.js) that allows an attacker to inject arbitrary HTTP headers into outgoing requests. The vulnerability exploits duck-type checking of the data payload, where if Object.prototype is polluted with getHeaders, append, pipe, on, once, and Symbol.toStringTag, Axios misidentifies any plain object payload as a FormData instance and calls the attacker-controlled getHeaders() function, merging the returned headers into the outgoing request.\n\nThe vulnerable code resides exclusively in lib/adapters/http.js. The prototype pollution source does not need to originate from Axios itself — any prototype pollution primitive in any dependency in the application's dependency tree is sufficient to trigger this gadget.\n\nPrerequisites:\n\nA prototype pollution primitive must exist somewhere in the application's dependency chain (e.g., via lodash.merge, qs, JSON5, or any deep-merge utility processing attacker-controlled input). The pollution source is not required to be in Axios.\nThe application must use Axios to make HTTP requests with a data payload (POST, PUT, PATCH).\n\n### Details\n\nThe vulnerability is in `lib/adapters/http.js`, in the data serialization pipeline:\n\n```javascript\n// lib/adapters/http.js \n} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {\n    headers.set(data.getHeaders());\n    // ...\n}\n```\n\nAxios uses two sequential duck-type checks, both of which can be satisfied via prototype pollution:\n\n**1. `utils.isFormData(data)` — `lib/utils.js`**\n```javascript\nconst isFormData = (thing) => {\n  let kind;\n  return thing && (\n    (typeof FormData === 'function' && thing instanceof FormData) || (\n      isFunction(thing.append) && ( \n        (kind = kindOf(thing)) === 'formdata' ||  \n        (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')\n      )\n    )\n  )\n}\n```\n\n**2. `utils.isFunction(data.getHeaders)` — Duck-type for `form-data` npm package**\n```javascript\n// Returns true if Object.prototype.getHeaders is a function\nutils.isFunction(data.getHeaders) \n```\n\n### PoC\n\n```javascript\n// Simulate Prototype Pollution\nObject.prototype[Symbol.toStringTag] = 'FormData';\nObject.prototype.append = () => {};\nObject.prototype.getHeaders = () => {\n    const headers = Object.create(null);\n    (.... Introduce here all the headers you want ....)\n    return headers;\n};\nObject.prototype.pipe = function(d) { if(d&&d.end)d.end(); return d; };\nObject.prototype.on = function() { return this; };\nObject.prototype.once = function() { return this; };\n\n// Legitimate application code\nconst response = await axios.post('https://internal-api.company.com/admin/delete', \n    { userId: 42 },\n    { headers: { 'Authorization': 'Bearer VALID_USER_TOKEN' } }\n);\n```\n\n### Impact\n\n- Authentication Bypass (CVSS: C:H)\n- Session Fixation (CVSS: I:H)\n- Privilege Escalation (CVSS: C:H, I:H)\n- IP Spoofing / WAF Bypass (CVSS: I:H)\n\n**Note on Scope**: There is an argument to promote this from **S:U to S:C** (Scope: Changed), which would raise the score to **10.0**. In some architectures, Axios is commonly used for service to service communication where downstream services trust identity headers (`Authorization`, `X-Role`, `X-User-ID`, `X-Tenant-ID`) forwarded from upstream API gateways. In this scenario, the vulnerable component (Axios in Service A) and the impacted component (Service B, which acts on the injected identity) are under different security authorities. The injected headers cross a trust boundary, meaning the impact extends beyond the security scope of the vulnerable component, the CVSS v3.1 definition of a Scope Change. We conservatively score S:U here, but maintainers should evaluate which one applies better here.\n\n### Recommended Fix\n\nAdd an explicit own-property check in `lib/adapters/http.js`:\n\n```diff\n- } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {\n-     headers.set(data.getHeaders());\n+ } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders) &&\n+            Object.prototype.hasOwnProperty.call(data, 'getHeaders')) {\n+     headers.set(data.getHeaders());\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"Axios es un cliente HTTP basado en promesas para el navegador y Node.js. Antes de 1.15.1 y 0.31.1, existe un ’gadget’ de contaminación de prototipos en el adaptador HTTP de Axios (lib/adapters/http.js) que permite a un atacante inyectar encabezados HTTP arbitrarios en las solicitudes salientes. La vulnerabilidad explota la verificación de tipo ’duck-type’ de la carga útil de datos, donde si Object.prototype se contamina con getHeaders, append, pipe, on, once y Symbol.toStringTag, Axios identifica erróneamente cualquier carga útil de objeto simple como una instancia de FormData y llama a la función getHeaders() controlada por el atacante, fusionando los encabezados devueltos en la solicitud saliente. El código vulnerable reside exclusivamente en lib/adapters/http.js. La fuente de contaminación de prototipos no necesita originarse de Axios mismo - cualquier primitiva de contaminación de prototipos en cualquier dependencia en el árbol de dependencias de la aplicación es suficiente para activar este ’gadget’. Esta vulnerabilidad está corregida en 1.15.1 y 0.31.1.","source":"nvd"}],"published":"2026-04-24T17:38:07.752Z","modified":"2026-11-11T23:10:00.263Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","score":7.4,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","score":7.4,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","score":7.4,"rating":"HIGH"}],"cwes":["CWE-113","CWE-1321"],"affected":[{"ranges":[{"version":">= 1.0.0, < 1.15.1","status":"affected"},{"version":"< 0.31.1","status":"affected"}],"vendor":"axios","product":"axios","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.0.0","status":"affected","fixed":"1.15.1"}],"ecosystem":"npm","package":"axios","purl":"pkg:npm/axios","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.31.1"}],"ecosystem":"npm","package":"axios","purl":"pkg:npm/axios","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.31.1"},{"status":"affected","introduced":"1.0.0","fixed":"1.15.1"}],"vendor":"axios","product":"axios","cpe":"cpe:2.3:a:axios:axios:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/axios/axios/security/advisories/GHSA-6chq-wfr3-2hj9","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42035","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/axios/axios","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-04-24T00:00:00.000Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42035","url":"https://www.cve.org/CVERecord?id=CVE-2026-42035","licence":"CVE Terms of Use","modified":"2026-04-25T03:55:59.169Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6chq-wfr3-2hj9","url":"https://github.com/advisories/GHSA-6chq-wfr3-2hj9","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:04.772Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42035","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42035","licence":"Public domain","modified":"2026-11-11T23:10:00.263Z"}],"updatedAt":"2026-11-25T22:59:19.556Z","epss":{"score":0.00417,"percentile":0.38032,"date":"2026-12-01T12:00:22.000Z"}}