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 — Auto-port 5.0: Fix MQTT decoder size check after variable header replay by netty-project-bot · Pull Request #16839 · netty/netty

Conversation

@netty-project-bot

@netty-project-bot netty-project-bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Auto-port of #16787 to 5.0
Cherry-picked commit: 72df658


Problem

The MQTT decoder can reject valid packets after the CVE-2026-44248 fix when several MQTT packets are present in the same cumulation buffer. If the current packet's variable header needs a replay, the decoder compares the total readable bytes in the buffer against maxBytesInMessage, so later packets can make the current in-limit packet look too large.

Root Cause

READ_VARIABLE_HEADER recorded buffer.readableBytes() before decoding the variable header. That value is the cumulation's total readable bytes, not the current MQTT packet's declared remaining length. When decodeVariableHeader throws Signal.REPLAY, the too-large decision must be based on bytesRemainingBeforeVariableHeader for the current packet.

Fix

  • Use bytesRemainingBeforeVariableHeader when deciding whether to swallow Signal.REPLAY and raise TooLongFrameException.
  • Continue replaying when the current packet is within maxBytesInMessage, even if the cumulation contains additional bytes for following packets.

Tests Added

Change Point Test
Variable-header replay uses the current packet size instead of total cumulation bytes for the too-long check testPublishMessageIncompleteVariableHeaderDoesNotUseCumulationSizeForTooLongCheck() verifies an incomplete in-limit PUBLISH variable header with extra cumulated PINGREQ packets does not emit an invalid message
Oversized current packets still fail during variable-header replay testPublishMessageIncompleteVariableHeaderStillFailsWhenCurrentPacketTooLarge() verifies an incomplete PUBLISH whose own remaining length exceeds maxBytesInMessage still emits a TooLongFrameException

Impact

This restores decoding for valid in-limit MQTT packets batched in the same buffer while preserving the CVE fix: packets whose declared remaining length exceeds maxBytesInMessage still fail with TooLongFrameException even if variable-header decoding requests replay.

Fixes #16776

Sorry, something went wrong.

Uh oh!

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

All reactions
@daguimu @netty-project-bot
Fix MQTT decoder size check after variable header replay (#16787)
7523949
## Problem

The MQTT decoder can reject valid packets after the CVE-2026-44248 fix
when several MQTT packets are present in the same cumulation buffer. If
the current packet's variable header needs a replay, the decoder
compares the total readable bytes in the buffer against
`maxBytesInMessage`, so later packets can make the current in-limit
packet look too large.

## Root Cause

`READ_VARIABLE_HEADER` recorded `buffer.readableBytes()` before decoding
the variable header. That value is the cumulation's total readable
bytes, not the current MQTT packet's declared remaining length. When
`decodeVariableHeader` throws `Signal.REPLAY`, the too-large decision
must be based on `bytesRemainingBeforeVariableHeader` for the current
packet.

## Fix

- Use `bytesRemainingBeforeVariableHeader` when deciding whether to
swallow `Signal.REPLAY` and raise `TooLongFrameException`.
- Continue replaying when the current packet is within
`maxBytesInMessage`, even if the cumulation contains additional bytes
for following packets.

## Tests Added

| Change Point | Test |
|-------------|------|
| Variable-header replay uses the current packet size instead of total
cumulation bytes for the too-long check |
`testPublishMessageIncompleteVariableHeaderDoesNotUseCumulationSizeForTooLongCheck()`
verifies an incomplete in-limit PUBLISH variable header with extra
cumulated PINGREQ packets does not emit an invalid message |
| Oversized current packets still fail during variable-header replay |
`testPublishMessageIncompleteVariableHeaderStillFailsWhenCurrentPacketTooLarge()`
verifies an incomplete PUBLISH whose own remaining length exceeds
`maxBytesInMessage` still emits a `TooLongFrameException` |

## Impact

This restores decoding for valid in-limit MQTT packets batched in the
same buffer while preserving the CVE fix: packets whose declared
remaining length exceeds `maxBytesInMessage` still fail with
`TooLongFrameException` even if variable-header decoding requests
replay.

Fixes #16776

(cherry picked from commit 72df658)
@netty-project-bot netty-project-bot mentioned this pull request May 20, 2026
Fix MQTT decoder size check after variable header replay #16787
Merged
@chrisvest chrisvest added this to the 5.0.0.Final milestone May 20, 2026
@chrisvest
chrisvest enabled auto-merge (squash) May 20, 2026 18:34
@chrisvest

chrisvest commented May 21, 2026

Copy link
Copy Markdown
Member

I think this has to be redone for 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

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

@chrisvest chrisvest closed this May 21, 2026
auto-merge was automatically disabled May 21, 2026 18:07

Pull request was closed

@chrisvest
chrisvest deleted the auto-port-pr-16787-to-5.0 branch May 21, 2026 18:08
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

5.0.0.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

@netty-project-bot @chrisvest @daguimu
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.