Skip to content

fix: validate AES-CBC ciphertext block alignment in Decrypt#6

Open
patrislav wants to merge 2 commits into
masterfrom
fix/aescbc-block-size-validation
Open

fix: validate AES-CBC ciphertext block alignment in Decrypt#6
patrislav wants to merge 2 commits into
masterfrom
fix/aescbc-block-size-validation

Conversation

@patrislav

Copy link
Copy Markdown
Member

Summary

  • Adds block-size validation in aescbc.Decrypt after IV removal to prevent a panic from cipher.cbcDecrypter.CryptBlocks on malformed (non-block-aligned) ciphertext
  • Returns a descriptive error instead of panicking
  • Adds test cases for IV-only, non-block-aligned, block-aligned, and round-trip decryption

Test plan

  • TestDecryptBlockSizeValidation/IV_only,_no_data — 16-byte input (IV only) returns error
  • TestDecryptBlockSizeValidation/non-block-aligned_after_IV — 17-byte input returns error
  • TestDecryptBlockSizeValidation/block-aligned_after_IV_does_not_panic — 32-byte input does not panic
  • TestDecryptBlockSizeValidation/round-trip — valid encrypt/decrypt still works
  • All existing tests pass

🤖 Generated with Claude Code

Add block-size validation after IV removal to prevent panic from
cipher.cbcDecrypter.CryptBlocks on malformed (non-block-aligned)
ciphertext. Returns a descriptive error instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@patrislav patrislav requested a review from a team June 19, 2026 15:54
go.mod requires go >= 1.26.1, but CI workflows were pinned to 1.25.x,
causing all jobs to fail.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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