-
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] one unsigned-integer-overflow bug #36804
Comments
@agatah2333 How is this undefined behavior? Decrement for an unsigned type past 0 is very much defined by the C++ standard, last I checked. It turns into the max representable value of the type. And since all uses of mCurReadHandlerIdx are either mod This seems like a false positive, in terms of being a security issue, on part of UBSan (and it's odd that it claims undefined behavior when behavior is in fact defined....) |
Thanks for your reply! When mCurReadHandlerIdx is zero, executing --mCurReadHandlerIdx; results in an unsigned integer underflow, setting its value to the maximum representable by uint32_t. While this behavior is defined in C++, it can lead to logical errors or unexpected behaviors, especially in indexing or counting contexts. We reported this mCurReadHandlerIdx issue after encountering the "Unsigned Integer Overflow" in chip-all-clusters-app-fuzzing within chip::Encoding::BigEndian::BufferWriter::EndianPut(this=0x000055555ac33290, x=12, size=0) at BufferWriter.cpp:81:16. This issue has been patched by #35580, thanks to @Alami-Amine. Could you please let me know why this bug was patched in Matter 1.4 but not backported to Matter 1.3, and why it was considered necessary to patch this code? UBSan almost confused us as it reported so many positives. ![]() |
Hello @agatah2333
|
I believe our change was to be able to enable UBSAN without what we consider "false positives" showing up. We have identified no security issue or bug due to this code. @agatah2333 if you have a concrete example for this bug happening (as an exploit) please share it (probably via a CVE process because security issue). Otherwise wrapping behaviour on decrement is well defined behavior. |
Reproduction steps
Issue Summary
A unsigned integer overflow bug was discovered in the Matter SDK while running the Self-modify program @Chapoly1305. The bug manifests when the mCurReadHandlerIdx counter reaches 0 and attempts to decrement, causing undefined behavior.
Environment
Crash Analysis
The crash was detected by UndefinedBehaviorSanitizer (UBSAN) with the following error:
Stack Trace Analysis
Key call stack elements:
Root Cause
The bug occurs in the Engine::ResetReadHandlerTracker method when attempting to decrement mCurReadHandlerIdx which is an unsigned integer (uint32_t). When the value is 0, the decrement operation causes an overflow.
Problematic Code
The issue arises because:
Impact
This bug can lead to:
Proposed Solutions
Short-term Fix
connectedhomeip/src/app/reporting/Engine.h
Line 117 in 9c8a552
Bug prevalence
each time
GitHub hash of the SDK that was being used
561d23d
Platform
core
Platform Version(s)
all versions
Anything else?
No response
The text was updated successfully, but these errors were encountered: