in_mqtt: fix OOB read from hardcoded remaining length overhead#11853
in_mqtt: fix OOB read from hardcoded remaining length overhead#11853TristanInSec wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe MQTT protocol parser refines remaining-length decoding by replacing fixed buffer-size assumptions with dynamic offset-based checks; it rewinds to the packet start and returns ChangesMQTT remaining-length parsing fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@TristanInSec would you please sign off the commits ? (DCO error / git commit -s ...) |
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>
a25128a to
66daf45
Compare
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.
Summary by CodeRabbit