-
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
[BUG] Crash in ProcessCommandDataIB due to incorrect endpoint validation and VerifyOrDie assertion #37184
Comments
That's a test-only implementation, not the one used by real code...
That is also a test-only implementation. On tip I can't reproduce the crash (because that verification code was removed), but what I can reproduce is that the server is incorrectly responding with SUCCESS for cluster 0x34 on a non-existent endpoint. If I use cluster 0x06, it correctly responds with UNSUPPORTED_ENDPOINT. Looks like the issue is only there for clusters implemented via CommandHandlerInterface, perhaps? Ah, yes, As in, this bit:
needs to be at the very top of the method. Same thing for |
Thanks for your reply! The root cause analysis I provided may be insufficient and inaccurate and I marked not sure. I only roughly reviewed the code and analysis, but I downloaded the v1.4 branch code (commit: 57ff3e6) and compiled the all-cluster-app in 1.4 version. It incorrectly responded with SUCCESS for cluster 0x34 on a nonexistent endpoint. I searched the v1.4 branch code with CodegenDataModelProvider related file and found that the tested code does not exist, yet the problem still occurs. There might be a logic issue when deal with command message. |
Looking at master with the script: ./chip-tool pairing onnetwork 1 20202021
./chip-tool any command-by-id 0x34 0x0 '{"0": 0}' 1 0x34 I do indeed see kSuccess for what it thinks is a SoftwareDiagnostics::ResetWatermarks. I am unsure about the fuzzing bit.
|
What is happening is that SoftwareDiagnostics is on ALL endpoints: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp#L61 So when Will fix it so that we will check for endpoint and cluster being valid. |
Read and write attribute are fine because they attempt to find the metadata for the attribute first. |
I created a fix, however @agatah2333 I do not see any crash. The underlying cause was that a wildcard endpoint was accepted for the CommandHandlerInterface, however processing was still ok. I imagine maybe a CHI that relies on valid endpoints would somehow crash... but unsure. Or maybe the latest (non 1.4) code is more resilient. |
Crash may be in 1.4 because it still had DataModelProvider as optional. The code looks like: auto provider = GetDataModelProvider();
if (provider->GetAcceptedCommandInfo(aCommandPath).has_value())
{
#if CHIP_CONFIG_USE_EMBER_DATA_MODEL
VerifyOrDie(ServerClusterCommandExists(aCommandPath) == Protocols::InteractionModel::Status::Success);
#endif
return Protocols::InteractionModel::Status::Success;
} That looks to align ember logic with datamodel::Provider logic, however these do NOT align (CHI finds the command however ember knows that this is not a valid path). the 1.4 fix probably has to be different. |
Reproduction steps
Description
When processing an InvokeCommandRequest with a non-existent endpoint (0x34), the code incorrectly validates the endpoint's existence and crashes with a VerifyOrDie assertion.
The payload that causes the issue is as follows:
Decoded Log
The decoded log of the issue is as follows:
Expected Behavior
After sending the message, the expected behavior is that the system should return an "Endpoint Not Found" error. For instance, the command: ./chip-tool descriptor read server-list 0x654324 0x34 correctly returns UNSUPPORTED_ENDPOINT.
Actual Behavior
The all-cluster-app instead returns: status = 0x00 (SUCCESS)
When fuzzing the all-cluster-app, it crashes with a SIGABRT signal and displays the following error:
reproduce(After 1.4):
Environment
CHIP SDK Version: After 1.4
Application: all-cluster-app
Root Cause(Not Sure)
For an non-existent value like endpoint=0x34:
emberAfEndpointIndexIsEnabled only checks if index is less than 3, considering it valid if index<3
then emberAfContainsServerFromIndex directly returns true, without any validation of whether the endpoint and cluster exist
Bug prevalence
each time
GitHub hash of the SDK that was being used
57ff3e6
Platform
core
Platform Version(s)
1.4
Anything else?
No response
The text was updated successfully, but these errors were encountered: