Skip to main content

More Info:

Any disabled AWS KMS Customer Master Keys (CMK) that have been accidentally or intentionally scheduled for deletion should be recovered in order to prevent losing any data encrypted with these keys.

Risk Level

Low

Address

Reliability, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • HIPAA
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Sure, here are the step by step instructions to remediate the KMS Keys Scheduled for Deletion should be recovered misconfiguration in AWS using the AWS console:
  1. Open the AWS Management Console and navigate to the KMS service.
  2. In the left navigation pane, click on “Scheduled Deletion”.
  3. Check the list of keys scheduled for deletion and identify the key that needs to be recovered.
  4. Select the key by clicking on the checkbox next to it.
  5. Click on the “Recover” button on the top of the page.
  6. In the confirmation dialog box, click on the “Recover” button again to confirm the recovery.
  7. Once the key is recovered, it will be available for use again.
That’s it! You have successfully remediated the KMS Keys Scheduled for Deletion should be recovered misconfiguration in AWS using the AWS console.

Sure, here are the step-by-step instructions to remediate the KMS Keys Scheduled for Deletion should be Recovered issue in AWS using AWS CLI:
  1. Open the AWS CLI on your local machine.
  2. Run the following command to list all the KMS keys that are scheduled for deletion:
Note: Replace <key-id> with the ID of the KMS key that is scheduled for deletion.
  1. Review the output of the command and identify the Grant IDs of the grants that are scheduled for deletion.
  2. Run the following command to recover the grants that are scheduled for deletion:
Note: Replace <key-id> with the ID of the KMS key that is scheduled for deletion and <grant-id> with the ID of the grant that you want to recover.
  1. Repeat steps 4 and 5 for all the grants that are scheduled for deletion.
  2. Once you have recovered all the grants that were scheduled for deletion, recheck the status of the KMS key to ensure that the issue has been resolved.
That’s it! These steps should help you remediate the KMS Keys Scheduled for Deletion should be Recovered issue in AWS using AWS CLI.
To remediate this issue in AWS using Python, you can use the AWS SDK for Python (Boto3) to recover the KMS keys that are scheduled for deletion. Here are the steps to do so:
  1. Import the required Boto3 libraries:
  1. Create a Boto3 client for the KMS service:
  1. Use the list_grants API to get the list of all KMS keys that are scheduled for deletion:
  1. For each grant that is scheduled for deletion, use the cancel_key_deletion API to cancel the scheduled deletion:
This Python script will cancel the scheduled deletion for all KMS keys that are in the “PendingDeletion” state. You can run this script periodically to ensure that any KMS keys that are scheduled for deletion are recovered.
AWS KMS key recovery from a PendingDeletion state (the aws kms cancel-key-deletion and subsequent aws kms enable-key operations) is not exposed by the Terraform AWS provider, so it cannot be remediated directly in Terraform; you must:
  1. In CLI/Console, run the verified fix:
    • aws kms cancel-key-deletion --key-id YOUR_KEY_ID --region YOUR_REGION
    • aws kms enable-key --key-id YOUR_KEY_ID --region YOUR_REGION
    • Heed the warnings: only cancel deletion if it wasn’t intentional.
  2. Import the key into Terraform (if not already managed) and ensure your aws_kms_key configuration does not schedule its deletion again:
    • terraform import aws_kms_key.EXISTING_KEY YOUR_KEY_ID
terraform plan should then show either:
  • No changes (if the config matches the recovered key), or
  • Only configuration drift being reconciled (description, tags, etc.), and specifically no actions that schedule the key for deletion.

Additional Reading: