feat: KMS column-encryption rotation drill with resumable state and audit - #811
Open
Fash004 wants to merge 21 commits into
Open
feat: KMS column-encryption rotation drill with resumable state and audit#811Fash004 wants to merge 21 commits into
Fash004 wants to merge 21 commits into
Conversation
…/Revora-Backend into feat/kms-column-rotation
…peer dependency conflicts
…native module lockfile errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes:#557
Summary
Implements background column-level re-encryption (
ColumnEncryptionRotator) for at-rest encrypted data when KMS keys are rotated. Tracks per-row key generation, maintains persisted resumable state across restarts, emitsrotation.rows_reencryptedmetric counter, and logs security audit events.Requirements & Context
kms_rotation_state) tracks batch cursor and status across service restarts.key_generation < target_key_generation, preventing double re-encryption if process crashes mid-batch.rotation.rows_reencryptedcounter metric viaMetricsCollector.Detailed Changes
Security & Rotator Service
src/security/kmsKeyProvider.ts:KMSKeyProviderinterface andLocalKMSKeyProviderimplementing AES-256-GCM column encryption tagged with key generation IDs (keyGeneration) and key rotation support (rotateKey()).src/security/columnEncryptionRotator.ts:ColumnEncryptionRotatorservice managing background column re-encryption jobs:startRotation(targetTable, targetColumn, options)processBatch(jobId, batchSize)resumePendingRotations(batchSize)rotation.rows_reencryptedmetric counter.KEY_ROTATIONaudit events.src/security/types.ts: AddedKMSRotationJobState,KMSRotationOptionsinterfaces and added'KEY_ROTATION'event type toAuditEvent.src/security/index.ts: Re-exported KMS encryption primitives and rotator service.Database Migration
src/db/migrations/020_create_kms_rotation_state.sql: Added database migration forkms_rotation_statepersistence table andkms_sample_recordsdemonstration table.Unit & Integration Tests
src/security/columnEncryptionRotator.test.ts: Comprehensive test suite testing KMS key rotation, batch re-encryption, crash mid-batch resumption without double re-encryption, metric counter emission, and audit log generation.package.json: Addedtest:kms-rotationtest script.