Interview Prep/DevSecOps/Secrets and Identity Management

Your app encrypts customer PII with a key hard-coded in the source. How do you fix the key management?

IntermediateScenarioSecrets and Identity Management
Answer

Situation read → Anyone with repo access can decrypt all PII. The key must move to a KMS and data needs re-encryption.

What I'd do →

  1. Create a KMS key with a key policy limited to the app role.
  2. Use envelope encryption: GenerateDataKey per record or batch, store the encrypted data key with the ciphertext.
  3. Write a migration job that decrypts with the old key and re-encrypts with KMS-derived data keys.
  4. Remove the old key from code and history, and treat it as compromised.
  5. Enable automatic key rotation and CloudTrail alerts on Decrypt spikes.

Why → KMS keys never leave the HSM, every use is logged, and access is controlled by IAM.

Interview tip → Explain envelope encryption in one sentence; interviewers love it.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets and Identity Management