An oversized UDP datagram and an ordinary-looking pair of transport parameters were enough to expose two very different denial-of-service bugs in quinn, a QUIC implementation in Rust.
I reported both to the maintainers, and both are fixed. The first lives below QUIC in quinn-udp: a receive fallback can keep retrying a nonblocking socket instead of returning control to the runtime. The second lives in quinn-proto: a peer-supplied minimum ACK delay can violate the precondition of Duration::clamp and cause a panic.
Their prerequisites are different, so it is useful to keep them separate from the start:
| Finding | Component | Required condition | First patched release |
|---|---|---|---|
| Receive loop spins after truncation | quinn-udp |
Unix recv_single fallback and a datagram larger than its receive buffer |
0.5.16 in the 0.5 line; 0.6.3 in the 0.6 line |
| ACK-delay calculation panics | quinn-proto |
Sending ACK_FREQUENCY enabled, plus peer parameters that invert the calculated bounds | 0.11.18 |
The UDP bug happens before QUIC packet authentication. The ACK-delay bug is reached while processing a connection with the relevant extension enabled; sending ACK_FREQUENCY is disabled by default. Neither finding should be read as a claim that every quinn endpoint has the same exposure.
1. recv_single() spins after a truncated datagram
GHSA-6pp4-4cxf-xf88 · High · quinn-udp · fixed in 0.5.16 and 0.6.3
Why returning WouldBlock matters
The affected function is the Unix recv_single fallback in quinn-udp/src/unix.rs. It receives one datagram at a time using recvmsg, rather than the ordinary Linux batched receive path.
Production callers include OpenBSD and other Unix/Apple fallback configurations. Windows uses a different implementation. A test that explicitly calls the fallback on Linux is therefore evidence about that function, not proof that Linux's normal production path is vulnerable.
The socket is nonblocking. When there is no datagram available, the receive call should return an error such as EAGAIN or EWOULDBLOCK, which the Rust layer exposes as WouldBlock. That is how the receiver tells its caller to stop trying immediately and wait for readiness again.
If the function keeps retrying without receiving data, reaching an await point, or returning that signal, it can occupy the runtime thread that is driving the endpoint. The connection logic above it cannot fix the problem because control has not returned there.
Two reasonable-looking decisions combine badly
The old code had two relevant properties:
- It inspected
MSG_TRUNCbefore handling a negativerecvmsgresult. - It initialized the
msghdronce, outside the retry loop.
msghdr contains both input information and output fields. Among the outputs, msg_flags can indicate that a received datagram was truncated because the payload did not fit in the buffer.
Discarding such a datagram is reasonable. Reusing a structure can also look harmless when the next successful call is expected to replace its output fields. The problem appears when the next call fails and the code still reads those fields as fresh output.
Here is the vulnerable recv_single function from the reviewed source revision. The imports and crate-local helper definitions live in the same module:
pub(crate) fn recv_single(
io: SockRef<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> io::Result<usize> {
let mut name = MaybeUninit::<libc::sockaddr_storage>::uninit();
let mut ctrl = cmsg::Aligned(MaybeUninit::<[u8; cmsg::LEN]>::uninit());
let mut hdr = unsafe { mem::zeroed::<libc::msghdr>() };
prepare_recv(&mut bufs[0], &mut name, &mut ctrl, &mut hdr);
let n = loop {
let n = unsafe { libc::recvmsg(io.as_raw_fd(), &mut hdr, 0) };
if hdr.msg_flags & libc::MSG_TRUNC != 0 {
continue;
}
if n >= 0 {
break n;
}
let e = io::Error::last_os_error();
match e.kind() {
// Retry receiving
io::ErrorKind::Interrupted => continue,
_ => return Err(e),
}
};
meta[0] = decode_recv(&name, &hdr, n as usize)?;
Ok(1)
}
The error branch is unreachable whenever the old truncation flag remains set. A flag describing the previous successful receive takes priority over the current call's failure.
The sequence that gets stuck
Suppose a datagram is larger than the receive buffer. The first recvmsg succeeds with a truncated message and sets MSG_TRUNC. The receiver discards that message and retries.
Now the queue is empty. The next nonblocking recvmsg fails with EAGAIN. Under the relevant semantics, that failed call can leave the previous output flags unchanged. Since the code checks MSG_TRUNC first, it interprets the stale flag as another truncated receive and immediately loops again.
| Attempt | Current receive result | Flag observed by the old code | Decision |
|---|---|---|---|
| First | Oversized datagram received |
MSG_TRUNC set |
Discard and retry |
| Second | No queued data; EAGAIN
|
Previous MSG_TRUNC still set |
Retry instead of returning WouldBlock
|
| Following attempts | Still no queued data | Same stale flag | Keep retrying |
A later successful, non-truncated receive can release the loop. That limits the claim: this is not necessarily an irreversible endpoint failure. It can still prevent useful runtime work while the loop is spinning, and its trigger occurs before any QUIC authentication.
The receive buffer must be smaller than the incoming datagram. Platform selection and buffer sizing are therefore part of the exposure assessment, rather than incidental details to leave out of the advisory.
How I reproduced it without hanging the test suite
I used a bounded localhost regression test that calls recv_single directly. It queues a 16-byte datagram for an 8-byte receive buffer and expects the function to discard the truncated message, observe the empty queue, and return WouldBlock.
The unpatched function does not finish that sequence in time. The test sends a valid cleanup message if the call has not finished within one second, allowing the stuck receiver to escape before the test reports failure. This is useful when testing a synchronous busy loop: the regression must detect the lack of progress without leaving the test process spinning indefinitely.
A second test covers truncation followed by a valid message and verifies both the payload and the source address. This catches a related class of mistakes where the function returns but carries stale receive metadata forward.
Those tests ran under Linux/WSL with the fallback explicitly enabled for unit testing. I also checked the relevant OpenBSD kernel receive semantics in source. I did not run the reproduction on native OpenBSD, and the test setup should not be presented as native platform confirmation.
The public advisory records the before-and-after result: the regression fails before the fix and passes after it. It also records passing quinn-udp suites on Linux and Windows.
Fix the ordering and reset the whole header
The fix I proposed returns receive errors before inspecting the output flags. It also initializes the receive header inside the retry_if_interrupted closure, before each syscall attempt.
The fix commit replaces it with this function:
pub(crate) fn recv_single(
io: SockRef<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> io::Result<usize> {
let mut name = MaybeUninit::<libc::sockaddr_storage>::uninit();
let mut ctrl = cmsg::Aligned(MaybeUninit::<[u8; cmsg::LEN]>::uninit());
let mut hdr = unsafe { mem::zeroed::<libc::msghdr>() };
let n = loop {
let n = retry_if_interrupted(|| {
prepare_recv(&mut bufs[0], &mut name, &mut ctrl, &mut hdr);
unsafe { libc::recvmsg(io.as_raw_fd(), &mut hdr, 0) }
})?;
if hdr.msg_flags & libc::MSG_TRUNC == 0 {
break n;
}
};
meta[0] = decode_recv(&name, &hdr, n as usize)?;
Ok(1)
}
The ? after retry_if_interrupted returns a receive error before the code can inspect hdr.msg_flags. The helper retries Interrupted errors but returns other errors, including WouldBlock.
Resetting the complete header matters because the flags are not its only reusable fields. Address and control-buffer lengths also participate in the input/output contract. A fix that only clears MSG_TRUNC risks preserving a similar assumption somewhere else in the structure.
The result is a receive loop with an explicit progress rule: after successfully receiving a truncated message it may try again, but an empty nonblocking socket returns control to the caller.
2. A peer can make clamp() panic
GHSA-3g6h-r5qx-f6hq / RUSTSEC-2026-0340 · High, CVSS 7.5 · quinn-proto · fixed in 0.11.18
The second bug does not need a malformed UDP receive. It comes from combining peer transport parameters with a locally calculated round-trip-time bound.
QUIC endpoints acknowledge received packets. When quinn is configured to send ACK_FREQUENCY frames, it calculates a delay to request from the peer. That calculation needs to account for the minimum delay the peer advertises as well as the local policy for choosing a useful delay.
The interval that stops being an interval
In AckFrequencyState::candidate_max_ack_delay, the vulnerable implementation converts the peer minimum to a Duration and uses it as the lower bound of clamp:
pub(super) fn candidate_max_ack_delay(
&self,
rtt: Duration,
config: &AckFrequencyConfig,
peer_params: &TransportParameters,
) -> Duration {
// Use the peer's max_ack_delay if no custom max_ack_delay was provided in the config
let min_ack_delay =
Duration::from_micros(peer_params.min_ack_delay.map_or(0, |x| x.into()));
config
.max_ack_delay
.unwrap_or(self.peer_max_ack_delay)
.clamp(min_ack_delay, rtt.max(MIN_AUTOMATIC_ACK_DELAY))
}
The candidate itself comes from an explicitly configured maximum delay, or from the peer's maximum ACK delay when no override is configured.
The missing invariant is that the lower bound must not exceed the upper bound. clamp does not resolve contradictory bounds by choosing a compromise: it panics when min > max.
The peer can advertise these values and pass the transport-parameter validator:
| Input | Value | Converted duration |
|---|---|---|
min_ack_delay |
100,000 microseconds | 100 ms |
max_ack_delay |
100 milliseconds | 100 ms |
| Current RTT used by the calculation | 5 milliseconds | 5 ms |
The unit conversion is worth making explicit. These two transport parameters use different units, but the example minimum and maximum both represent 100 ms. Their relationship is acceptable to the validator.
The upper bound comes from the current RTT and MIN_AUTOMATIC_ACK_DELAY, which is 25 ms. At a 5 ms RTT, that produces a 25 ms upper bound against the peer's 100 ms lower bound.
The values have passed one validation boundary and still violate a precondition at another. Checking each field, or even the relationship between the two advertised parameters, is insufficient when a later calculation combines them with local state.
A small illustration of the panic
The following standalone example demonstrates the violated Rust precondition. It is an arithmetic illustration, not a network reproduction:
use std::time::Duration;
fn main() {
let peer_minimum = Duration::from_millis(100);
let rtt = Duration::from_millis(5);
let automatic_floor = Duration::from_millis(25);
let local_upper = rtt.max(automatic_floor);
let candidate = Duration::from_millis(100);
// Panics because the minimum is greater than the maximum.
let _ = candidate.clamp(peer_minimum, local_upper);
}
Changing the candidate alone cannot repair an inverted interval. This explains why both automatic and explicitly configured maximum ACK delays could reach the bug: the problematic relationship belongs to the bounds.
The configuration and impact limits
Reaching this path requires TransportConfig::ack_frequency_config(Some(...)). Sending ACK_FREQUENCY is disabled by default, so an endpoint that has not enabled it does not reach this finding's affected calculation through that feature.
The demonstrated failure is a panic while driving the connection. What happens to the embedding application depends on its panic strategy and runtime behavior. I did not verify a process-wide crash, and the advisory explicitly preserves that limitation.
That distinction matters operationally. A panic in a connection-driving task can be serious, but it should not automatically be reported as every quinn deployment terminating its process on receipt of these parameters.
The fix defines which bound wins
The published fix in PR #2868 replaces the clamp with explicit minimum and maximum operations. This is the corrected method from the merged source:
pub(super) fn candidate_max_ack_delay(
&self,
rtt: Duration,
config: &AckFrequencyConfig,
peer_params: &TransportParameters,
) -> Duration {
let min_ack_delay =
Duration::from_micros(peer_params.min_ack_delay.map_or(0, |x| x.into()));
// Use the peer's max_ack_delay if no custom max_ack_delay was provided in the config
let candidate = config.max_ack_delay.unwrap_or(self.peer_max_ack_delay);
// Must be no smaller than the `min_ack_delay` advertised by the peer
Ord::max(
// Should be less than the RTT (itself at least `MIN_AUTOMATIC_ACK_DELAY`)
Ord::min(candidate, Ord::max(rtt, MIN_AUTOMATIC_ACK_DELAY)),
min_ack_delay,
)
}
The ordering expresses the policy. Apply the local preferred upper bound first, then ensure the result is at least the minimum advertised by the peer. If the peer's minimum exceeds that local preference, the peer minimum wins. The function can return a duration without requiring the two bounds to form a valid clamp interval.
For the example above, the result is 100 ms. This is more precise than saying the fix simply removes a panic: it defines the behavior for a combination of valid inputs that the old expression could not represent.
The public patch also includes regression tests that encode and read the transport parameters before calling the calculation. Here is the first test, from the same module:
#[test]
fn peer_min_ack_delay_can_exceed_rtt() {
let params = TransportParameters {
min_ack_delay: Some(100_000u32.into()),
max_ack_delay: 100u32.into(),
..TransportParameters::default()
};
let mut encoded = Vec::new();
params.write(&mut encoded);
let params = TransportParameters::read(Side::Client, &mut encoded.as_slice())
.expect("peer parameters must pass wire-level validation");
let state = AckFrequencyState::new(Duration::from_millis(100));
let delay = state.candidate_max_ack_delay(
Duration::from_millis(5),
&AckFrequencyConfig::default(),
¶ms,
);
assert_eq!(delay, Duration::from_millis(100));
}
A second test uses the same minimum with a 200 ms maximum. At a 5 ms RTT, both expect a 100 ms result.
Passing the values through the wire-level validator is useful evidence. A test that only invents an impossible internal state might protect a helper function while saying little about remote reachability. Here the tests preserve the connection between accepted input and the arithmetic that consumes it.
Reviewing the two failures together
Both bugs appear at boundaries where one part of the system assumes another has established more than it actually has.
In the receive loop, the code treats an output flag as current before establishing that the syscall succeeded. The missing question is whether that output belongs to this attempt.
In the ACK-delay calculation, the code treats accepted parameters as safe bounds for a later operation. The missing question is whether they still satisfy the required relationship after combining them with RTT and local policy.
These suggest two concrete review techniques. For syscall wrappers, trace a successful unusual result followed by a failure, including all reused output fields. For protocol arithmetic, trace accepted extreme values all the way to the operation that uses them, including relationships with changing local state.
The tests should follow the same distinction. A receive regression needs to prove that control returns or a later valid packet is delivered. An arithmetic regression needs to assert the intended result for contradictory preferences, rather than only asserting that execution avoids a panic.
Updating downstream applications
For these findings, the patched component versions are:
-
quinn-udp0.5.16 or later in the 0.5 line, or 0.6.3 or later in the 0.6 line. Version 0.6.0 is newer than 0.5.16 but is still within the affected 0.6 range. -
quinn-proto0.11.18 or later containing the ACK-delay fix. RustSec lists versions below 0.11.0 as unaffected by this particular finding.
Check the resolved versions of those components, including transitive dependencies and duplicate versions, rather than relying only on the top-level quinn declaration. The platform receive implementation, buffer size, and ACK-frequency configuration then determine which of the described paths a deployed application can reach.
Disabling ACK_FREQUENCY transmission removes the prerequisite for the second finding while an update is being prepared. It does not address the UDP receive loop, which sits below that protocol feature. Each fix belongs to its own component and needs to reach the build that is actually deployed.
Thanks to the quinn maintainers for handling the reports, shipping the fixes, and crediting the work in the advisories.
Top comments (0)