fix(ocb3): Fix asymmetric bounds check vulnerability in encrypt/decrypt#814
Closed
PrarthanaPurohit wants to merge 1 commit intoRustCrypto:masterfrom
Closed
Conversation
Member
|
This will be fixed as part of #765. I have more or less finished the code, but haven't opened a PR yet. P.S.: Please respect maintainers time and do not just dump LLM-generated slop without reviewing it. |
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.
🐛 Critical Security Fix: OCB3 Asymmetric Bounds Check Vulnerability
Problem
The OCB3 implementation had inconsistent bounds checking between encrypt and decrypt operations:
if (buffer.len() >= max_len) || (associated_data.len() >= max_len)if (buffer.len() > max_len) || (associated_data.len() > max_len)❌This asymmetry created a critical vulnerability where:
max_lenbytes that encryption would rejectmax_len = 1,073,741,824bytes with defaultL_TABLE_SIZE=26), thentz(i)function could cause out-of-bounds access toself.ll[ntz(i)]Solution
Changed the decrypt bounds check to match encrypt: