More Info:
KMS keys should have been rotated at least once (more than one key version). Keys that have never been rotated may use outdated cryptographic parameters.Risk Level
HighAddress
Compliance, SecurityCompliance 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
Remediation
Using Console
Using Console
Below are the concise steps to remediate “OCI Encryption KMS Keys Should Be Rotated At Least Once” using the OCI Console.
If you share which exact monitoring/control (Cloud Guard detector recipe, Security Zone policy, or a third-party scanner), I can tailor the rotation interval and any additional verification steps to match that control’s logic.
1. Identify the Non‑Rotated Keys
- Sign in to the OCI Console.
- Go to Identity & Security → Vault.
- Choose the Compartment you monitor (top-left compartment selector).
- Open each Vault and then select Keys.
- Look for Keys with:
Key Status: Enabled- No rotation history (never rotated) or last rotation is older than your required policy.
2. Manually Rotate a Key
For each key that needs rotation:- In the vault, go to Keys.
- Click the Key Name you want to rotate.
- On the key details page, click Rotate Key (or Create New Key Version).
- Confirm the rotation:
- This creates a new key version; the key’s OCID stays the same.
- Existing resources using this key will automatically start using the new version (no change needed in resource config).
- Verify rotation:
- On the key details page, you should now see multiple Key Versions with the latest marked as Primary.
3. Configure Automatic Key Rotation (Recommended)
To avoid future findings for “not rotated at least once”:- In the same Key details page, look for Key Rotation or Automatic Rotation section.
- Click Edit Rotation Policy or Enable Rotation.
- Set:
- Rotation Interval (e.g., every 90 days or per your policy).
- Save.
- The key is rotated at least once (clearing current misconfiguration).
- Future rotations are automated, preventing recurring findings.
4. Confirm Remediation in Your Monitoring Tool
If you’re using OCI Cloud Guard / Security Zones / custom monitoring:- Allow some time for the next evaluation cycle.
- Re-run the check (or wait for Cloud Guard detector to rescan).
- Verify the finding for “OCI Encryption KMS Keys Should Be Rotated At Least Once” is no longer reported for keys you rotated.
If you share which exact monitoring/control (Cloud Guard detector recipe, Security Zone policy, or a third-party scanner), I can tailor the rotation interval and any additional verification steps to match that control’s logic.
Using CLI
Using CLI
Below are CLI-focused steps to rotate OCI KMS keys and (optionally) enforce a rotation schedule so they’re not flagged as “never rotated”.Assumptions:
This immediately creates a new key version and makes it the primary version. Any subsequent cryptographic operations will use this new version, while old versions remain available for decrypting existing data (unless explicitly disabled/destroyed).You can verify:You should now see multiple versions.
Confirm:Look for the
In practice, for each flagged key:
- You already have
ociCLI configured with proper tenancy/region. - You know the
vault-idandkey-idfor the keys in question.
1. Identify KMS keys that have never been rotated
- List keys in a vault:
- For each key, list key versions:
- If only a single version exists (the original), the key has never been rotated.
2. Manually rotate a key (create a new key version)
Manual rotation = creating a new key version.3. Configure automatic key rotation (so the finding does not reoccur)
To ensure periodic rotation, you can set a rotation interval (policy) on the key.3.1 Prepare a key policy JSON with rotation settings
Create a filekey-policy.json:rotationIntervaluses ISO 8601 duration format:P90D= every 90 days- Example:
P180D= every 180 days
isUseKeyInVaultEnabled, isDerivedKeysEnabled) if needed for your environment.3.2 Apply the key policy via OCI CLI
keyPolicy and rotationInterval details in the output.4. Scriptable remediation (optional)
To remediate all “never rotated” keys in a compartment:High-level bash pseudo-script:5. Tie into “OCI Encryption Monitoring”
To ensure any future non-rotated or long-unrotated keys are remediated:- Use Oracle Cloud Guard / Security Zones or your own governance scripts to:
- Periodically run a CLI/script similar to section 4 to:
- Detect keys with a single version or last version older than your threshold.
- Rotate them and/or enforce
rotationInterval.
- Periodically run a CLI/script similar to section 4 to:
- Optionally, configure an Events rule (e.g., on key creation) that triggers a Function which:
- Immediately sets the
rotationInterval. - Optionally performs an initial rotation.
- Immediately sets the
In practice, for each flagged key:
oci kms management key-version create --key-id <key_ocid>oci kms management key update --key-id <key_ocid> --from-json file://key-policy.json(with an appropriaterotationInterval).
Using Python
Using Python
Below is how to remediate “OCI Encryption KMS Keys Should Be Rotated At Least Once” with Python-based monitoring and enforcement using the OCI Python SDK.
1. Prerequisites
- Install SDK:
- Configure OCI credentials (one of):
~/.oci/configwith a profile (e.g.DEFAULT)- Or instance principal / resource principal (for OCI native execution)
- Ensure the calling principal has these permissions in the compartment(s) and vault(s) you care about:
manage keysread vaults
2. What you need to check
For each key:- Has at least one new key version been created (i.e., rotated) since creation?
- Is automatic rotation enabled with a reasonable interval (e.g., 90 days)?
- Each rotation = new key version (
create_key_version). - Automatic rotation is controlled via:
is_auto_key_rotation_enabledrotation_interval_in_days(min 1 day, typical 30–365)
3. Python script: monitor and remediate rotation
This example:- Lists all vaults and keys in a compartment.
- For each key, checks:
- Whether it has more than one version (i.e., rotated at least once).
- Whether auto-rotation is enabled with an acceptable interval.
- Optionally:
- Enables auto-rotation if not enabled.
- Immediately rotates keys that have never been rotated.
Adjust: compartment OCID, rotation policy (e.g., 90 days), and DRY_RUN flag.
4. How this addresses the misconfiguration
- Monitoring: Script reports keys that:
- Have never been rotated (only 1 key version).
- Do not have compliant auto-rotation settings.
- Remediation (if
DRY_RUN = False):- Creates a new key version for never-rotated keys.
- Enables auto-rotation and sets
rotation_interval_in_daysto your policy.
5. Operationalizing
- Run this script on a schedule (e.g., OCI Functions, OCI DevOps, or cron on a compute instance).
- Send output to:
- OCI Logging / Object Storage / Email or Slack via webhooks for alerts.
- Optionally:
- Restrict to “monitor only” in production (keep
DRY_RUN=True) and have a change process for enabling actual rotation.
- Restrict to “monitor only” in production (keep
Using Terraform
Using Terraform
terraform plan should show a single + create action for oci_kms_key_version.ENCRYPTION_KEY_ROTATION_1 and no changes to oci_kms_key.ENCRYPTION_KEY.
