Surfaced by an automated multi-agent correctness audit.
Summary
decode_key auto-detects the key encoding (base64 / hex / raw) by decoded length, accepting a base64 decode purely because the result is a valid AES length (16/24/32) — so a raw ASCII key that happens to be valid base64 is silently decoded to the wrong bytes.
Location
src/encryption.rs:129 (decode_key), base64 branch validated only by is_valid_aes_length, raw fallback ~150-152.
Failure scenario
A 32-character raw ASCII AES-256 key that is coincidentally valid base64 decodes to 24 bytes (passing the AES-192 length check) and is returned instead of the intended 32 raw bytes; decryption then fails with no indication the format was misinterpreted.
Suggested fix
Require an explicit encoding hint/prefix (base64: / hex: / raw:) rather than length-based auto-detection, or only auto-detect when unambiguous and document precedence.
Severity: Medium (requires a format-ambiguous key; misleading failure).
Surfaced by an automated multi-agent correctness audit.
Summary
decode_keyauto-detects the key encoding (base64 / hex / raw) by decoded length, accepting a base64 decode purely because the result is a valid AES length (16/24/32) — so a raw ASCII key that happens to be valid base64 is silently decoded to the wrong bytes.Location
src/encryption.rs:129(decode_key), base64 branch validated only byis_valid_aes_length, raw fallback ~150-152.Failure scenario
A 32-character raw ASCII AES-256 key that is coincidentally valid base64 decodes to 24 bytes (passing the AES-192 length check) and is returned instead of the intended 32 raw bytes; decryption then fails with no indication the format was misinterpreted.
Suggested fix
Require an explicit encoding hint/prefix (
base64:/hex:/raw:) rather than length-based auto-detection, or only auto-detect when unambiguous and document precedence.Severity: Medium (requires a format-ambiguous key; misleading failure).