Files
amethyst/quic
Claude ce8d852518 fix(quic): final stabilization sweep — CID picking, atomic gates, defensive checks
Round 5 of the audit follow-ups. The remaining low-leverage items
from the original audit all addressed in one pass.

* PathValidator: pick the smallest spare CID sequence number rather
  than LinkedHashMap insertion order. RFC 9000 §19.15 lets the peer
  issue NEW_CONNECTION_ID out of sequence (e.g. retransmits arriving
  after newer offers); insertion-order picking would land on
  whichever offer arrived first instead of the lowest seq, drifting
  away from the RFC-expected ordering. forceRotateToHigherSequence
  also now filters >= retirePriorToWatermark explicitly so we never
  pick a sequence below the watermark even if the pool somehow holds
  one.
* QuicWebTransportSessionState.close: driver.wakeup() AFTER enqueuing
  the WT_CLOSE_SESSION capsule + FIN but BEFORE driver.close, so the
  capsule actually reaches the wire instead of being short-circuited
  by the driver shutdown. Pre-fix the peer saw an abrupt UDP-level
  tear-down with no application-error-code surfaced.
* QuicStream.resetStream / stopSending: synchronized(this) atomic
  CAS for the "first call wins" gate. Pre-fix two concurrent callers
  could both observe `resetState == null` and both write — the
  second caller's errorCode would clobber the first while
  resetEmitPending was already set, so the writer emitted the
  RESET_STREAM with whichever value landed last.
* Http3Settings.decodeBody: per-id value range checks. A peer that
  advertises e.g. MAX_FIELD_SECTION_SIZE = 2^60 could otherwise
  drive our encoder into unbounded heap. Bounds chosen above any
  legitimate value (1 GiB for table-capacity / field-section caps,
  1 for boolean flags) and below 2^32 for unknown ids.
* Privatize crypto-relevant static byte arrays:
  InitialSecrets.V1_INITIAL_SALT, RetryPacket.V1_RETRY_KEY,
  RetryPacket.V1_RETRY_NONCE. Pre-fix these were public mutable
  ByteArrays — any caller could stomp on them, and any toString /
  reflection would leak the bytes. Crypto material doesn't need to
  be reachable outside the deriving / sealing path.
* peekHeader length cast: re-verified as already safe (lengthRaw is
  bounded by r.remaining before .toInt() — Int.MAX_VALUE ceiling
  enforced).

All 269 :quic:jvmTest tests pass. BUILD SUCCESSFUL in 2m 17s.

https://claude.ai/code/session_01AhGvbMV8uPRse3TmAGaddM
2026-05-08 23:57:34 +00:00
..