Skip to content

security: migrate AES-CBC to AES-GCM authenticated encryption#2331

Open
3em0 wants to merge 1 commit intoarc53:mainfrom
3em0:fix/aes-gcm-authenticated-encryption
Open

security: migrate AES-CBC to AES-GCM authenticated encryption#2331
3em0 wants to merge 1 commit intoarc53:mainfrom
3em0:fix/aes-gcm-authenticated-encryption

Conversation

@3em0
Copy link
Copy Markdown

@3em0 3em0 commented Mar 26, 2026

Summary

  • Replaced AES-CBC (no message authentication) with AES-GCM in application/security/encryption.py, providing both confidentiality and integrity for stored credentials
  • Backward-compatible decryption: existing CBC-encrypted data is auto-detected via a version byte prefix and decrypted through the legacy path
  • Added tests for GCM round-trip, legacy CBC compatibility, and tamper detection (flipped ciphertext byte → returns {})

Motivation

AES-CBC without HMAC lacks ciphertext integrity protection. While the practical Padding Oracle attack surface is limited (no direct decrypt endpoint), the absence of authenticated encryption is a cryptographic deficiency. AES-GCM resolves this in a single primitive.

Changes

File Change
application/security/encryption.py encrypt_credentials → AES-256-GCM; decrypt_credentials → version-byte dispatch (GCM vs legacy CBC)
tests/security/test_encryption.py Updated round-trip test; added test_decrypt_legacy_cbc_format and test_tampered_gcm_ciphertext_returns_empty

Test plan

  • pytest tests/security/test_encryption.py -v — 8/8 passed
  • GCM encrypt/decrypt round-trip verified
  • Legacy CBC data still decrypts correctly
  • Tampered GCM ciphertext correctly rejected (returns {})

🤖 Generated with Claude Code

…d encryption AES-CBC without message authentication (HMAC) is vulnerable to ciphertext tampering and theoretical padding oracle attacks. AES-GCM provides both confidentiality and integrity in a single primitive. - encrypt_credentials now uses AES-256-GCM with a version byte prefix - decrypt_credentials auto-detects format: v1 (GCM) vs legacy (CBC) - Legacy CBC decryption preserved for backward compatibility - Added tests for GCM round-trip, legacy CBC compat, and tamper detection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added application Application tests Tests labels Mar 26, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

Someone is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

@3em0
Copy link
Copy Markdown
Author

3em0 commented Mar 27, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

application Application tests Tests

1 participant