Skip to content

Fix property serialization bounds checks - #382

Merged
allanli4 merged 1 commit into
FreeRTOS:mainfrom
allanli4:fix/property-buffer-size-check
Aug 13, 2026
Merged

allanli4 merged 1 commit into
FreeRTOS:mainfrom
allanli4:fix/property-buffer-size-check

Conversation

@allanli4

@allanli4 allanli4 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Description

Fix property serialization bounds checks

Thank you XueDugu for reporting the issue.

Test Steps

  • Added test_MQTTPropAdd_ReasonString_BufferTooSmall to core_mqtt_prop_serializer_utest.c.
  • Added a CBMC proof test/cbmc/proofs/MQTTPropAdd_ReasonString/ covering the write path of addPropUtf8 via MQTTPropAdd_ReasonString.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

N/A

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@allanli4
allanli4 force-pushed the fix/property-buffer-size-check branch from 0726a29 to 474324f Compare August 5, 2026 22:27
@allanli4 allanli4 changed the title Account for property ID byte in MQTT v5 property buffer size check Harden property serialization bounds checks Aug 5, 2026
@allanli4 allanli4 changed the title Harden property serialization bounds checks Fix property serialization bounds checks Aug 5, 2026
@allanli4
allanli4 force-pushed the fix/property-buffer-size-check branch from 474324f to 736d841 Compare August 6, 2026 20:51
The size check reserved propertyLength + 2 bytes, but a serialized UTF-8
property occupies propertyLength + 3: one byte for the property ID, two for
the length prefix, and propertyLength for the string. A buffer advertised as
propertyLength + 2 was therefore accepted and written one byte past its end.

Reserve propertyLength + 3, and add a unit test and a CBMC proof for
MQTTPropAdd_ReasonString covering the boundary.
@allanli4
allanli4 force-pushed the fix/property-buffer-size-check branch from 736d841 to 519c77f Compare August 13, 2026 20:42
@allanli4
allanli4 merged commit 75711c0 into FreeRTOS:main Aug 13, 2026
20 of 22 checks passed
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.

3 participants