Skip to content

in_mqtt: fix OOB read from hardcoded remaining length overhead [Backport to 4.2]#11899

Merged
cosmo0920 merged 1 commit into
4.2from
fix/mqtt-remaining-length-oob-4.2
Jun 3, 2026
Merged

in_mqtt: fix OOB read from hardcoded remaining length overhead [Backport to 4.2]#11899
cosmo0920 merged 1 commit into
4.2from
fix/mqtt-remaining-length-oob-4.2

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

Backporting of #11853.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

The MQTT packet parser used hardcoded +2/-2 to account for the fixed
header size (1 type byte + 1 remaining-length byte). This is only
correct when the remaining length fits in a single byte (0-127).
For remaining lengths 128+, the encoding uses 2-4 bytes, making the
actual overhead 3-5 bytes. Replace the constant with the computed
header size (buf_pos - pos + 1) so the bounds checks account for the
actual number of remaining-length bytes consumed.

Signed-off-by: Tristan <tristan@talencesecurity.com>
@cosmo0920 cosmo0920 requested a review from edsiper as a code owner June 3, 2026 01:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eec1ed9e-9f41-4055-9564-0a0c1ea51a0f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mqtt-remaining-length-oob-4.2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cosmo0920 cosmo0920 added this to the Fluent Bit v4.2.5 milestone Jun 3, 2026
@cosmo0920 cosmo0920 merged commit 5c93e3e into 4.2 Jun 3, 2026
25 checks passed
@cosmo0920 cosmo0920 deleted the fix/mqtt-remaining-length-oob-4.2 branch June 3, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant