GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't count insertions twice in QPACK Insert Count Increments by allthingssecurity · Pull Request #17756 · netty/netty

Conversation

@allthingssecurity

@allthingssecurity allthingssecurity commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Motivation:

When the QPACK decoder resumes a blocked stream, it decodes the header block and sends a Section Acknowledgment. As described in RFC 9204, section 4.4.1, the encoder then raises its Known Received Count to the Required Insert Count of that header block.

QpackDecoder did not take this into account. lastAckInsertCount was only updated when an Insert Count Increment was sent, so the next Insert Count Increment included the insertions that the Section Acknowledgment had already acknowledged.

Example, with the dynamic table and blocked streams enabled:

  1. A header block on stream 0 references the first dynamic table entry before the decoder received it, so stream 0 is blocked.
  2. The first insertion arrives. Stream 0 is resumed and a Section Acknowledgment is sent (the encoder's Known Received Count is now 1). ackEachInsert() skips the Insert Count Increment, as the Section Acknowledgment covered it, but lastAckInsertCount stays 0.
  3. The second insertion arrives and the decoder sends an Insert Count Increment of 2 instead of 1.

The encoder's Known Received Count (3) is now larger than the number of insertions (2). RFC 9204, section 4.4.3, requires the encoder to treat this as a connection error of type QPACK_DECODER_STREAM_ERROR. Netty's own QpackEncoder does that (INVALID_KNOW_RECEIVED_COUNT_INCREMENT), and the connection is closed. This happens every time a blocked stream is resumed and another insertion follows, which is the normal case when a peer uses blocking references.

Modification:

  • Update lastAckInsertCount when a Section Acknowledgment is sent for a header block with a larger Required Insert Count.
  • Don't send an Insert Count Increment when all insertions were acknowledged already, even if the QpackDecoderStateSyncStrategy asks for one. An increment of 0 is a connection error too, and a custom strategy can return true from entryAdded(...) at any time.
  • Add QpackDecoderTest.insertCountIncrementDoesNotRepeatInsertsAcknowledgedBySection. It blocks a stream on the first insertion, adds two insertions, replays the instructions written to the decoder stream the way an encoder does, and checks that the Known Received Count is 2 and that no increment is 0. It runs with ackEachInsert() and with a strategy that acknowledges every insertion.
  • QpackEncoderDecoderTest.duplicateWithBlockedStreams encoded a header block that is never decoded on the same stream as the header block that is decoded. The encoder applied the Section Acknowledgment to the first one (Section Acknowledgments of a stream are processed in order), and the extra Insert Count Increment made up for it. The test now uses another stream for the header block that is never decoded.

Result:

Insert Count Increments no longer acknowledge insertions twice, and the connection is no longer closed with QPACK_DECODER_STREAM_ERROR after a blocked stream was resumed.

  • Without the change to QpackDecoder, both cases of the new test fail (Expected: is <2> but: was <3>). With it, they pass.
  • All test classes of codec-http3 that use QpackDecoder pass (Http3FrameCodecTest, Http3RequestStreamValidationHandlerTest, Http3UnidirectionalStreamInboundHandlerTest, QpackDecoderDynamicTableTest, QpackDecoderHandlerTest, QpackDecoderTest, QpackEncoderDecoderTest, QpackEncoderHandlerTest, QpackStreamHandlerTest: 522 tests, 13 skipped), with -Dio.netty.leakDetection.level=paranoid and without any LEAK: report. Checkstyle and the API check pass.

Prepared with Claude Code on behalf of allthingssecurity.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
allthingssecurity and others added 4 commits October 4, 2026 08:16
@allthingssecurity @claude
Don't count insertions twice in QPACK Insert Count Increments
581f8ff
Motivation:

When the QPACK decoder resumes a blocked stream it decodes the header block and sends a Section Acknowledgment. As described in RFC 9204, section 4.4.1, the encoder then raises its Known Received Count to the Required Insert Count of that header block. `QpackDecoder` did not take this into account: `lastAckInsertCount` was only updated when an Insert Count Increment was sent, so the next Insert Count Increment included the insertions that the Section Acknowledgment had acknowledged already.

For example, a stream is blocked on the first insertion. The first insertion resumes it (Section Acknowledgment, Known Received Count = 1) and the second insertion sends an Insert Count Increment of 2 instead of 1. The encoder's Known Received Count (3) is now larger than the number of insertions (2), which RFC 9204, section 4.4.3, requires the encoder to treat as a connection error of type QPACK_DECODER_STREAM_ERROR. Netty's own `QpackEncoder` does so and the connection is closed. This happens whenever the dynamic table and blocked streams are enabled and the peer references an entry the decoder did not receive yet.

Modification:

- Update `lastAckInsertCount` when a Section Acknowledgment is sent for a header block with a larger Required Insert Count.
- Don't send an Insert Count Increment when all insertions were acknowledged already, even if the `QpackDecoderStateSyncStrategy` asks for it, as an increment of 0 is an error as well.
- Add `QpackDecoderTest.insertCountIncrementDoesNotRepeatInsertsAcknowledgedBySection`.
- `QpackEncoderDecoderTest.duplicateWithBlockedStreams` encoded a header block that is never decoded on the same stream as the one that is decoded, so the encoder applied the Section Acknowledgment to the wrong header block. The extra Insert Count Increment hid this. Use another stream for the header block that is never decoded.

Result:

The decoder's Insert Count Increments no longer acknowledge insertions twice, and the connection is not closed with QPACK_DECODER_STREAM_ERROR after a blocked stream was resumed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allthingssecurity @claude
Merge branch '4.2' into fix-qpack-insert-count-increment-after-sectio…
8478b2d
…n-ack

Resolve the conflict in QpackDecoderTest: keep both the new test of this
branch and blockedStreamsCountReleasedAfterStreamAbandoned from 4.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@normanmaurer
Merge branch '4.2' into fix-qpack-insert-count-increment-after-sectio…
f26996e
…n-ack
@normanmaurer @claude
Test that a lower Section Acknowledgment does not lower the acknowled…
b1760ab
…ged insert count

Motivation:

QpackDecoder only raises lastAckInsertCount when a Section Acknowledgment is
sent for a larger Required Insert Count. Nothing covered a Section
Acknowledgment for a lower Required Insert Count, which must not move
lastAckInsertCount back.

Modification:

- Add QpackDecoderTest.sectionAcknowledgmentOfLowerRequiredInsertCountDoesNotLowerAcknowledgedInsertCount.
- Let knownReceivedCountOfEncoder(...) take the Required Insert Count per stream
  instead of a single value for all Section Acknowledgments.

Result:

Removing the `requiredInsertCount > lastAckInsertCount` check fails the new test.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@normanmaurer

normanmaurer commented Oct 15, 2026

Copy link
Copy Markdown
Member

@allthingssecurity added a missing test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.20.Final milestone Oct 15, 2026
@normanmaurer normanmaurer added the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 15, 2026
@testlens-app

testlens-app Bot commented Oct 15, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: b1760ab
▶️ Tests: 42032 executed
⚪️ Checks: 28/28 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer merged commit 098e103 into netty:4.2 Oct 19, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17907

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Oct 19, 2026
Auto-port 5.0: Don't count insertions twice in QPACK Insert Count Increments #17907
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 19, 2026
normanmaurer added a commit that referenced this pull request Oct 19, 2026
@netty-project-bot @allthingssecurity @normanmaurer
Auto-port 5.0: Don't count insertions twice in QPACK Insert Count Inc…
bfddb34
…rements (#17907)

Auto-port of #17756 to 5.0
Cherry-picked commit: 098e103

---
Motivation:

When the QPACK decoder resumes a blocked stream, it decodes the header
block and sends a Section Acknowledgment. As described in RFC 9204,
section 4.4.1, the encoder then raises its Known Received Count to the
Required Insert Count of that header block.

`QpackDecoder` did not take this into account. `lastAckInsertCount` was
only updated when an Insert Count Increment was sent, so the next Insert
Count Increment included the insertions that the Section Acknowledgment
had already acknowledged.

Example, with the dynamic table and blocked streams enabled:

1. A header block on stream 0 references the first dynamic table entry
before the decoder received it, so stream 0 is blocked.
2. The first insertion arrives. Stream 0 is resumed and a Section
Acknowledgment is sent (the encoder's Known Received Count is now 1).
`ackEachInsert()` skips the Insert Count Increment, as the Section
Acknowledgment covered it, but `lastAckInsertCount` stays 0.
3. The second insertion arrives and the decoder sends an Insert Count
Increment of 2 instead of 1.

The encoder's Known Received Count (3) is now larger than the number of
insertions (2). RFC 9204, section 4.4.3, requires the encoder to treat
this as a connection error of type QPACK_DECODER_STREAM_ERROR. Netty's
own `QpackEncoder` does that (`INVALID_KNOW_RECEIVED_COUNT_INCREMENT`),
and the connection is closed. This happens every time a blocked stream
is resumed and another insertion follows, which is the normal case when
a peer uses blocking references.

Modification:

- Update `lastAckInsertCount` when a Section Acknowledgment is sent for
a header block with a larger Required Insert Count.
- Don't send an Insert Count Increment when all insertions were
acknowledged already, even if the `QpackDecoderStateSyncStrategy` asks
for one. An increment of 0 is a connection error too, and a custom
strategy can return `true` from `entryAdded(...)` at any time.
- Add
`QpackDecoderTest.insertCountIncrementDoesNotRepeatInsertsAcknowledgedBySection`.
It blocks a stream on the first insertion, adds two insertions, replays
the instructions written to the decoder stream the way an encoder does,
and checks that the Known Received Count is 2 and that no increment is
0. It runs with `ackEachInsert()` and with a strategy that acknowledges
every insertion.
- `QpackEncoderDecoderTest.duplicateWithBlockedStreams` encoded a header
block that is never decoded on the same stream as the header block that
is decoded. The encoder applied the Section Acknowledgment to the first
one (Section Acknowledgments of a stream are processed in order), and
the extra Insert Count Increment made up for it. The test now uses
another stream for the header block that is never decoded.

Result:

Insert Count Increments no longer acknowledge insertions twice, and the
connection is no longer closed with QPACK_DECODER_STREAM_ERROR after a
blocked stream was resumed.


Co-authored-by: allthingssecurity <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.20.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@allthingssecurity @normanmaurer @netty-project-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.