-
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
A command with no data struct will cause use of an un-initialized TLV reader #10501
Comments
In particular, we need to decide how to represent "there is no command data here" when calling |
Our current What should be the spec defined behavior here? Is not sending the data element permitted? Looking at the spec, it's quite mum on this... |
I'd be fine with just initializing the TLVReader with a null buffer. That ensures that subsequent decode will fail. This also reduces the API churn. |
You're assuming that the sender is using our code. And not being malicious. We should not be assuming that. |
We can't defer this: this is a known bug where we read un-initialized memory and then act on it, which is really bad from a security perspective. |
I think this issue is already fixed in previous refactors
connectedhomeip/src/app/CommandHandler.cpp Lines 97 to 103 in 0861153
(Which ensures
connectedhomeip/src/app/CommandHandler.cpp Lines 128 to 136 in 0861153
(Which ensures it is holding exactly one list (as we only supports one request today))
connectedhomeip/src/app/CommandHandler.cpp Lines 305 to 326 in 0861153
This should ensure the payload passed to DispatchCommand is a valid reader. For group writes, we also have connectedhomeip/src/app/CommandHandler.cpp Lines 362 to 370 in 0861153
|
It does not. What happens if Group commands have the same problem, as you note. |
Attaching a change to the commands test that shows the problem. The decoding of the command either fails if there is no fields struct (which the spec allows), if the random "control byte" value is not of type struct, or we hit ASAN errors trying to decode if the control byte happens to be "struct". Which actually points out a second problem: validly not including a field struct at all for a command that has no fields will fail decode! This is an absolute must-fix for spec compliance. |
Problem
CommandHandler::ProcessCommandDataElement
does this:But now commandDataReader is not initialized, and we proceed to pass it to
DispatchSingleClusterCommand
which will try to read from it.Proposed Solution
@yunhanw-google @mrjerryjohns
The text was updated successfully, but these errors were encountered: