Repository navigation
Size cipher_update's output for decryption with padding - #113
Merged
Merged
Conversation
EVP_DecryptUpdate can write up to inl + block_size bytes; the buffer was inl + block_size - 1, so a whole-block update after a partial one wrote one byte past it on OpenSSL 1.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #113 +/- ##
==========================================
- Coverage 83.43% 83.41% -0.02%
==========================================
Files 2 2
Lines 1352 1351 -1
==========================================
- Hits 1128 1127 -1
Misses 224 224 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
cipher_updatesized its output buffer asin_length + block_size - 1. OpenSSL documents that decryption with padding can write up toin_length + block_sizebytes (EVP_DecryptUpdate), so on OpenSSL 1.1 an update whose input is a whole number of blocks, after an earlier partial update, wrote one byte past the buffer. OpenSSL 3 stays within the shorter bound. The buffer is nowin_length + block_size, which also covers encryption (in_length + block_size - 1).Found by the sweep's OpenSSL memory-safety audit. No regression test: the write lands in allocator slack and is only observable with a memory checker. Checked locally: AES-256-CBC encrypt/decrypt round trips with split decrypt updates for lengths 0, 1, 15, 16, 17, 32, 100 and 4096 on Julia 1.12.
The old expression also used float division (
/); with power-of-two block sizes it was exact, so the change in size is exactly one byte.🤖 Generated with Claude Code