Skip to content

QUIC: process the packets coalesced after one that has no keys - #241

Draft
deadcaf3 wants to merge 2 commits into
apple:mainfrom
deadcaf3:fix-coalesced-undecryptable-packet
Draft

deadcaf3 wants to merge 2 commits into
apple:mainfrom
deadcaf3:fix-coalesced-undecryptable-packet

Conversation

@deadcaf3

@deadcaf3 deadcaf3 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

When a datagram carries several QUIC packets and we can't decrypt one of them because its keys are gone or not installed yet, we drop everything after it. RFC 9000 Section 12.2 says the remaining packets must still be processed.

PacketParser.parse now skips such a packet using the Length in its long header and carries on with the rest of the datagram.

  • Only packets with missing keys are covered. A packet that has keys but fails decryption still ends the datagram, as before; ideally that case should be tackled separately.
  • Two new tests send an Initial followed by a 1-RTT packet in one datagram after the Initial keys were discarded, one per direction. Both fail without the fix.

if !skippedPacket {
return packet
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand needing to claim the frame we did not open, but do we need to do this loop above? Can we let it signal to the out loops in handleInbound that we need to continueProcessing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prototyped what you said, ran the tests, they pass, your suggestion is better than current state; out loop in handleInbound already iterates coalesced packets. Letting parse report the skip and have existing loop take the next packet seems to simplify things yea.

At the same time, outer loop bumps the idle and keep alive timestamps after every packet that returns "continue". A skipped packet must not bump it. RFC 9000 Section 10.1 restarts the idle timer on a packet that was successfully processed and today an undecryptable packet doesnt bump it. Without a guard, anyone who knows the connection DCID could keep the connection from idling out by sending a dead initial with one trailing byte. The prototype guards that with one if, ill push that patch shortly

@deadcaf3
deadcaf3 force-pushed the fix-coalesced-undecryptable-packet branch from 965c72c to 8de98b7 Compare October 13, 2026 15:25
@deadcaf3
deadcaf3 marked this pull request as ready for review October 13, 2026 15:25
coalesced: coalesced,
isServerConnection: isServerConnection,
packetParser: &packetParser,
skippedPacket: &skippedPacket,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need skippedPacket here then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the inout, no. The loop still needs to tell "skipped" from "processed" so it doesnt refresh lastPacketReceivedTimestamp on a packet it couldn't open (RFC 9000 10.1 only restarts the idle timer on a successfully processed packet).

I've changed handleInboundPacket to return .processed / .skipped / .stop instead of Bool plus a flag, so this call site reads one value; the flag only lives between the parser and handleInboundPacket now; change in b78aeb8 now

- A long-header packet whose keys are not installed, or were already
  discarded, ended processing of the whole datagram, so a packet
  coalesced after it was dropped. RFC 9000 Section 12.2 requires the
  remaining packets to be processed
- PacketParser.parse now steps over such a packet using the length in
  its header and reports the skip, so QUICConnection.handleInbound goes
  on to the next coalesced packet without restarting the idle timer. A
  packet that has keys but fails decryption still ends the datagram, as
  before
- Add tests that deliver an Initial packet followed by a 1-RTT packet in
  one datagram after both ends discarded their Initial keys
@deadcaf3
deadcaf3 force-pushed the fix-coalesced-undecryptable-packet branch from 8de98b7 to b78aeb8 Compare October 14, 2026 11:08
@deadcaf3
deadcaf3 requested a review from agnosticdev October 15, 2026 10:29
@deadcaf3
deadcaf3 marked this pull request as draft October 16, 2026 20:05
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.

2 participants