Codrio BLE: ignore packet if data allocation fails (CVE-2024-48985) - #384
Merged
multiplemonomials merged 1 commit intoNov 21, 2024
Merged
Conversation
Author
|
This PR fixes CVE-2024-48985 |
multiplemonomials
approved these changes
Nov 21, 2024
multiplemonomials
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
hciTrSerialRxIncomingparses 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_ASSERTis 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_HEADERstate for longer than intended. Because every iteration of the loop writes another byte tohdrRxand the intended exit condition for this state has been passed, it will continue writing tohdrRxpast 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