Skip to main content

More Info:

Customer-managed KMS keys should be rotated at least once per year (365 days). Annual rotation ensures cryptographic material is refreshed and limits long-term exposure from key compromise

Risk Level

High

Address

Compliance, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS AWS
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • GDPR
  • HIPAA
  • HITRUST CSF
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • PCI
  • Reserve Bank of India (RBI) Cyber Security Framework
  • Reserve Bank of India (RBI) Master Direction – Information Technology Framework
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Below are step‑by‑step console instructions to remediate the “OCI Encryption KMS Keys Should Be Rotated Annually” issue for OCI Encryption Monitoring (Cloud Guard) and your KMS keys.

1. Find the non‑compliant KMS keys (Cloud Guard)

  1. Sign in to the OCI Console.
  2. Open the navigation menu → Security & IdentityCloud Guard.
  3. In the left pane, click Problems.
  4. Use filters:
    • Detector type: OCI Encryption Monitoring
    • Problem description / name contains: KMS Keys Should Be Rotated Annually
    • (Optional) Filter by Compartment to narrow scope.
  5. For each listed problem, open it and note:
    • Key OCID (or name).
    • Compartment where the key’s vault resides.
    • Region.
You now know which keys must be rotated.

2. Rotate the KMS key in Vault (Console)

You must create a new key version for each flagged key.
  1. From the console, open the navigation menu → Security & IdentityVault.
  2. At the top-right, confirm you are in the same region where the problem key exists.
  3. In the left pane, click Vaults and select the vault that contains the problem key.
  4. In the vault, click the Keys tab.
  5. Find the Key (by name or OCID noted from Cloud Guard) and click it.
  6. On the key details page, click Rotate Key (or Create New Key Version, depending on UI wording).
  7. Confirm the rotation:
    • This creates a new key version; the key OCID stays the same.
    • Existing resources that reference the key by key OCID continue to work automatically.
  8. Wait until the key status shows the new version as Current (refresh if needed).
Repeat for all keys reported by Cloud Guard.
Note: OCI does not provide a built‑in “automatic schedule” for rotation in the console; rotation is via manual action (as above) or automation (CLI/SDK/scheduled functions).

3. Validate and close the Cloud Guard problem

Cloud Guard periodically re‑evaluates; once it detects a newer key version within the last year, the problem status will change.
  1. Return to Cloud Guard → Problems.
  2. Open the problem you remediated.
  3. After evaluation (may take several minutes), the problem should move to Resolved automatically.
  4. If using workflows, you can:
    • Add a comment describing the rotation performed.
    • Optionally mark it as Resolved manually if your org’s process requires that.

4. (Optional) Reduce future findings – policy / process

Since rotation is annual, set up a process so the key doesn’t age beyond one year:
  • Use Cloud Guard detector “OCI Encryption KMS Keys Should Be Rotated Annually” as your control and:
    • Ensure it’s enabled in your Detector Recipe for OCI Encryption Monitoring.
    • Attach the recipe to all relevant targets / compartments.
  • Optionally configure Notifications:
    1. Go to Application Integration → NotificationsTopics.
    2. Create a topic (e.g., kms-rotation-alerts).
    3. Subscribe email/Slack/HTTPS endpoint.
    4. In Cloud Guard → Responders or in your ticketing/automation layer, tie the “key older than 1 year” problem to send alerts to this topic.
This ensures future keys nearing 1 year will be detected and acted upon via the console‑driven process above.
Below are step‑by‑step instructions to identify and rotate OCI KMS keys older than 1 year using the OCI CLI, suitable for putting into a monitoring/automation workflow.

1. Prerequisites

  1. Install and configure OCI CLI:
  2. Ensure your user has these IAM permissions (or equivalent via group/policy):
  3. Have the following values ready:
    • TENANCY_OCID
    • COMPARTMENT_OCID where your keys live
    • VAULT_OCID (optional filter if you want per vault)
    • REGION
Set them as environment variables for convenience:

2. List All KMS Keys in a Compartment (Optionally Per Vault)

To get JSON instead (for scripting):
Each key will have an id (Key OCID).

3. Find Keys Whose Current Version is Older Than 1 Year

Each KMS key has versions; rotation = creating a new version. We need to:
  1. Get the current key version.
  2. Get its time-created.
  3. Compare to “now − 365 days”.
Here is a Bash script that:
  • Iterates over keys in a compartment (optionally per vault),
  • Checks the current version age,
  • Prints keys older than 365 days.
Use this for monitoring (e.g., run via cron, OCI DevOps build, or scheduled job) and alert when keys exceed 365 days.

4. Rotate a Specific KMS Key via OCI CLI

Rotation = rotate-key API/CLI, which creates a new key version and makes it current.
Example:

5. Automate Rotation for Keys Older Than 1 Year

Here is a script that rotates all KMS keys in a compartment (optionally per vault) whose current version is older than 365 days:
You can run this script monthly/weekly as part of your OCI Encryption Monitoring/compliance pipeline.

6. Optional: Wire into OCI Monitoring/Events

To fully “monitor” via OCI:
  1. Use an OCI Logging or Monitoring–backed job (e.g., OCI DevOps Build, or a compute instance cron) that runs the check script.
  2. When the script finds aged keys, write results to:
    • stdout + agent -> OCI Logging, and
    • A custom metric using oci monitoring metric-data post for “kms.key.rotation_needed = 1”.
  3. Create an Alarm on that metric to notify when rotation is needed.
  4. Optionally trigger an OCI Function from an Event or Alarm that calls the rotation script logic (via Python SDK or CLI containers).

If you share whether you prefer a pure CLI solution or CLI + Python SDK, I can give you a ready‑to‑run monitoring + rotation job for your environment.
Below is how to remediate “OCI Encryption KMS Keys Should Be Rotated Annually” using Python, by:
  1. Detecting KMS keys older than 365 days (or whose last key version is older than 365 days).
  2. Automatically rotating them by creating a new key version.
  3. Optionally, enforcing a rotation policy interval.

1. Prerequisites

  1. Install OCI Python SDK
  2. Configure OCI CLI/SDK credentials (user, tenancy, region, key pair, etc.)
    Create/verify ~/.oci/config with at least:
  3. The user/principal running this must have IAM permissions similar to:

2. Strategy

  • For each key in your vault(s) / compartment(s):
    • Check the most recent key version’s time_created.
    • If older than 365 days, call create_key_version (this rotates the key).
  • Optionally, set a rotation policy using update_key key_shape and key_lifecycle_details or the dedicated rotation policy (if available in your region/tenancy; for older APIs, you do it via monitoring + create_key_version).

3. Python Script: Monitor & Rotate Keys Annually

Below is a basic example:
Notes:
  • You must set the KMS management endpoint correctly. Often you:
    1. Use oci.key_management.KmsVaultClient to get the management endpoint for a given vault.
    2. Then initialize KmsManagementClient with that endpoint.
Example to get endpoint:

4. Automate as “Monitoring”

  • Run this Python script on a schedule:
    • OCI Functions + OCI Events/Scheduled Jobs.
    • Or an external scheduler like cron / CI pipeline.
  • Log or send alerts (e.g., to OCI Logging, email, Slack) whenever a key is rotated or close to threshold.

5. (Optional) Enforce a Rotation Policy

If your tenancy/region supports key rotation policies, you can set a policy to 365 days so you don’t have to run your own rotation logic. Pseudocode:
Check the specific fields for rotation policy in the SDK version you’re using (help(oci.key_management.models.UpdateKeyDetails)).
If you tell me how you’re currently deploying/monitoring (OCI Functions, VM, external runner), I can tailor the script and IAM policy exactly for that setup.
Terraform cannot configure rotation for oci_kms_key because OCI KMS key rotation is an operational action, not a persisted property on the key, and the oci provider exposes no argument for a rotation interval or schedule.To meet the “rotate annually” requirement you must rotate keys outside Terraform (e.g., via Console, OCI CLI, or an automated script/Function scheduled by Events/Alarms), and keep Terraform managing only the key’s lifecycle (creation, tags, etc.).Console path (as of now):
KMS → Vaults → select VAULT → Keys → select KEY → Rotate → confirm, or configure any available automatic rotation option there.
terraform plan will not show any change related to rotation, because it is not a Terraform-managed setting.