Codrio BLE: ignore packet if data allocation fails (CVE-2024-48985) #384
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.
Summary of changes
hciTrSerialRxIncoming
parses incoming hci packets. It takes two bytes from the packet header and tries to allocate a buffer based on the packet size contained in those bytes. There is no logic to account for the case of an allocate failing. IfWSF_ASSERT
is not enabled (it isn't by default), the packet isn't dropped either.mbed-os/connectivity/FEATURE_BLE/source/cordio/stack_adaptation/hci_tr.c
Line 200 in 54e8693
This means that the function will stay in it's
HCI_RX_STATE_HEADER
state for longer than intended. Because every iteration of the loop writes another byte tohdrRx
and the intended exit condition for this state has been passed, it will continue writing tohdrRx
past it's bounds, causing a buffer overflow.This fix handles the failed allocation by resetting the parser and exiting the function, similar to #374.
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results