fix(deps): update dependency axios to ^0.33.0 [security] - autoclosed - #276
Closed
renovate[bot] wants to merge 1 commit into
Closed
fix(deps): update dependency axios to ^0.33.0 [security] - autoclosed#276renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR contains the following updates:
^0.32.0→^0.33.0Axios: Deep formToJSON Key Recursion Can Cause Denial of Service
GHSA-pmv8-rq9r-6j72
More information
Details
Summary
Axios versions starting with
0.28.0contain uncontrolled recursion informDataToJSON, which is exposed asaxios.formToJSON()and used internally when axios serialisesFormDatawithContent-Type: application/json.If an application passes attacker-controlled
FormDatafield names to this functionality, a field name with thousands of nested bracket segments can exhaust the JavaScript call stack and cause denial of service for that request or, in applications without appropriate error handling, process termination.Impact
Applications are affected only when untrusted users can control
FormDatakey names that are converted through axios.Affected paths include direct use of
axios.formToJSON()on untrustedFormDataand axios requests in which attacker-controlledFormDatais sent withContent-Type: application/json.The observed failure is
RangeError: Maximum call stack size exceeded. In local testing, this error is catchable, so process-wide crash depends on the consuming application's error handling and runtime behaviour.Affected Functionality
Affected functionality:
axios.formToJSON(formData)formToJSONtransformRequestbehaviour forFormDatawhenContent-Typecontainsapplication/jsonUnaffected functionality:
FormDatasubmission without JSON serialisationtoFormData, which already enforces amaxDepthguard<=0.27.2, whereformDataToJSONwas not presentTechnical Details
The vulnerable code is in
lib/helpers/formDataToJSON.js.parsePropPath()splits a field name such asa[x][x][x]into path segments.buildPath()then recursively processes one segment per call without enforcing a maximum depth:A key with thousands of bracket-delimited segments causes thousands of recursive calls and can exceed the JavaScript engine's call stack limit.
Relevant source locations:
lib/helpers/formDataToJSON.jscontains the unbounded recursivebuildPath().lib/axios.jsexposes the helper asaxios.formToJSON.index.jsexposesformToJSONas a named export.index.d.tsandindex.d.ctsdeclare the public API.lib/defaults/index.jscallsformDataToJSON(data)when JSON-serializingFormData.The inverse helper,
toFormData, already enforcesmaxDepthand throwsAxiosErrorwithERR_FORM_DATA_DEPTH_EXCEEDED, butformDataToJSONdoes not have an equivalent guard.Proof of Concept of Attack
Expected result on affected versions:
RangeError: Maximum call stack size exceeded
The same condition can be reached via an axios request transformation when attacker-controlled
FormDatais sent withContent-Type: application/json.Workarounds
Applications can reject or normalise untrusted form field names before calling
axios.formToJSON().Applications can avoid sending untrusted
FormDatathrough axios as JSON unless JSON conversion is required.Applications should catch errors around
formToJSON()or axios requests that transform untrustedFormData.Original Source
Summary
An uncontrolled recursion vulnerability in
formDataToJSONallows any user who controls FormData input to crash a Node.js process with a single request. The function recurses once per bracket-delimited segment in a FormData key name with no depth limit, so a key likea[x][x][x]...with 15,000+ segments exhausts the call stack. This is a denial-of-service that kills the process via an unrecoverableRangeError. The inverse functiontoFormDataalready enforces amaxDepthlimit (default 100) for exactly this reason —formDataToJSONlacks the equivalent guard.Details
Vulnerable function:
buildPathinlib/helpers/formDataToJSON.js, lines 50–82.buildPath(path, value, target, index)is called recursively — once per segment in the parsed property path — with no depth check:The key is first split into segments by
parsePropPath(line 17), which extracts every[segment]via regex. A key with 15,000 bracket pairs produces a 15,001-element array, causing 15,001 recursive calls — well beyond the V8 default stack limit (~10,000–15,000 frames).formDataToJSONis a public API consumed two ways:Directly by consumers — exported as
axios.formToJSON()(lib/axios.js:80), with TypeScript declarations in bothindex.d.ts:699andindex.d.cts:708, and documented in the API reference in four languages (docs/pages/advanced/api-reference.md).Internally by
transformRequest— called atlib/defaults/index.js:56when the request body isFormDataandContent-Typecontainsapplication/json:Contrast with
toFormData: The inverse function (lib/helpers/toFormData.js:118) enforcesmaxDepth(default 100) and throwsAxiosErrorwith codeERR_FORM_DATA_DEPTH_EXCEEDEDwhen exceeded.formDataToJSONhas no equivalent protection.PoC
Requires only Node.js and an unmodified axios v1.x install:
Verified output on Node.js 22.22.3 against axios v1.16.1 (current
v1.xHEAD):The process crashes. In a server context (e.g., Express middleware calling
axios.formToJSON()on an uploaded form), a single crafted request terminates the process.Impact
Denial of Service (process crash). Any unauthenticated user who can submit FormData to a Node.js application that passes it through
axios.formToJSON()— or that sends it as a JSON-serialized FormData body via axios — can crash the server process with a single request. TheRangeErrorfrom stack exhaustion is unrecoverable in many contexts (it cannot be reliably caught when the stack is already full). No authentication or special privileges are required; the attacker only needs to control a FormData key name.Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Axios: Excessive recursion in formDataToJSON can cause denial of service
GHSA-42h9-826w-cgv3
More information
Details
Summary
Axios versions
0.28.0and later contain uncontrolled recursion informDataToJSON, the helper behind the publicaxios.formToJSON()/ namedformToJSONAPI and the default request transform used when FormData is sent with anapplication/jsoncontent type.Applications are affected when they pass attacker-controlled
FormDatafield names into this functionality. A field name with thousands of nested bracket segments can exhaust the JavaScript call stack and throwRangeError: Maximum call stack size exceeded, causing request failure and, in applications that do not handle the exception or rejected promise, possible process termination.Impact
The impact is denial of service against applications that process untrusted
FormDatafield names through axios' FormData-to-JSON conversion.The vulnerable path is not reached by merely installing axios, by normal multipart
FormDatapass-through, or by ordinary axios requests that do not request JSON serialisation ofFormData. In the default axios request, the error is produced before network I/O and returned as a rejected Promise. Direct use offormToJSON()throws synchronously.Server-side applications are the primary risk when remote users can submit arbitrary form field names, and the application converts those fields with
formToJSON()or sends them through axios as JSON.Affected Functionality
Affected APIs and paths:
axios.formToJSON(formData)import { formToJSON } from "axios"lib/helpers/formDataToJSON.jstransformRequestwhendataisFormDataandContent-Typecontainsapplication/jsonUnaffected or lower-risk paths:
FormDatarequests withoutJSON Content-TypetoFormData()object-to-FormData serialisation, which already has amaxDepthguardTechnical Details
lib/helpers/formDataToJSON.jsparses a form field name into path segments withparsePropPath(). For a key such asa[x][x][x], each bracketed segment becomes another path element.formDataToJSON()then calls the nestedbuildPath(path, value, target, index)function.buildPath()recursively calls itself once for each path segment and does not enforce a maximum depth:const result = buildPath(path, value, target[name], index);A key containing thousands of bracket segments, therefore, creates thousands of recursive calls. At sufficient depth, V8 throws
RangeError: Maximum call stack size exceeded.Axios already applies a depth guard to the inverse serializer in
lib/helpers/toFormData.js, wheremaxDepthdefaults to 100 and exceeding it throwsAxiosErrorwith codeERR_FORM_DATA_DEPTH_EXCEEDED.formDataToJSON()does not currently have equivalent protection.Proof of Concept of Attack
Expected vulnerable result:
RangeError: Maximum call stack size exceeded
The axios request transform path can also be reached before network I/O:
Expected vulnerable result:
RangeError: Maximum call stack size exceeded
Workarounds
Applications can avoid the vulnerable path by not converting attacker-controlled
FormDatato JSON with axios.If conversion is required before a fixed axios release is available, validate
FormDatafield names before callingformToJSON()or before sendingFormDatawithContent-Type: application/json. Reject keys whose parsed nesting depth exceeds the application's expected schema.For axios requests carrying untrusted
FormData, avoid settingContent-Type: application/json; leaving the data as multipart FormData bypassesformDataToJSON().Catching the resulting error can prevent process termination, but it does not remove the uncontrolled-recursion behaviour and should not be treated as the primary mitigation.
Original Report
Axios SSRF via Incomplete Loopback Detection
CWE-918 | CVSS 7.5 (HIGH) | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
1. Classification
2. Description
Summary
The
shouldBypassProxy()function in Axios fails to recognise0.0.0.0,::, and::ffff:0.0.0.0as loopback addresses. WhenNO_PROXY=localhostis configured, requests to these addresses are incorrectly forwarded through the proxy instead of being sent directly, enabling an SSRF attack against internal services reachable via the proxy's loopback interface.Root Cause
File:
lib/helpers/shouldBypassProxy.jsisIPv4Loopback(lines 3-8): Only checks for127.x.x.xaddresses by inspectingparts[0] !== '127'. The0.0.0.0address hasparts[0] === '0', so it falls through as non-loopback, even though on Linux0.0.0.0routes to the loopback interface.isIPv6Loopback(lines 10-38): Only checkshost === '::1'. The::address (unspecified IPv6) also routes to the loopback, but is not recognised.Attack Flow:
Attack Vector
3. Proof of Concept
Phase 1: Logic Verification
Phase 2: Docker E2E Reproduction
A full 3-container Docker reproduction was created and tested:
Reproduction steps:
Results:
127.0.0.1 + NO_PROXY=localhost→ BYPASS (correct)0.0.0.0 + NO_PROXY=localhost→ VIA_PROXY (SSRF)[::] + NO_PROXY=localhost→ VIA_PROXY (SSRF)[::ffff:0.0.0.0] + NO_PROXY=localhost→ VIA_PROXY (SSRF)Phase 3: Actual Axios Client
The real Axios HTTP client (v1.16.1, source tree) was tested through proxy configuration:
proxy: { host: 'proxy', port: 8888 }NO_PROXY=localhostand requestinghttp://0.0.0.0:9999/4. Impact
Attack Scenario
NO_PROXY=localhostto protect internal serviceshttp://0.0.0.0:8080/adminas the target URL0.0.0.0→ the proxy's own loopback → reaches the internal admin service on port 8080Potential Consequences
Likelihood
5. Remediation
Code Fix
File:
lib/helpers/shouldBypassProxy.jsWorkarounds
0.0.0.0and::to theNO_PROXYenvironment variable explicitly127.0.0.1instead of0.0.0.0in all internal service URLs0.0.0.0and::before passing to AxiosSeverity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Axios: NO_PROXY bypass for 0.0.0.0 local addresses in axios
GHSA-f4gw-2p7v-4548
More information
Details
Summary
Axios versions containing
lib/helpers/shouldBypassProxy.jsdo not treat0.0.0.0as a local address when evaluatingNO_PROXYrules. In Node.js applications that useHTTP_PROXYorHTTPS_PROXYtogether withNO_PROXY=localhost,127.0.0.1,::1or similar, a request tohttp://0.0.0.0:<port>/can be routed through the configured proxy instead of bypassing it.The issue is exploitable when an attacker can influence the axios request URL or a followed redirect target, and when the proxy can reach or relay
0.0.0.0to local services. This is a Node.js runtime proxy-routing issue, not a browser, install-time, or development-tooling issue.Impact
Applications are affected when all of the following are true:
HTTP_PROXYorHTTPS_PROXY.NO_PROXYentries such aslocalhost,127.0.0.1, or::1to keep local traffic out of the proxy path.0.0.0.0and can reach the local destination.For plain HTTP targets, the proxy can receive the full request URL, headers, and body, and may be able to observe the local service response. HTTPS targets are less exposed because axios uses CONNECT tunneling in current versions.
Affected Functionality
Affected functionality is limited to environment-derived proxy selection in the Node HTTP adapter:
lib/adapters/http.jscallsgetProxyForUrl(location)and thenshouldBypassProxy(location)before applying the proxy.lib/helpers/shouldBypassProxy.jsnormalizes and comparesNO_PROXYentries.config.proxyremains trusted caller configuration.Technical Details
lib/helpers/shouldBypassProxy.jsdefines local loopback equivalence throughisLoopback(). The current implementation recognizeslocalhost, IPv4127.0.0.0/8, IPv6::1, and IPv4-mapped loopback forms, but it does not include0.0.0.0.At
lib/helpers/shouldBypassProxy.js:176, axios treats two hosts as matching when both are considered loopback:Because
isLoopback('0.0.0.0')returnsfalse,NO_PROXY=localhost,127.0.0.1,::1does not matchhttp://0.0.0.0:<port>/.lib/adapters/http.js:185-193then applies the environment proxy.Proof of Concept of Attack
Expected safe behavior: both
127.0.0.1and0.0.0.0bypass the proxy when theNO_PROXYpolicy is intended to cover local destinations.Observed behavior:
127.0.0.1bypasses the proxy, while0.0.0.0is sent through the proxy.Workarounds
0.0.0.0explicitly toNO_PROXYwhere local addresses must bypass proxies.0.0.0.0in application URL validation before calling axios.proxy: falseon axios requests that must never use environment proxies.0.0.0.0, loopback, link-local, and internal address ranges.Original Report
Summary
axiosversions 1.15.0–1.16.1 contain an incomplete loopback-address check inlib/helpers/shouldBypassProxy.js. TheisLoopback()function correctly identifies127.0.0.0/8and::1as loopback addresses but does not recognise0.0.0.0— the IPv4 unspecified address, which routes to the local machine on Linux and macOS.An attacker who controls a URL passed to axios can use
http://0.0.0.0/<path>to bypass proxy-based SSRF filtering that the application relies upon.Details
Affected versions
>= 1.15.0, <= 1.16.1The vulnerability was introduced in v1.15.0 when the
shouldBypassProxyhelper was added as a security improvement (PR #10661).Root cause
File:
lib/helpers/shouldBypassProxy.jsThe depth guard is in
build():For
{}metatoken values,build()only sees the top-level property. The nested value is handed directly to nativeJSON.stringify(), which recurses internally and can throwRangeErrorbefore axios emits the intendedAxiosError.Proof of Concept of Attack
Safe local PoC with no network I/O:
Expected fixed behavior is an
AxiosErrorwith codeERR_FORM_DATA_DEPTH_EXCEEDED.Workarounds
Reject or depth-limit untrusted objects before passing them to axios serialization.
Strip or reject top-level keys ending in
{}from untrusted objects when using axios form serialization.For query parameters, use a custom
paramsSerializer.serializethat enforces a depth limit.For form bodies, construct
FormDataorURLSearchParamsmanually after validating input depth.Original Report
Summary
The
maxDepth=100guard added in axios 1.15.0 to fix GHSA-62hf-57xw-28j9 lives inside thebuild()recursion inlib/helpers/toFormData.js. The default visitor atlib/helpers/toFormData.js:166-170still has a top-level shortcut that callsJSON.stringify(value)whenever a key ends in'{}', beforebuild()ever sees the nested value. JSON.stringify on a deeply nested object stack-overflows withRangeError: Maximum call stack size exceeded, which propagates synchronously out of the axios call. The exact attacker-data flow that the original advisory described (proxy-style code that forwards client JSON intoaxios({ data, params })) still crashes the process at depth ~3000 on a default Node.js stack, despite v1.16.0 being patched.Details
Affected: axios 1.15.0 - 1.16.0 (every released version that carries the GHSA-62hf-57xw-28j9 fix). The bug is reachable from any code path that hits
toFormData, which includes:axios.post(url, data, { headers: { 'content-type': 'application/x-www-form-urlencoded' } })->defaults.transformRequest->toURLEncodedForm(data)->toFormDataaxios.post(url, data, { headers: { 'content-type': 'multipart/form-data' } })-> same path viatoFormDataaxios.get(url, { params })->buildURL->new AxiosURLSearchParams(params)->toFormDataVulnerable code,
lib/helpers/toFormData.js:build()later does enforcemaxDepth:The
'{}'shortcut runs indefaultVisitor, which is invoked from insidebuild()for top-level keys (the!pathclause at line 165 means the shortcut only triggers at top level, wherepathisundefined). At that pointdepth === 0and the maxDepth check has already passed; the recursion-aware guard never sees the nested value becausedefaultVisitorreassignsvalue = JSON.stringify(value)and returns the rendered string straight toformData.append. JSON.stringify itself is recursive in V8 and stack-overflows on deeply nested objects, throwingRangeErrorsynchronously.The behaviour is independent of the
metaTokensoption: line 168 only changes whether'{}'stays on the key name, line 170 stringifies regardless.toURLEncodedForm's wrapper visitor inlib/helpers/toURLEncodedForm.js:11-14falls through to the samedefaultVisitor, so the form-encoded path is also affected.The attacker payload is a single top-level key ending in
'{}'whose value is a nested object. The keys themselves do not have to be deep, so the payload is small to send (a few KB of{"x":{"x":...}}produces enough nesting to overflow). The original advisory's threat model -- a server that forwardsreq.bodyorreq.queryinto axios -- is unchanged:The error is not an
AxiosError; it is a rawRangeErrorthrown from the stringifier, so handlers that look forerr.code === 'ERR_FORM_DATA_DEPTH_EXCEEDED'(the documented signal that the maxDepth guard fired) do not see it. Synchronous startup paths or worker threads still take the whole process down.The fix is to also depth-limit (or pre-walk) the value before calling
JSON.stringifyon line 170, or to remove the top-level'{}'shortcut and rely on the depth-checkedbuild()recursion to handle it. A minimal patch that preserves observable behaviour for legal payloads:if (utils.endsWith(key, '{}')) { // eslint-disable-next-line no-param-reassign key = metaTokens ? key : key.slice(0, -2); + // Reject objects that would exceed maxDepth before handing to JSON.stringify, + // which is recursive in V8 and stack-overflows on deeply nested input. + (function checkDepth(v, d) { + if (d > maxDepth) { + throw new AxiosError( + 'Object is too deeply nested (' + d + ' levels). Max depth: ' + maxDepth, + AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED + ); + } + if (v && typeof v === 'object') { + for (const k in v) checkDepth(v[k], d + 1); + } + })(value, 0); // eslint-disable-next-line no-param-reassign value = JSON.stringify(value); }(The recursion in
checkDepthitself is bounded bymaxDepth, so it cannot itself overflow.)PoC
Reproduces against a clean clone of
axios/axiosat v1.16.0 withnpm installalready run.targets/axios/poc_jsonstringify_dos.mjsis the script:3/3 runs reproduce the same
RangeErroronaxios@1.16.0with Node.js 24:safeAdapteris a stub that returns a fake response, so the crash is provably inside axios's serialization layer, not in HTTP I/O. Removing the'{}'suffix from the key and re-running gives the expectedAxiosError: Object is too deeply nested ... ERR_FORM_DATA_DEPTH_EXCEEDEDfrom the maxDepth guard, confirming the fix is wired correctly elsewhere -- it just does not cover this branch.Crash threshold on a default-stack Node.js process is roughly depth 2500-3000; 8000 is comfortably above that, and the payload is a few KB.
Impact
A remote, unauthenticated attacker who can influence an object that the application passes to axios as request
dataorparamstriggers an uncaughtRangeErrorfrom inside the synchronousJSON.stringifycall indefaultVisitor. In server-side applications that proxy or re-forward client JSON through axios -- the same threat model that motivated GHSA-62hf-57xw-28j9 -- this crashes the request handler and, in worker/cluster setups, the whole process. The previously shippedmaxDepthguard does not stop it because the'{}'suffix path bypassesbuild()entirely. Same severity class as the original advisory (CWE-674 Uncontrolled Recursion, network-reachable DoS); the only difference is the attacker has to suffix one of their object keys with'{}'to land on the unguarded code path.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Axios: Excessive recursion in formDataToJSON can cause denial of service
GHSA-42h9-826w-cgv3
More information
Details
Summary
Axios versions
0.28.0and later contain uncontrolled recursion informDataToJSON, the helper behind the publicaxios.formToJSON()/ namedformToJSONAPI and the default request transform used when FormData is sent with anapplication/jsoncontent type.Applications are affected when they pass attacker-controlled
FormDatafield names into this functionality. A field name with thousands of nested bracket segments can exhaust the JavaScript call stack and throwRangeError: Maximum call stack size exceeded, causing request failure and, in applications that do not handle the exception or rejected promise, possible process termination.Impact
The impact is denial of service against applications that process untrusted
FormDatafield names through axios' FormData-to-JSON conversion.The vulnerable path is not reached by merely installing axios, by normal multipart
FormDatapass-through, or by ordinary axios requests that do not request JSON serialisation ofFormData. In the default axios request, the error is produced before network I/O and returned as a rejected Promise. Direct use offormToJSON()throws synchronously.Server-side applications are the primary risk when remote users can submit arbitrary form field names, and the application converts those fields with
formToJSON()or sends them through axios as JSON.Affected Functionality
Affected APIs and paths:
axios.formToJSON(formData)import { formToJSON } from "axios"lib/helpers/formDataToJSON.jstransformRequestwhendataisFormDataandContent-Typecontainsapplication/jsonUnaffected or lower-risk paths:
FormDatarequests withoutJSON Content-TypetoFormData()object-to-FormData serialisation, which already has amaxDepthguardTechnical Details
lib/helpers/formDataToJSON.jsparses a form field name into path segments withparsePropPath(). For a key such asa[x][x][x], each bracketed segment becomes another path element.formDataToJSON()then calls the nestedbuildPath(path, value, target, index)function.buildPath()recursively calls itself once for each path segment and does not enforce a maximum depth:const result = buildPath(path, value, target[name], index);A key containing thousands of bracket segments, therefore, creates thousands of recursive calls. At sufficient depth, V8 throws
RangeError: Maximum call stack size exceeded.Axios already applies a depth guard to the inverse serializer in
lib/helpers/toFormData.js, wheremaxDepthdefaults to 100 and exceeding it throwsAxiosErrorwith codeERR_FORM_DATA_DEPTH_EXCEEDED.formDataToJSON()does not currently have equivalent protection.Proof of Concept of Attack
Expected vulnerable result:
RangeError: Maximum call stack size exceeded
The axios request transform path can also be reached before network I/O:
Expected vulnerable result:
RangeError: Maximum call stack size exceeded
Workarounds
Applications can avoid the vulnerable path by not converting attacker-controlled
FormDatato JSON with axios.If conversion is required before a fixed axios release is available, validate
FormDatafield names before callingformToJSON()or before sendingFormDatawithContent-Type: application/json. Reject keys whose parsed nesting depth exceeds the application's expected schema.For axios requests carrying untrusted
FormData, avoid settingContent-Type: application/json; leaving the data as multipart FormData bypassesformDataToJSON().Catching the resulting error can prevent process termination, but it does not remove the uncontrolled-recursion behaviour and should not be treated as the primary mitigation.
Original Report
Axios SSRF via Incomplete Loopback Detection
CWE-918 | CVSS 7.5 (HIGH) | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
1. Classification
2. Description
Summary
The
shouldBypassProxy()function in Axios fails to recognise0.0.0.0,::, and::ffff:0.0.0.0as loopback addresses. WhenNO_PROXY=localhostis configured, requests to these addresses are incorrectly forwarded through the proxy instead of being sent directly, enabling an SSRF attack against internal services reachable via the proxy's loopback interface.Root Cause
File:
lib/helpers/shouldBypassProxy.jsisIPv4Loopback(lines 3-8): Only checks for127.x.x.xaddresses by inspectingparts[0] !== '127'. The0.0.0.0address hasparts[0] === '0', so it falls through as non-loopback, even though on Linux0.0.0.0routes to the loopback interface.isIPv6Loopback(lines 10-38): Only checkshost === '::1'. The::address (unspecified IPv6) also routes to the loopback, but is not recognised.Attack Flow:
Attack Vector
3. Proof of Concept
Phase 1: Logic Verification
Phase 2: Docker E2E Reproduction
A full 3-container Docker reproduction was created and tested:
Reproduction steps:
Results:
127.0.0.1 + NO_PROXY=localhost→ BYPASS (correct)0.0.0.0 + NO_PROXY=localhost→ VIA_PROXY (SSRF)[::] + NO_PROXY=localhost→ VIA_PROXY (SSRF)[::ffff:0.0.0.0] + NO_PROXY=localhost→ VIA_PROXY (SSRF)Phase 3: Actual Axios Client
The real Axios HTTP client (v1.16.1, source tree) was tested through proxy configuration:
proxy: { host: 'proxy', port: 8888 }NO_PROXY=localhostand requestinghttp://0.0.0.0:9999/4. Impact
Attack Scenario
NO_PROXY=localhostto protect internal serviceshttp://0.0.0.0:8080/adminas the target URL0.0.0.0→ the proxy's own loopback → reaches the internal admin service on port 8080Potential Consequences
Likelihood
5. Remediation
Code Fix
File:
lib/helpers/shouldBypassProxy.jsWorkarounds
0.0.0.0and::to theNO_PROXYenvironment variable explicitly127.0.0.1instead of0.0.0.0in all internal service URLs0.0.0.0and::before passing to AxiosSeverity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Axios: Nested axios option objects can consume polluted prototype values
GHSA-7q8q-rj6j-mhjq
More information
Details
Summary
Axios can consume inherited properties from nested request option objects when the JavaScript process already has a polluted
Object.prototype.The top-level merged config is protected with a null prototype, but nested plain objects such as
authandparamsSerializerare cloned into ordinary objects. If application code passes placeholders such asauth: {}orparamsSerializer: {}, inheritedusername,password,encode, orserializeproperties can influence outbound requests.Impact
This is reachable only when another component has already polluted
Object.prototypeand the application passes an affected nested axios option object.Confirmed impacts include silent injection of an
Authorization: Basic ...header from inheritedusernameandpasswordvalues, and query-string tampering when inheritedparamsSerializerfields are function-valued.The
authcase requires only string-valued pollution. Full query-string replacement throughparamsSerializer.serializerequires a function-valued pollution primitive; string-only pollution may still cause request failures or encoding changes throughencode.This does not mean every axios request is affected. Requests that do not pass
auth, do not passparamsSerializer, or provide explicit own properties for the relevant nested fields are not affected by this specific gadget.Affected Functionality
Affected runtime functionality:
lib/adapters/http.js.lib/helpers/resolveConfig.js.lib/helpers/buildURL.js.axios.getUri()when called with an affectedparamsSerializerobject.Affected config shapes:
auth: {}or anauthobject missing ownusernameand/orpassword.paramsSerializer: {}or aparamsSerializerobject missing ownencodeand/orserialize.Unaffected by this specific issue:
authproperty.paramsSerializerproperty.authorparamsSerializervalues in current hardened versions.Technical Details
lib/core/mergeConfig.jscreates the top-level merged config withObject.create(null), but nested object cloning still uses ordinary{}containers:Downstream code then reads nested fields without own-property checks.
In
lib/helpers/resolveConfig.js:In
lib/adapters/http.js:In
lib/helpers/buildURL.js:Proof of Concept of Atta