-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[groups] Fix #38823 - filter group keys by session_id during decrypt #39401
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
base: master
Are you sure you want to change the base?
Conversation
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.
Code Review
The pull request addresses a critical issue where group messages were being decrypted against all available keys, instead of filtering by session ID. The changes introduce a mechanism to derive the session ID from the key and only attempt decryption when the session IDs match. This significantly improves efficiency and security. The implementation appears sound, but I have a few suggestions for improvement.
Summary of Findings
- Missing Log Messages: Consider adding log messages for key context not found and session ID mismatch to aid in debugging.
- Potential Null Pointer Dereference: It might be beneficial to add a check to ensure that
keyContext
is valid before callingDeriveGroupSessionId
. - Inconsistent Logging: The logging statements for decryption attempts are placed inside a conditional compilation block, which might lead to inconsistent logging behavior.
Merge Readiness
The pull request effectively addresses the issue of filtering group keys by session ID during decryption. However, I recommend addressing the comments provided to improve debugging capabilities and ensure consistent logging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the medium severity issue should be addressed before merging.
184946e
to
ce941b1
Compare
…ring group message decrypt.
ce941b1
to
91e99ef
Compare
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.
Pull Request Overview
This PR addresses issue #38823 by ensuring that decryption for group messages is attempted only when the session ID in the packet header matches the hash of the decryption key.
- Updated header includes to use the appropriate provider and logging constants.
- Added retrieval of key context and a check to compare the key hash against the session ID to filter decryption attempts.
PR #39401: Size comparison from b1fc719 to 91e99ef Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
Fix #38823
The receive handler for a group message can try to decrypt against multiple keys, but right now it tries every key when it should only try keys where session_id matches hash(key).
This change will extract the hash of the key from CryptoContext and only attempt decryption when that is equal to the session_id in PacketHeader.
Testing