Skip to content

Codrio BLE: ignore packet if data allocation fails (CVE-2024-48985) #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Diff-fusion
Copy link

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. If WSF_ASSERT is not enabled (it isn't by default), the packet isn't dropped either.

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 to hdrRx and the intended exit condition for this state has been passed, it will continue writing to hdrRx 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

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

@Diff-fusion
Copy link
Author

This PR fixes CVE-2024-48985

@Diff-fusion Diff-fusion changed the title Codrio BLE: ignore packet if data allocation fails Codrio BLE: ignore packet if data allocation fails (CVE-2024-48985) Nov 19, 2024
Copy link
Collaborator

@multiplemonomials multiplemonomials left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@multiplemonomials multiplemonomials merged commit 92df629 into mbed-ce:master Nov 21, 2024
52 checks passed
@Diff-fusion Diff-fusion deleted the fix-write2-hciTrSerialRxIncoming branch November 21, 2024 12:23
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.

2 participants