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 →
- Create a KMS key with a key policy limited to the app role.
- Use envelope encryption:
GenerateDataKeyper record or batch, store the encrypted data key with the ciphertext. - Write a migration job that decrypts with the old key and re-encrypts with KMS-derived data keys.
- Remove the old key from code and history, and treat it as compromised.
- Enable automatic key rotation and CloudTrail alerts on
Decryptspikes.
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.
More on Secrets and Identity Management
A team stores database passwords in a `.env` file committed to a private repo. How do you migrate them out?BeginnerYour CI pipeline uses long-lived AWS access keys stored as repository secrets. How do you replace them?IntermediateAn auditor asks how often you rotate database credentials. You currently never do. What do you build?IntermediatePods need AWS access. A developer mounted an IAM user's keys as a Kubernetes Secret. What do you propose instead?BeginnerShould you use Kubernetes Secrets, Sealed Secrets, External Secrets Operator or the Secrets Store CSI driver?IntermediateA Slack webhook URL and a Stripe live key were posted in a public GitHub issue. What is your response sequence?Beginner