Skip to content

Size cipher_update's output for decryption with padding - #113

Merged
quinnj-bot[bot] merged 1 commit into
mainfrom
claude/cipher-update-buffer
Oct 30, 2026
Merged

quinnj-bot[bot] merged 1 commit into
mainfrom
claude/cipher-update-buffer

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

cipher_update sized its output buffer as in_length + block_size - 1. OpenSSL documents that decryption with padding can write up to in_length + block_size bytes (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 now in_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

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

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.41%. Comparing base (c7f1272) to head (a95c3d8).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj-bot
quinnj-bot Bot merged commit 3fe95c4 into main Oct 30, 2026
14 checks passed
@quinnj-bot
quinnj-bot Bot deleted the claude/cipher-update-buffer branch October 30, 2026 00:09
@quinnj-bot quinnj-bot Bot mentioned this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant