bound key material lengths in KeyMaterialCDRDeserialize#6425
Open
alhudz wants to merge 1 commit into
Open
Conversation
Signed-off-by: alhudz <al.hudz.k@gmail.com>
Author
|
gentle ping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
KeyMaterialCDRDeserializeparses thedds.cryp.keymatbinary property carried in aCryptoTokensent by a remote participant, so every length byte in it crosses a trust boundary.Repro:join a secured domain and send a participant/datawriter/datareaderCryptoTokenwhose first sequence length byte (master_salt) is0xFFfollowed by enough bytes.Cause:eachkey_lenis read straight off the wire and handed tomemcpyinto the 32-bytestd::arraymembers (master_salt,master_sender_key,master_receiver_specific_key) with no check, and the CDR buffer size is never validated before indexing, so akey_lenup to 255 writes past the destination (ASan reports astack-buffer-overflow,WRITE of size 255).Fix:validate the available CDR size at each step and reject anykey_lenlarger than its destination array, returningfalseso the threeset_remote_*_crypto_tokenscallers drop the malformed token.The validation lives in the deserialiser itself rather than the callers, since the callers only have the opaque token bytes.
Contributor Checklist
versions.mdfile (if applicable).