-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix Global Buffer Overflow in AudioOutputManager.cpp #36858
Fix Global Buffer Overflow in AudioOutputManager.cpp #36858
Conversation
PR #36858: Size comparison from cfdaf79 to 7783af2 Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BoB13-Matter please add a Testing
section to your PR summary:
- how was this tested
- since I see no unit tests changes, I assume this was manual. Please explain why automated testing is impossible (clusters are generally not built for unit tests ... but also why can't we have yaml or python tests?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #36875 for testing this. The PR description does describe how to reproduce the issue so assuming manual and the delta is small.
Description
This pull request fixes a global-buffer-overflow in the
AudioOutputManager::HandleRenameOutput
function of the AudioOutput cluster.Similar to PR #36856 for the MediaInput cluster, this bug arises from an unchecked memcpy operation that allows oversized input to overflow a fixed-size buffer.
The mCharDataBuffer in AudioOutputManager is a statically allocated buffer with a fixed size of 32 for each entry:
However, the HandleRenameOutput function does not validate the size of the input string (name.size()) before copying it into the buffer. If the input string exceeds 32 bytes, this leads to a buffer overflow, as demonstrated in the reproduction steps.
Reproduce
Run the following commands in separate terminals:
tv-app:
chip-tool:
Execute the
rename-output
command in the AudioOutput cluster with a long string argument:Observe the AddressSanitizier Log
ASAN Log.txt
Changes
The fix applies the same solution introduced in PR #36856. A size check is added before the memcpy operation to ensure the input does not exceed the buffer's capacity.
Updated HandleRenameOutput function: