Skip to content

Commit f230732

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update undici to 8.13.1
PR-URL: #67692 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent d9540f5 commit f230732

41 files changed

Lines changed: 2289 additions & 1467 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎deps/undici/src/SECURITY.md‎

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,29 @@ issue.
3636

3737
Undici is an HTTP client library for Node.js. Its threat model is derived from
3838
and aligned with the [Node.js threat model](https://github.com/nodejs/node/blob/HEAD/SECURITY.md#the-nodejs-threat-model).
39+
The Node.js policy is authoritative for the copy of undici bundled with
40+
Node.js. This section applies the same boundaries to the standalone undici
41+
package.
42+
43+
### Security triage dispositions
44+
45+
Security reports are classified using the same dispositions as Node.js:
46+
47+
* **Vulnerability**: An undici defect that is exploitable across an
48+
undici-owned security boundary and meets the criteria under
49+
[What constitutes a vulnerability](#what-constitutes-a-vulnerability),
50+
including any applicable DoS criteria.
51+
* **Security-interest bug**: A real undici defect, or an API behavior likely to
52+
cause security bugs in applications, that is not itself a vulnerability
53+
under this threat model. These are fixed as regular bugs and do not
54+
automatically receive a CVE, but should still be reported privately first
55+
when they affect a common security control such as protocol interpretation,
56+
certificate validation, or TLS decisions.
57+
* **Common bug**: A correctness, robustness, or crash issue without an
58+
undici-owned security boundary or a realistic cross-boundary attacker
59+
benefit.
60+
* **Invalid / out of scope**: A report that cannot be reproduced, is not an
61+
undici defect, or concerns behavior excluded by this policy.
3962

4063
### What constitutes a vulnerability
4164

@@ -53,35 +76,49 @@ For a behavior to be considered a DoS vulnerability, the proof of concept must
5376
meet the following criteria:
5477

5578
* The API is being correctly used.
56-
* The API is public and documented.
57-
* The behavior is significant enough to cause a denial of service quickly
58-
or in a context not controlled by the application developer (for example,
59-
HTTP parsing).
79+
* The API does not have a warning against its use in production.
80+
* The API is public and documented. For standards-based APIs, the behavior
81+
must be well-defined by the applicable specification.
82+
* The API is stable. For APIs bundled in Node.js, it must have stable (2.0)
83+
status.
84+
* The behavior is significant enough to cause a denial of service quickly or
85+
in a context not controlled by the application developer, such as protocol
86+
parsing.
6087
* The behavior is directly exploitable by an untrusted source without requiring
6188
application mistakes.
6289
* The behavior cannot be reasonably mitigated through standard operational
63-
practices (like process recycling).
90+
practices, such as process recycling.
91+
* The behavior occurs deterministically under normal usage patterns rather than
92+
only in edge cases.
93+
* The behavior occurs at a rate that would cause practical resource exhaustion
94+
within a practical timeframe under typical workloads.
6495
* The attack demonstrates
6596
[asymmetric resource consumption](https://cwe.mitre.org/data/definitions/405.html),
66-
where the attacker expends significantly fewer resources than what is required
67-
by the client to process the attack.
97+
where the attacker expends significantly fewer resources than the client
98+
must expend to process the attack. Attacks requiring comparable resources on
99+
the attacker's side, which can be mitigated through practices such as rate
100+
limiting, may not qualify.
68101

69102
**Undici does NOT trust**:
70103

71-
* Data received from the remote end of HTTP connections (both inbound responses
72-
and server-sent data) that is parsed or transformed by undici before being
73-
passed to the application. This includes:
104+
* Data received from the remote end of outbound network connections created
105+
through undici APIs and transformed or validated by undici before being
106+
passed to the application, **except with respect to payload length**. Undici
107+
trusts applications to make connections and requests that avoid payload
108+
sizes that would result in a denial of service. Subject to that exception,
109+
untrusted data includes:
74110
* HTTP response headers and status lines.
75-
* HTTP response bodies when processed by undici (e.g., chunked transfer
76-
decoding, content-encoding).
111+
* HTTP response bodies processed by undici, such as chunked transfer decoding
112+
and content-encoding.
77113
* WebSocket frames received from a server.
78114
* Server-Sent Events (EventSource) data received from a server.
79115
* TLS certificate validation performed by undici on behalf of the application.
80116

81117
**Undici trusts**:
82118

83119
* The application code that uses its APIs, including all configuration,
84-
options, callbacks, and decisions about which body-consuming APIs to call.
120+
options, callbacks, connection and request decisions, and decisions about
121+
which body-consuming APIs to call.
85122
* The operating system and its network stack.
86123
* The Node.js runtime undici is running on.
87124
* Dependencies installed by the application.
@@ -99,19 +136,19 @@ meet the following criteria:
99136
bypass organizational, regulatory, or legal controls. Untrusted proxies are
100137
outside the supported threat model.
101138

102-
In other words, if untrusted data passing through undici to the application
103-
can trigger actions other than those documented for the APIs, there is likely
104-
a security vulnerability. Examples of unwanted actions are polluting globals,
105-
causing an unrecoverable crash, or any other unexpected side effects that can
106-
lead to a loss of confidentiality, integrity, or availability.
139+
In other words, if untrusted data passing through undici to the application can
140+
trigger actions other than those documented for the APIs, there is likely a
141+
security vulnerability. Examples include polluting globals, causing an
142+
unrecoverable crash, or other unexpected side effects that can lead to a loss
143+
of confidentiality, integrity, or availability.
107144

108145
### Examples of vulnerabilities
109146

110147
#### Improper Certificate Validation (CWE-295)
111148

112149
* Undici provides TLS connections to HTTPS endpoints. If certificates can be
113-
crafted that result in incorrect validation by undici, that is considered
114-
a vulnerability.
150+
crafted that result in incorrect validation by undici, that is considered a
151+
vulnerability.
115152

116153
#### Inconsistent Interpretation of HTTP Responses (CWE-444)
117154

@@ -127,12 +164,19 @@ lead to a loss of confidentiality, integrity, or availability.
127164

128165
#### CRLF Injection in Request Headers (CWE-93)
129166

130-
* If untrusted input passed to undici APIs (such as header values or URLs)
131-
can inject additional headers or corrupt the HTTP request stream, that is
167+
* If untrusted input passed to undici APIs, such as header values or URLs, can
168+
inject additional headers or corrupt the HTTP request stream, that is
132169
considered a vulnerability.
133170

134171
### Examples of non-vulnerabilities
135172

173+
#### Defense-in-depth issues
174+
175+
* Bugs whose fixes only improve resilience after another security boundary has
176+
already failed, or reduce the impact of behavior outside this threat model,
177+
are defense-in-depth issues. They are fixed as regular bugs and do not
178+
receive CVEs.
179+
136180
#### Malicious Third-Party Modules (CWE-1357)
137181

138182
* Application code and its dependencies are trusted by undici. Any scenario
@@ -141,17 +185,17 @@ lead to a loss of confidentiality, integrity, or availability.
141185

142186
#### Prototype Pollution Attacks (CWE-1321)
143187

144-
* Undici trusts the inputs provided to it by application code. It is up to the
145-
application to sanitize appropriately. Any scenario that requires control
146-
over user input passed directly by the application is not considered a
147-
vulnerability in undici.
188+
* Undici trusts inputs provided by application code. The application must
189+
sanitize them appropriately. A scenario that requires control over user input
190+
passed directly by the application is not a vulnerability in undici.
148191

149192
#### Uncontrolled Resource Consumption on Outbound Connections (CWE-400)
150193

151-
* If undici is asked to connect to a remote site and the response payload is
152-
large enough to impact performance or cause the runtime to run out of
153-
resources, that is not considered a vulnerability. Applications are
154-
responsible for setting appropriate limits on response sizes.
194+
* If undici is asked to connect to a remote site and return an artifact, it is
195+
not a vulnerability if the size of that artifact is large enough to impact
196+
performance or cause the runtime to run out of resources. Applications are
197+
responsible for choosing suitable response-processing APIs and enforcing
198+
limits appropriate for their workloads.
155199

156200
#### Calling body-consuming methods on untrusted responses
157201

@@ -188,9 +232,9 @@ lead to a loss of confidentiality, integrity, or availability.
188232

189233
#### Application Misconfiguration
190234

191-
* Issues arising from incorrect or insecure use of undici APIs (such as
235+
* Issues arising from incorrect or insecure use of undici APIs, such as
192236
disabling TLS verification, ignoring errors, or passing unsanitized user
193-
input to request options) are the application's responsibility, not
237+
input to request options, are the application's responsibility and not
194238
vulnerabilities in undici.
195239

196240
#### Unauthorized or untrusted proxy use

‎deps/undici/src/docs/docs/api/CacheStore.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ added: v7.0.0
203203
integers; a `TypeError` is thrown otherwise, or if `maxEntrySize` is greater
204204
than 2 GB.
205205

206+
The database is not encrypted, and nothing in it is hashed. The request URL
207+
(including the query string), the response headers and body, and the values of
208+
any request headers named in the response's `Vary` header (for example
209+
`Authorization` or `Cookie`) are written as plain text to `location`. Protect
210+
that file like any other sensitive data, or use `':memory:'`. A response to a
211+
request that carries `Authorization` is only stored when the response allows it
212+
with `public`, `s-maxage`, or `must-revalidate` (see [RFC 9111, Section 3.5][]);
213+
servers can send `Cache-Control: no-store` to keep a response out of the cache
214+
entirely.
215+
206216
### `sqliteCacheStore.close()`
207217

208218
<!-- YAML
@@ -372,4 +382,5 @@ The value returned by `get`. It contains every field of
372382
body. (optional)
373383

374384
[RFC&nbsp;9111]: https://www.rfc-editor.org/rfc/rfc9111.html
385+
[RFC 9111, Section 3.5]: https://www.rfc-editor.org/rfc/rfc9111.html#section-3.5
375386
[`node:sqlite`]: https://nodejs.org/api/sqlite.html

‎deps/undici/src/docs/docs/api/Client.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ added: v1.0.0
137137
positive integer. **Default:** `524288`.
138138
* `pingInterval` {number} The time interval, in milliseconds, between HTTP/2
139139
PING frames. Set to `0` to disable PING frames. Applies only to HTTP/2
140-
connections and emits a `ping` event on the client. **Default:** `60e3`.
140+
connections and emits a `ping` event on the client. A connection whose
141+
PING is still unacknowledged when the next one is due is closed, and new
142+
requests go to a new connection. **Default:** `60e3`.
141143
* `settings` {object} `SETTINGS` frame options. For full reference, take a
142144
look to [HTTP/2#Settings Object](https://nodejs.org/api/http2.html#settings-object)
143145
* `webSocket` {Object} (optional) WebSocket-specific configuration.
@@ -217,7 +219,7 @@ import { Client, buildConnector } from 'undici'
217219
const connector = buildConnector({ rejectUnauthorized: false })
218220
const client = new Client('https://localhost:3000', {
219221
connect (opts, cb) {
220-
connector(opts, (err, socket) => {
222+
return connector(opts, (err, socket) => {
221223
if (err) {
222224
cb(err)
223225
} else {

‎deps/undici/src/docs/docs/api/Connector.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const connector = buildConnector({ rejectUnauthorized: false })
7878

7979
const client = new Client('https://localhost:3000', {
8080
connect (opts, cb) {
81-
connector(opts, (err, socket) => {
81+
return connector(opts, (err, socket) => {
8282
if (err) {
8383
cb(err)
8484
} else if (/* assertion */ false) {
@@ -124,6 +124,13 @@ targets or a [`tls.TLSSocket`][] for `https:` targets, applies TCP keep-alive an
124124
the connect timeout, and invokes `callback` once the socket connects or errors.
125125
The socket is also returned synchronously.
126126

127+
undici uses the returned socket to cancel a connection attempt that no request
128+
needs any more: once every request waiting for it is aborted, the socket is
129+
destroyed and the next request opens a new connection instead of waiting for
130+
it. A connector that wraps another one should return the socket it gets back,
131+
as the examples on this page do. If it returns nothing, the attempt runs until
132+
it connects or fails.
133+
127134
When connecting over TLS, established sessions are cached (subject to
128135
`maxCachedSessions`) and reused for subsequent connections to the same
129136
`servername` or `hostname`.
@@ -141,7 +148,7 @@ const connector = buildConnector({ rejectUnauthorized: false })
141148

142149
const client = new Client('https://localhost:3000', {
143150
connect (opts, cb) {
144-
connector(opts, (err, socket) => {
151+
return connector(opts, (err, socket) => {
145152
if (err) {
146153
cb(err)
147154
} else if (getIssuerCertificate(socket).fingerprint256 !== caFingerprint) {

‎deps/undici/src/docs/docs/api/Dispatcher.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,26 @@ The order of the interceptors matters: the last interceptor in the chain is the
705705
first to be called. Forking the chain of interceptors can lead to unexpected
706706
results.
707707

708+
Because interceptors wrap each other, ordering is the end-user's responsibility.
709+
Certain built-in interceptors are order-sensitive and will throw an
710+
`InvalidArgumentError` if composed in an unsafe order. In particular, the
711+
`cache` interceptor must be composed **after** the `redirect` interceptor. When
712+
`cache` is composed before `redirect`, the cache handler is wrapped *above* the
713+
redirect handler, so it never observes the redirect history and its
714+
cross-origin / credential-bearing redirect guards are silently disabled.
715+
This allows an attacker-controlled or cross-principal redirect response to be
716+
stored under the trusted origin's cache key and replayed to unrelated callers
717+
(see GHSA-75VM-9G8F-99J4, GHSA-MQG3-3V4R-CM32, GHSA-4W7W-5XRC-9H26 and
718+
GHSA-7XG3-FPHP-28HG).
719+
720+
```js
721+
// Correct: cache is composed after redirect.
722+
new Agent().compose(interceptors.redirect({ maxRedirections: 5 }), interceptors.cache({}))
723+
724+
// Throws an InvalidArgumentError: cache composed before redirect.
725+
new Agent().compose(interceptors.cache({}), interceptors.redirect({ maxRedirections: 5 }))
726+
```
727+
708728
```text
709729
compose([interceptor1, interceptor2, interceptor3])
710730

‎deps/undici/src/docs/docs/api/Interceptors.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ and `x-compress`, is left untouched, matching `fetch()`. As required by
204204
[RFC 9659](https://www.rfc-editor.org/rfc/rfc9659.html), a `zstd` frame that
205205
requires a window size larger than 8 MB fails to decode.
206206
207-
> **Experimental:** This interceptor is experimental and subject to change.
208-
> A one-time `ExperimentalWarning` is emitted on first use.
209-
210207
**Parameters**
211208
212209
* `opts` {Object} (optional)
@@ -359,12 +356,25 @@ backing store.
359356
360357
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
361358
359+
> **Ordering:** the `cache` interceptor must be composed **after** the
360+
> `redirect` interceptor. When `cache` is composed before `redirect`, the cache
361+
> handler is wrapped above the redirect handler, so it never observes the
362+
> redirect history and its cross-origin / credential-bearing redirect guards are
363+
> silently disabled, which lets an attacker-controlled or cross-principal
364+
> redirect response be stored under the trusted origin's cache key and replayed
365+
> to unrelated callers (GHSA-75VM-9G8F-99J4, GHSA-MQG3-3V4R-CM32,
366+
> GHSA-4W7W-5XRC-9H26, GHSA-7XG3-FPHP-28HG). `compose()` throws an
367+
> `InvalidArgumentError` for this unsafe order. The `deduplicate` interceptor
368+
> participates in the same redirect-history contract and may be placed before or
369+
> after `redirect`, as long as `cache` follows `redirect`.
370+
362371
**Example**
363372
364373
```js
365374
import { Agent, interceptors, cacheStores } from 'undici'
366375

367376
const agent = new Agent().compose(
377+
interceptors.redirect({ maxRedirections: 5 }),
368378
interceptors.cache({ store: new cacheStores.MemoryCacheStore() })
369379
)
370380
```

‎deps/undici/src/docs/docs/best-practices/mocking-request.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const success = await bankTransfer('1234567890', '100')
6161

6262
assert.deepEqual(success, { message: 'transaction processed' })
6363

64-
// if you dont want to check whether the body or the headers contain the same value
64+
// if you don't want to check whether the body or the headers contain the same value
6565
// just remove it from interceptor
6666
mockPool.intercept({
6767
path: '/bank-transfer',

0 commit comments

Comments
 (0)