Repository navigation
fix: panic on Initial packets with a zero-length DCID - #5
Merged
Merged
Conversation
A remote unauthenticated attacker can crash a QUIC server with only two packets: 1. Send an Initial packet with a zero-length DCID and a garbage token, which triggers the server to issue a Retry token embedding the zero-length DCID as the odcid. 2. Replay the poisoned Retry token; the decoded odcid is restored to None, and the server panics on `token.odcid.unwrap()`. This patch applies defense in depth: - endpoint: drop the first Initial packet with a DCID shorter than 8 bytes, as required by RFC 9000 Section 7.2. The DCID of a subsequent Initial packet carrying a valid Retry token is not affected. - endpoint: replace `token.odcid.unwrap()` with explicit error handling. - token: reject encoding/decoding Retry tokens whose odcid is shorter than 8 bytes, as required by RFC 9000 Section 8.1.2.1. - tests: fix missing assertions in address_token tests and add regression tests for the poisoned tokens.
- Pin typos-cli to 1.42.3: the latest release (1.50.3) requires rustc 1.95, which is newer than the toolchain pinned in this repository (1.90.0). 1.42.3 is the newest release whose MSRV (1.87) is compatible. - Skip the Codecov upload step when no CODECOV_TOKEN is available (e.g. on forks, which do not inherit upstream secrets), instead of failing the whole unit testing job.
- Remove the unused MAX_CID_LEN import in token.rs. - Correct the RFC 9000 reference: Retry tokens are described in Section 8.1.2 (Address Validation Using Retry Packets); there is no Section 8.1.2.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a remotely triggerable panic (unauthenticated DoS) in the QUIC server. An attacker crashes the server with two packets:
send_retry, which signs a Retry token embedding the zero-length DCID as the odcid.odcid = None, andendpoint.rspanics ontoken.odcid.unwrap().Root cause (three overlapping defects)
packet.rsdid not enforce the RFC 9000 Section 7.2 requirement that the first client Initial carries a DCID of at least 8 bytes.token.rsencoded/decoded Retry tokens with a zero-length odcid (Some(empty)→ written as len 0 → decoded back asNone).endpoint.rsconsumed the decoded odcid withunwrap()under an incorrect "always success" assumption.Fix (defense in depth)
unwrap()with explicit error handling returningInvalidToken.encode()rejects Retry tokens whose odcid is shorter than 8 bytes;decode()rejects such tokens asInvalidToken(RFC 9000 Section 8.1.2.1).assert!inaddress_tokentests (which let this inconsistency slip through), move now-invalid zero-length odcid cases to the invalid list, and add regression tests: hand-crafted poisoned tokens must be rejected by decode, and Initial packets with a zero-length DCID must be dropped without side effects.Validation
cargo test --lib: 560 passed, 0 failedcargo fmt -- --check: cleancargo clippy --lib --tests: no new warnings