More Info:
Customer secret keys should be rotated every 90 days. Regular rotation reduces the risk window if keys are leaked through code repositories, logs, or configuration filesRisk Level
HighAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- 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)
- Essential 8
- 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 SP 800-171
- NYDFS 23 NYCRR 500
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are two parts:
This setup gives you:
- How to actually rotate a customer secret key (per user) via the console
- How to monitor/enforce 90‑day rotation using OCI Cloud Guard (OCI IAM Monitoring)
1. Manually rotate OCI IAM Customer Secret Keys (per user)
You must create a new secret key, update applications to use it, then delete the old one.- Sign in to the OCI Console.
- Go to: Identity & Security → Identity → Users.
- Click the user whose customer secret key you want to rotate.
- In the user details page, go to the Customer Secret Keys tab.
- Click Create Customer Secret Key.
- Optionally give it a description (e.g., “app‑xyz‑2024‑07‑rotation”).
- Click Create and copy the Access Key / Secret Key values (you won’t be able to see the secret again).
- Update all apps/integrations that were using the old customer secret key so they now use the new key.
- After confirming everything works with the new key, go back to the same Customer Secret Keys tab.
- Select the old key (older than 90 days) and click Delete.
2. Monitor/enforce “rotate every 90 days” using Cloud Guard (IAM Monitoring)
To continuously detect keys older than 90 days and optionally auto-remediate:2.1 Enable Cloud Guard
- In the console, go to Identity & Security → Cloud Guard.
- If not already enabled, click Enable Cloud Guard.
- Choose the compartment and region you want Cloud Guard to monitor, and confirm.
2.2 Configure the detector recipe for IAM customer secret keys
- In Cloud Guard, go to Detector Recipes.
- Open the OCI-managed detector recipe you’re using (e.g., OCI Activity Detector Recipe or OCI Configuration Detector Recipe, naming varies by tenancy/region).
-
Create a clone of the OCI-managed recipe (you can’t edit the managed one directly):
- Click Create Custom Detector Recipe (or Clone).
- Give it a name (e.g.,
Custom-IAM-Key-Rotation-Recipe).
-
In your custom detector recipe, find the rule for customer secret key age. Typical rule name is similar to:
- “IAM Customer Secret Keys should be rotated every 90 days”
or - “Customer secret key age exceeds threshold”.
- “IAM Customer Secret Keys should be rotated every 90 days”
-
Edit that rule:
- Ensure the rule is Enabled.
- Set the age threshold to 90 days (or keep the default if it is already 90).
- Set the Risk Level (e.g., High or Medium) as per your policy.
- Save changes.
-
Attach this custom detector recipe to your Cloud Guard target:
- Go to Targets in Cloud Guard.
- Edit your existing target (or create a new one).
- Under Detector Recipes, replace the default OCI-managed detector recipe with your custom clone that has the 90‑day rule enabled.
- Save.
2.3 (Optional) Auto-remediate (delete old keys) via responder recipe
If you want Cloud Guard to take automatic action (e.g., delete old keys):- In Cloud Guard, go to Responder Recipes.
- Clone the OCI-managed responder recipe into a custom responder recipe.
- Find a responder rule appropriate for IAM key issues (e.g., “Delete customer secret key” or similar name).
- Enable that responder rule and (if needed) associate it with the IAM customer secret key age detector rule:
- Set its Action to something like Delete Resource or Disable Key (exact wording depends on current OCI capabilities).
- Attach this custom responder recipe to the same Cloud Guard target where your custom detector recipe is attached.
- Set the responder mode (per target) to Auto if you want automatic remediation; otherwise keep User-Driven for manual approving of actions from the Problems page.
2.4 Review and act on findings
- Go to Cloud Guard → Problems.
- Filter for the rule name (e.g., “IAM Customer Secret Keys should be rotated every 90 days”).
- For each problem:
- If you use user-driven mode: click the problem → choose the recommended Responder action → run it.
- If you use auto mode and have a delete responder, Cloud Guard will delete or remediate according to your responder rule.
This setup gives you:
- Manual rotation of keys via the Users → Customer Secret Keys tab.
- Continuous monitoring (and optionally automated deletion/remediation) via Cloud Guard to enforce the 90‑day rotation requirement.
Using CLI
Using CLI
Below is a practical way to monitor and rotate OCI IAM Customer Secret Keys every 90 days using the OCI CLI.
Or for the current CLI user:Simpler if you know your OCID:
Run this via cron (e.g., daily) and pipe output to email or a log monitoring system.
Before deleting an old key, update any applications using it to the new key.Update your apps/services with Set
If you want, I can provide a single combined script that:
1. Prerequisites
- Install and configure OCI CLI (with a user that has IAM permissions):
- Ensure the CLI user has policy allowing:
inspect usersmanage customer-secret-keyson users in the tenancy
2. Find Customer Secret Keys and Their Age
2.1. Get the User OCID
If you know the username:2.2. List the Customer Secret Keys
3. Identify Keys Older Than 90 Days (Monitoring Logic)
Example Bash script to detect keys older than 90 days:4. Rotate (Create New + Delete Old) Keys via CLI
Important:Before deleting an old key, update any applications using it to the new key.
4.1. Create a New Customer Secret Key
ACCESS_KEY_ID and SECRET_ACCESS_KEY.4.2. Delete Old Keys (Older Than 90 Days)
Extend the previous script to delete old keys:DRY_RUN=false once you have validated behavior.5. Automate Monitoring (and Optional Auto-Rotation)
- Save script(s) on a secure host (e.g., bastion, management server).
- Configure cron (example: run daily at 01:00):
- Integrate log output with your monitoring/alerting (e.g., send mail if “OLD KEY” lines appear).
If you want, I can provide a single combined script that:
- checks for keys >90 days,
- creates a new key if needed, and
- deletes just the oldest key after a grace period.
Using Python
Using Python
Below is a practical way to both detect and remediate “OCI IAM Customer Secret Keys older than 90 days” using Python and the OCI SDK.
1. Prerequisites
- Install OCI Python SDK:
- Configure your OCI CLI/SDK config (
~/.oci/config) with a profile that has permissions:IDENTITY_READandIDENTITY_UPDATEon users in the tenancy- Typically, a policy like:
- Know:
- Tenancy OCID
- Compartment/Users whose keys you want to rotate (or all users in tenancy)
2. High-Level Rotation Logic
For each user:- List all Customer Secret Keys.
- For each key:
- If
time_createdis older than 90 days:- Create a new Customer Secret Key.
- Store the new key’s ID/secret somewhere safe (e.g., password manager, vault).
- Update any application/config using the old key to use the new key.
- Delete the old Customer Secret Key.
- If
- Mark old keys as “stale” and send alerts,
- Or rotate only keys that are not in current use (if you track usage yourself).
3. Example Python Script – Detect And Rotate Keys Older Than 90 Days
This script:- Iterates over all users in tenancy (or filter by name),
- Checks each user’s customer secret keys,
- For keys older than 90 days:
- Creates a new key,
- Prints the new key secret (you must store it securely),
- Deletes the old key (this step is optional until you’ve updated the apps).
WARNING: This will break any system still using the old secret key.
Test in non‑prod and comment out the delete step at first.
4. How To Use This For Ongoing Monitoring
- Keep
DRY_RUN = Trueto use it as a monitoring/check script. - Run it periodically via:
- OCI DevOps pipeline,
- A scheduled job (cron) on a bastion/automation server,
- Or an OCI Function triggered via Events (if you wrap this logic into a function).
- Parse the output / send results to:
- Email / Slack / Teams,
- Logging / monitoring system (Cloud Guard, custom metrics, etc.).
DRY_RUN = False and introduce a safe process around:- Storing new secrets securely,
- Coordinating application updates before deleting old keys.
Using Terraform
Using Terraform
Terraform cannot enforce “rotate every 90 days” for OCI IAM customer secret keys; it can only (re)create/delete keys, not schedule or trigger periodic rotation.In practice you either:
- Rotate manually in the Console (Identity & Security → Users → User → Customer Secret Keys → Create / Delete old), or
- Automate rotation outside Terraform using OCI Events + Functions/CLI/SDK, or an external scheduler (e.g., CI pipeline) that calls
oci iam customer-secret-keyAPIs on a 90‑day schedule.
oci_identity_* Terraform resource or argument that can express a 90‑day rotation policy for IAM customer secret keys, so there will be nothing for terraform plan to show for this control.
