Skip to content

Fix path validation deadlock after peer address verification - #523

Open
aswanthk777 wants to merge 1 commit into
Tencent:developfrom
aswanthk777:bonding/validation-deadlock
Open

Fix path validation deadlock after peer address verification#523
aswanthk777 wants to merge 1 commit into
Tencent:developfrom
aswanthk777:bonding/validation-deadlock

Conversation

@aswanthk777

Copy link
Copy Markdown

The server-side anti-amplification helpers (inc/dec/cmp_anti_ampl_limit) all stop applying the limit once verified_peer_address is set — the limit value is frozen from that point on. need_send_validation_frames and need_expand_padding_frames, however, keep consulting the frozen value.

For a path opened by a small packet — exactly what a NAT rebinding looks like to a server — the sequence deadlocks:

  1. The first packet on the new 4-tuple is small (e.g. a bare PING), so the path starts with an anti_ampl_limit of only a few hundred bytes.
  2. The server sends an unpadded PATH_CHALLENGE (padding refused because anti_ampl_limit <= max_datagram_size), and the peer answers.
  3. on_path_resp_received sets verified_peer_address, freezing anti_ampl_limit; the path is promoted to ValidatingMTU and probes again, now needing a challenge padded to MIN_CLIENT_INITIAL_LEN.
  4. need_expand_padding_frames still compares the frozen limit against max_datagram_size and refuses the padding — forever. The path never reaches Validated, never becomes active, and the server keeps sending user data to the stale address.

Fix: skip the anti-amplification checks in both helpers once the peer address is verified, matching the semantics of the other three helpers (address-validated paths are exempt from the 3x limit per RFC 9000 §8).

Found while implementing server-side NAT rebind handling (#524 builds on this and adds a test that deadlocks at ValidatingMTU without it). Full suite passes: 558/0.

🤖 Generated with Claude Code

The server-side anti-amplification helpers (inc/dec/cmp_anti_ampl_limit)
all stop applying the limit once verified_peer_address is set: the limit
value is frozen from that point on. need_send_validation_frames and
need_expand_padding_frames, however, kept consulting the frozen value.

For a path opened by a small packet — exactly what a NAT rebinding looks
like to a server — the sequence deadlocks:

1. The first packet on the new 4-tuple is small (e.g. a bare PING), so
   the path starts with anti_ampl_limit of only a few hundred bytes.
2. The server sends an unpadded PATH_CHALLENGE (padding is refused
   because anti_ampl_limit <= max_datagram_size), and the peer answers.
3. on_path_resp_received sets verified_peer_address, which freezes
   anti_ampl_limit; the path is promoted to ValidatingMTU and probes
   again, needing a challenge padded to MIN_CLIENT_INITIAL_LEN.
4. need_expand_padding_frames still compares the frozen limit against
   max_datagram_size and refuses the padding — forever. The path never
   reaches Validated, never becomes active, and the server keeps
   sending user data to the stale address.

Fix: skip the anti-amplification checks in both helpers once the peer
address is verified, matching the semantics of the other three helpers.
Address-validated paths are exempt from the 3x limit per RFC 9000
Section 8; the MTU-validating padded challenge is then allowed out and
validation completes.

Found while adding server-side NAT rebind handling; covered by the
conn_multipath_nat_rebind test added in a follow-up commit (the test
deadlocks at ValidatingMTU without this fix).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant