Skip to content

getFieldEncryptionConfig-driven key rotation has no mechanism to confirm all data was re-encrypted before retiring a key #1439

Description

@1nonlypiece

decryptField in src/lib/encryption.ts documents the key-rotation flow: old ciphertext keeps decrypting under a retired key (looked up via keyById) while new writes use the active (first) key. There is no code anywhere in this module (or, per the earlier exploration of webhookSubscriberRepository.ts, in its consumers) that tracks or reports how much stored ciphertext still references a given retired kid, so an operator has no built-in way to confirm it's actually safe to remove an old key from FIELD_ENCRYPTION_KEYS — doing so prematurely causes decryptField to throw DecryptionError: No field encryption key configured for key id "..." for every row still encrypted under it (as the docstring on line 226-229 explicitly warns can happen). Add an audit query/report that counts rows still encrypted under each known kid before a key is removed from configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions