axios 0.31.1 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,38 @@
1
+ # AGENTS.md
2
+
3
+ ## Setup
4
+ - Use npm here; `package-lock.json` is committed and CI installs with `npm ci --ignore-scripts`.
5
+ - `mise.toml` pins local Node 20, but CI runs Node 12, 14, 16, 18, 20, 22, and 24; keep `lib/` source compatible with old CommonJS-era syntax and runtime assumptions.
6
+ - CI order is `npm ci --ignore-scripts`, `npm run build`, then `npm test`.
7
+
8
+ ## Commands
9
+ - `npm run build`: runs `grunt build`, which cleans `dist/` and uses Rollup from `lib/axios.js` to create `dist/axios*.js` and `dist/esm/axios*.js`.
10
+ - `npm test`: runs JS tests and declaration tests through `bin/ssl_hotfix.js`; use this full command on Node >16 so old tooling gets `NODE_OPTIONS=--openssl-legacy-provider`.
11
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/grunt test`: JS-only verification, running ESLint on `lib/**/*.js`, Mocha on `test/unit/**/*.js`, and Karma on `test/specs/**/*.spec.js`.
12
+ - `./node_modules/.bin/mocha --timeout 30000 test/unit/<path>.js`: run one Node/Mocha unit test file without Karma or dtslint.
13
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/grunt karma:single`: run the browser suite only.
14
+ - `node bin/ssl_hotfix.js ./node_modules/.bin/dtslint --localTs node_modules/typescript/lib`: run the declaration tests in `test/typescript/axios.ts`.
15
+ - `npm run fix`: ESLint autofix for `lib/**/*.js` only.
16
+
17
+ ## Structure
18
+ - Package entry is `index.js` -> `lib/axios.js`; the TypeScript surface is the root `index.d.ts`.
19
+ - `lib/defaults/index.js` chooses the runtime adapter: `lib/adapters/xhr.js` for browsers and `lib/adapters/http.js` for Node.
20
+ - Browser bundlers also rely on `package.json` `browser` mappings from `./lib/adapters/http.js` to `./lib/adapters/xhr.js` and from `./lib/platform/node/index.js` to `./lib/platform/browser/index.js`.
21
+ - `lib/env/data.js` stores the package version and is generated by `grunt version` or `npm run preversion`; do not edit it except as part of a version bump.
22
+ - `grunt build` uses `rollup.config.js`; `webpack.config.js` is not the package build path, while Karma has its own webpack config inside `karma.conf.js`.
23
+
24
+ ## Tests
25
+ - Node tests live in `test/unit/**/*.js` and use Mocha plus Node `assert`.
26
+ - Browser tests live in `test/specs/**/*.spec.js` and use Jasmine/Jasmine-Ajax; globals such as `axios` and `getAjaxRequest` come from `test/specs/__helpers.js`.
27
+ - Karma defaults to `FirefoxHeadless` and `ChromeHeadless` whenever `process.env.GITHUB_ACTIONS !== 'false'`, including when the variable is unset; set `GITHUB_ACTIONS=false` only if you need non-headless local browsers.
28
+ - There is no committed single-browser-spec target; do not leave `fdescribe`, `fit`, or `.only` in tests.
29
+ - Declaration changes should update both `index.d.ts` and `test/typescript/axios.ts`, then run the dtslint command above.
30
+
31
+ ## Source Conventions
32
+ - `lib/` is CommonJS with `'use strict'`, `var`, semicolons, 2-space indentation, and no trailing commas; ESLint only checks `lib/**/*.js`.
33
+ - Public API behavior usually needs README docs, TypeScript declarations, and declaration tests updated together.
34
+ - Adapter or platform changes usually need both Node and browser paths considered, including Mocha coverage for `http.js` behavior and Karma coverage for `xhr.js` behavior.
35
+
36
+ ## Node 12+ Compatibility
37
+ - All shipped code AND test code must run on Node 12 through Node 24. CI runs the full matrix, so a test that only works on Node 16+ will break the build. Avoid `??`, `?.`, top-level `await`, private class fields, `Array.prototype.at`, `structuredClone`, etc. in both `lib/` and `test/`.
38
+ - Be wary of `Object.prototype` pollution tests on Node 12/14: setting `Object.prototype.get` (or `set`) before any code that calls `Object.defineProperty` with a value-only descriptor will throw `TypeError: Getter must be a function`, because the descriptor inherits the polluted property. Construct servers/clients first, pre-load any lazy-required Node internals (e.g. `require('dns')`), then apply the pollution.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,148 @@
1
1
  # Changelog
2
2
 
3
- ## [0.30.0](https://github.com/axios/axios/compare/v0.29.0...v0.30.0) (2025-03-26)
3
+ ## v0.32.0 — May 4, 2026
4
+
5
+ This release backports a comprehensive set of security and hardening fixes from the v1.x branch into v0.x, covering prototype-pollution protections, default error redaction, stricter proxy/cookie/socket handling, and one breaking change to merged config and header object prototypes.
6
+
7
+ ## ⚠️ Breaking Changes & Deprecations
8
+
9
+ - Null-prototype merged objects: mergeConfig and header merging now return objects with a null prototype to block prototype-pollution gadgets. Consumers must use Object.prototype.hasOwnProperty.call(obj, key) and avoid implicit string coercion against merged config or header objects. (#10838)
10
+
11
+ ## 🔒 Security Fixes
12
+
13
+ - Default error redaction: AxiosError.toJSON() now redacts sensitive keys by default to prevent credential leaks in logs. The behavior is configurable via config.redact, with defaults exposed on defaults.redact. (#10838)
14
+ - Cookie & XSRF handling: Cookie names are read literally rather than via regex, and only own properties are respected when evaluating withXSRFToken. (#10838)
15
+ - Proxy bypass IPv6 parity: NO_PROXY matching now handles canonical IPv4-mapped IPv6 forms such as ::ffff:127.0.0.1 and ::ffff:7f00:1. (#10838)
16
+ - Node http adapter hardening: Strips Proxy-Authorization when no proxy is in use and gates socketPath behind a new allowedSocketPaths allowlist (string or array, normalized) to reduce accidental Unix socket exposure. (#10838)
17
+ - Browser xhr adapter: Stricter own-property checks when reading config and headers. (#10838)
18
+ - URL parameters: AxiosURLSearchParams keeps %00 encoded and applies consistent encoding throughout. (#10838)
19
+ - Public type surface: Adds formDataHeaderPolicy, redact, and allowedSocketPaths to the TypeScript declarations alongside their runtime defaults. (#10838)
20
+
21
+ ## 🔧 Maintenance & Chores
22
+
23
+ - Repo hygiene: Updates README.md and CHANGELOG.md, adds AGENTS.md, and refreshes the issue and PR templates. (#10838)
24
+
25
+ [**Full Changelog**](https://github.com/axios/axios/compare/v0.31.1...v0.32.0)
26
+
27
+ ## 0.31.1 (2024-12-19)
28
+
29
+ This release backports a broad set of security hardenings from the v1 line — covering prototype-pollution defences, stream size enforcement, XSRF handling, URL null-byte encoding, and bounded FormData recursion — and drops committed `dist/` artefacts along with Bower support.
30
+
31
+ ## ⚠️ Breaking Changes & Deprecations
32
+
33
+ * **Bower & Committed `dist/` Removed:** `dist/` bundles are no longer committed to the repo, and `bower.json` plus the Grunt `package2bower` task have been removed. CI still builds bundles before publish, so npm/yarn/pnpm consumers are unaffected; installs via Bower or directly from the git tree must migrate to npm or a CDN. (__#10747__)
34
+
35
+ ## 🔒 Security Fixes
36
+
37
+ * **Prototype Pollution in Header Merge (GHSA-6chq-wfr3-2hj9):** Tightened `isFormData` to reject plain/null-prototype objects and require `append`, and guarded the Node HTTP adapter so `data.getHeaders()` is only merged when it is not inherited from `Object.prototype`. Blocks injected headers via polluted `getHeaders`. (__#10750__)
38
+ * **Prototype Pollution in Config Merging (GHSA-pf86-5x62-jrwf):** `mergeConfig`, defaults resolution, and the HTTP adapter now uses own-property checks for `transport`, `env`, `Blob`, `formSerializer`, and transforms arrays, and merged configs are returned as null-prototype objects. Prevents hijacking of the request flow through polluted prototypes. (__#10752__)
39
+ * **FormData / Params Recursion DoS:** Added a configurable `maxDepth` (default `100`, `Infinity` disables) to `toFormData` and params serialisation, throwing `AxiosError` with code `ERR_FORM_DATA_DEPTH_EXCEEDED` when exceeded. Circular-reference detection is preserved. (__#10728__)
40
+ * **Null-Byte Injection in Query Strings:** Removed the unsafe `%00` → null-byte substitution from `AxiosURLSearchParams.encode` so `%00` is preserved as-is. Other encoding behaviour (including `%20` → `+`) unchanged. (__#10737__)
41
+ * **Consolidated v1 Security Backport:** Rolls up remaining v1 hardenings into `v0.x`: `maxContentLength` enforcement for `responseType: 'stream'` via a guarded transform with deferred piping, `maxBodyLength` enforcement for streamed uploads on native `http`/`https` with `maxRedirects: 0`, and stricter `withXSRFToken` handling so only own boolean `true` enables cross-origin XSRF headers. (__#10764__)
42
+
43
+ ## 🔧 Maintenance & Chores
44
+
45
+ * **CODEOWNERS:** Added `.github/CODEOWNERS` with `* @jasonsaayman` to set a default reviewer for all paths. (__#10740__)
46
+
47
+ [Full Changelog](https://github.com/axios/axios/compare/v0.31.0...v0.31.1)
48
+
49
+ ## 0.31.0 (2024-12-17)
50
+
51
+ This release backports security fixes from v1.x, hardens the CI/CD supply chain with OIDC publishing and `zizmor` scanning, resolves TypeScript typing issues in `AxiosInstance`, and fixes a performance regression in `isEmptyObject()`.
52
+
53
+ ## 🔒 Security Fixes
54
+
55
+ * **Header Injection & Proxy Bypass:** Backports v1 security hardening — sanitizes outgoing header values to strip invalid bytes, CRLF sequences, and boundary whitespace (including array values); adds proper `NO_PROXY`/`no_proxy` enforcement covering wildcards, explicit ports, loopback aliases (`localhost`, `127.0.0.1`, `::1`), bracketed IPv6, and trailing-dot hostnames. Proxy bypass is now checked before the proxy URL is parsed, and `parsed.host` is used for correct port and IPv6 handling. (__#10688__)
56
+
57
+ * **CI Security:** SHA-pins all actions and disables credential persistence in v0.x CI, introduces `zizmor` security scanning with SARIF upload to code scanning, adds an OIDC Trusted Publishing workflow with npm provenance attestations, and gates all publishes behind a required `npm-publish` GitHub Environment with configurable reviewer protections. (__#10638__, __#10639__, __#10667__)
58
+
59
+ ## 🐛 Bug Fixes
60
+
61
+ * **TypeScript — `AxiosInstance` Return Types:** Fixes return types in `AxiosInstance` methods to correctly resolve to `Promise<R>` (matching `AxiosPromise<T>` semantics), and corrects the generic call signature so TypeScript properly enforces the response data type. TypeScript-only changes; no runtime impact. (__#6253__, __#7328__)
62
+
63
+ * **Performance:** Fixes a performance regression in `isEmptyObject()` that caused excessive computation when the argument was a large string. (__#6484__)
64
+
65
+ ## 🔧 Maintenance & Chores
66
+
67
+ * **Versioning & CI Workflow:** Adds an automated versioning flow for v0.x, renames the CI workflow for consistency with the v1.x naming convention, and corrects the branch name reference in CI config. (__#10690__, __#10691__, __#10692__)
68
+
69
+ ## 🌟 New Contributors
70
+
71
+ We are thrilled to welcome our new contributors. Thank you for helping improve axios:
72
+
73
+ * __@nakataki17__ (__#6253__)
74
+ * __@gmasclet__ (__#6484__)
75
+ * __@shaanmajid__ (__#10638__, __#10639__, __#10667__)
76
+ * __@ivan-churakov__ (__#7328__)
77
+
78
+ [Full Changelog](https://github.com/axios/axios/compare/v0.30.3...v0.31.0)
79
+
80
+ ## 0.30.3 (2024-12-10)
81
+
82
+ This is a critical security maintenance release for the v0.x branch. It addresses a high-priority vulnerability involving prototype pollution that could lead to a Denial of Service (DoS).
83
+
84
+ Recommendation: All users currently on the 0.x release line should upgrade to this version immediately to ensure environment stability.
85
+
86
+ ## 🛡️ Security Fixes
87
+
88
+ - **Backport: Fix DoS via __proto__ key in merge config**
89
+ - Patched a vulnerability where specifically crafted configuration objects using the __proto__ key could cause a Denial of Service during the merge process. - _by @FeBe95 in [PR #7388](https://github.com/axios/axios/pull/7388)_
90
+
91
+ ## ⚙️ Maintenance & CI
92
+
93
+ - **CI Infrastructure Update**
94
+ - Updated Continuous Integration workflows for the v0.x branch to maintain long-term support and build reliability. - _by @jasonsaayman in [PR #7407](https://github.com/axios/axios/pull/7407)_
95
+
96
+ ## ⚠️ Breaking Changes
97
+
98
+ Configuration Merging Behavior:
99
+
100
+ As part of the security fix, Axios now restricts the merging of the __proto__ key within configuration objects. If your codebase relies on unconventional deep-merging patterns that target the object prototype via Axios config, those operations will now be blocked. This is a necessary change to prevent prototype pollution.
101
+
102
+ Full Changelog: [v0.30.2...v0.30.3](https://github.com/axios/axios/compare/v0.30.2...v0.30.3)
103
+
104
+ ## 0.30.2 (2024-11-28)
105
+
106
+ ## What's Changed
107
+ * Backport `maxContentLength` vulnerability fix to v0.x by @FeBe95 in https://github.com/axios/axios/pull/7034
108
+
109
+ ## New Contributors
110
+ * @FeBe95 made their first contribution in https://github.com/axios/axios/pull/7034
111
+
112
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.30.1...v0.30.2
113
+
114
+ ## 0.30.1 (2024-11-27)
115
+
116
+ ## Release notes:
117
+
118
+ ### Bug Fixes
119
+ * chore(deps): bump form-data from 4.0.0 to 4.0.4 for v0.x by @wolandec in https://github.com/axios/axios/pull/6978
120
+
121
+ ### Contributors to this release
122
+ * @wolandec made their first contribution in https://github.com/axios/axios/pull/6978
123
+
124
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.30.0...v0.30.1
125
+
126
+ ## 0.30.0 (2024-11-21)
127
+
128
+ ## Release notes:
129
+
130
+ ### Bug Fixes
131
+ * fix: modify log while request is aborted by @mori5321 in https://github.com/axios/axios/pull/4917
132
+ * fix: update CHANGELOG.md for v0.x by @TehZarathustra in https://github.com/axios/axios/pull/6271
133
+ * fix: modify upgrade guide for 0.28.1's breaking change by @nafeger in https://github.com/axios/axios/pull/6787
134
+ * fix: backport allowAbsoluteUrls vulnerability fix to v0.x by @thatguyinabeanie in https://github.com/axios/axios/pull/6829
135
+ * fix: add allowAbsoluteUrls type by @thatguyinabeanie in https://github.com/axios/axios/pull/6849
136
+
137
+ ### Contributors to this release
138
+ * @mori5321 made their first contribution in https://github.com/axios/axios/pull/4917
139
+ * @TehZarathustra made their first contribution in https://github.com/axios/axios/pull/6271
140
+ * @nafeger made their first contribution in https://github.com/axios/axios/pull/6787
141
+ * @thatguyinabeanie made their first contribution in https://github.com/axios/axios/pull/6829
142
+
143
+ **Full Changelog**: https://github.com/axios/axios/compare/v0.29.0...v0.30.0
144
+
145
+ ## 0.29.0 (2024-11-21)
4
146
 
5
147
  ## Release notes:
6
148
 
@@ -14,6 +156,8 @@
14
156
 
15
157
  ## [0.29.0](https://github.com/axios/axios/compare/v0.28.1...v0.29.0) (2024-11-21)
16
158
 
159
+ ## 0.28.1 (2024-03-24)
160
+
17
161
  ## Release notes:
18
162
 
19
163
  ### Bug Fixes
@@ -25,6 +169,8 @@
25
169
 
26
170
  ## [0.28.1](https://github.com/axios/axios/compare/v0.28.0...v0.28.1) (2024-03-24)
27
171
 
172
+ ## 0.28.0 (2024-02-12)
173
+
28
174
  ## Release notes:
29
175
 
30
176
  ### Bug Fixes
package/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ @AGENTS.md
package/README.md CHANGED
@@ -331,14 +331,14 @@ These are the available config options for making requests. Only the `url` is re
331
331
  // `params` are the URL parameters to be sent with the request
332
332
  // Must be a plain object or a URLSearchParams object
333
333
  // Null bytes in param values stay percent-encoded as `%00` in the resulting query string
334
- // (GHSA-xhjh-pmcv-23jw) — Axios does not reverse `encodeURIComponent` output for `%00`,
334
+ // Axios does not reverse `encodeURIComponent` output for `%00`,
335
335
  // so null-byte injection cannot be smuggled through the serializer.
336
336
  params: {
337
337
  ID: 12345
338
338
  },
339
339
 
340
340
  // `paramsSerializer` is an optional config in charge of serializing `params`
341
- // Nested objects are walked with a bounded recursion depth (GHSA-62hf-57xw-28j9):
341
+ // Nested objects are walked with a bounded recursion depth:
342
342
  // once `maxDepth` is exceeded the serializer throws `ERR_FORM_DATA_DEPTH_EXCEEDED`
343
343
  // instead of overflowing the call stack. The same cap applies to `toFormData` when
344
344
  // `Content-Type: multipart/form-data` triggers automatic FormData serialization.
@@ -404,7 +404,7 @@ These are the available config options for making requests. Only the `url` is re
404
404
  // `undefined` (default) - set XSRF header only for the same origin requests
405
405
  // Only an explicit `true` (own property on the config) will add the XSRF header for
406
406
  // cross-origin requests. Values inherited from `Object.prototype` are ignored
407
- // (GHSA-xx6v-rp6x-q39c), so a polluted prototype cannot silently enable the token.
407
+ // so a polluted prototype cannot silently enable the token.
408
408
  withXSRFToken: boolean | undefined | ((config: AxiosRequestConfig) => boolean | undefined),
409
409
 
410
410
  // `onUploadProgress` allows handling of progress events for uploads
@@ -421,7 +421,7 @@ These are the available config options for making requests. Only the `url` is re
421
421
 
422
422
  // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js
423
423
  // Also enforced on streamed responses (`responseType: 'stream'`): bytes are counted as they
424
- // arrive and the stream is aborted with an error once the cap is exceeded (GHSA-vf2m-468p-8v99).
424
+ // arrive and the stream is aborted with an error once the cap is exceeded.
425
425
  maxContentLength: 2000,
426
426
 
427
427
  // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed
@@ -429,6 +429,18 @@ These are the available config options for making requests. Only the `url` is re
429
429
  // once the cap is exceeded, even when the native http transport is used directly.
430
430
  maxBodyLength: 2000,
431
431
 
432
+ // `formDataHeaderPolicy` controls which headers the Node adapter copies from
433
+ // FormData `getHeaders()`.
434
+ // 'legacy' (default) copies all returned headers for v1 compatibility.
435
+ // 'content-only' copies only Content-Type and Content-Length.
436
+ formDataHeaderPolicy: 'legacy',
437
+
438
+ // `redact` masks matching config keys when AxiosError#toJSON() is called.
439
+ // Matching is case-insensitive and recursive. It does not change the request.
440
+ // An empty array is treated as "no override" and falls back to the defaults so
441
+ // an accidental `redact: []` cannot silently disable redaction.
442
+ redact: ['authorization', 'password'],
443
+
432
444
  // `validateStatus` defines whether to resolve or reject the promise for a given
433
445
  // HTTP response status code. If `validateStatus` returns `true` (or is set to `null`
434
446
  // or `undefined`), the promise will be resolved; otherwise, the promise will be
@@ -454,10 +466,18 @@ These are the available config options for making requests. Only the `url` is re
454
466
 
455
467
  // `socketPath` defines a UNIX Socket to be used in node.js.
456
468
  // e.g. '/var/run/docker.sock' to send requests to the docker daemon.
469
+ // Avoid passing user-controlled values because socket paths bypass host,
470
+ // port, DNS, and proxy controls.
457
471
  // Only either `socketPath` or `proxy` can be specified.
458
472
  // If both are specified, `socketPath` is used.
459
473
  socketPath: null, // default
460
474
 
475
+ // `allowedSocketPaths` constrains `socketPath` to known-safe Unix sockets.
476
+ // Use this when config can include partially user-controlled input.
477
+ // Set to a string or array of strings. An empty array denies all socket paths.
478
+ // Set to `null` on a request to clear an instance-level allowlist.
479
+ allowedSocketPaths: null, // default
480
+
461
481
  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
462
482
  // and https requests, respectively, in node.js. This allows options to be added like
463
483
  // `keepAlive` that are not enabled by default.