#2684·quiche

Server keeps PTO timer armed at the anti-amplification limit

Author: LiD0209Created Aug 31, 2026Updated Sep 20, 2026

Server keeps PTO timer armed at the anti-amplification limit

Summary

When a server has exhausted its anti-amplification budget before address validation, RFC 9002 Section 6.2.2.1 requires that the server's PTO timer not be armed. quiche enforces the send budget in send() but leaves the recovery timer armed after the last allowed flight exhausts max_send_bytes.

Standard Requirement

RFC 9002 Section 6.2.2.1:

If no additional data can be sent, the server's PTO timer MUST NOT be
armed until datagrams have been received from the client because
packets sent on PTO count against the anti-amplification limit.

When the server receives a datagram from the client, the
amplification limit is increased and the server resets the PTO timer.
If the PTO timer is then set to a time in the past, it is executed
immediately.

RFC 9002 Appendix A.8 models the timer rule as:

if (server is at anti-amplification limit):
  loss_detection_timer.cancel()
  return

So the required state is simple: unvalidated server + no remaining send budget means no armed PTO timer.

Relevant Source Code

quiche/src/lib.rs:4024 limits server output by max_send_bytes before address validation:

rust
if !send_path.verified_peer_address && self.is_server {
    left = cmp::min(left, send_path.max_send_bytes);
}

quiche/src/lib.rs:5496 deducts the budget after a packet is written and records when it reaches zero:

rust
let had_send_budget = path.max_send_bytes > 0;
path.max_send_bytes = path.max_send_bytes.saturating_sub(written);
if self.is_server &&
    !path.verified_peer_address &&
    had_send_budget &&
    path.max_send_bytes == 0
{
    self.amplification_limited_count =
        self.amplification_limited_count.saturating_add(1);
}

quiche/src/recovery/congestion/recovery.rs:504 has no server-at-limit cancellation branch:

rust
if self.bytes_in_flight.is_zero() &&
    handshake_status.peer_verified_address
{
    self.loss_timer.clear();
    return;
}

if let (Some(timeout), _) = self.pto_time_and_space(handshake_status, now)
{
    self.loss_timer.update(timeout);
} else {
    self.loss_timer.clear();
}

quiche/src/recovery/gcongestion/recovery.rs:662 has the same timer logic for gcongestion.

Implementation Behavior

The server send path correctly stops sending once max_send_bytes reaches zero. However, the recovery layer does not know that the server is now anti-amplification limited. It can keep a PTO/loss timer armed even though no additional PTO packet may be sent until another client datagram increases the budget.

Inconsistency Reason

RFC 9002 Section 6.2.2.1 requires canceling the server PTO timer while the server is blocked by the anti-amplification limit. quiche only applies the limit at packet generation time and does not clear the recovery timer when the last allowed packet consumes the remaining budget. This leaves loss_detection_timer armed in a state where the standard says it must not be armed.

Runtime Evidence

The focused anti-amplification timer test was run from implementions/quiche:

cargo test -p quiche codex_tmp_server_amp_limited_must_disarm_pto_timer --features gcongestion --release -- --nocapture

The command exited with code 101, which is the expected reproducer signal for the failing assertions below.

Observed output:

cubic: client_sent=1200 server_sent=3600 max_send_bytes=0 verified_peer_address=false loss_timer_armed=true
bbr2_gcongestion: client_sent=1200 server_sent=3600 max_send_bytes=0 verified_peer_address=false loss_timer_armed=true

test result: FAILED. 0 passed; 2 failed

The failure is the expected reproducer signal: the server is unvalidated and has no remaining send budget, but the timer is still armed for both legacy CUBIC and BBR2/gcongestion.

Impact

The application can observe a PTO/loss timeout while the server is not allowed to send PTO probes. This diverges from RFC 9002 Section 6.2.2.1's anti-amplification timer state and can cause unnecessary timeout wakeups or incorrect PTO handling around handshake blocking.

Fix Direction

Make timer scheduling aware of the server anti-amplification state. When the active path is unvalidated and max_send_bytes == 0, clear the PTO/loss timer. When a client datagram increases the budget, re-run loss timer setup and execute the timeout immediately if the recomputed timer is already in the past.