More Info:
Auth tokens should be rotated every 90 days. Stale tokens increase the risk of unauthorized access if credentials are compromised or leakedRisk 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 things you need to do using only the OCI Console:
- Rotate any existing auth tokens older than 90 days
- Configure monitoring (via Cloud Guard) to detect tokens older than 90 days going forward
1. Manually rotate IAM auth tokens older than 90 days
You must do this per user.- Sign in to the OCI Console with a user that has IAM admin privileges.
- Open the navigation menu → Identity & Security → Domains (or Identity → Users if you are on the older model).
- Choose the domain (if applicable), then go to Users.
- Click the target User.
- Go to the Auth Tokens tab.
- Here you see each token with its Created date.
- Identify tokens older than 90 days.
- For each such token:
- Click Generate Token.
- Enter a Description, click Generate Token.
- Copy the token value once (you’ll need this for the application that uses it).
- Update the corresponding application / script / tool to use the new token.
- After confirming the application works with the new token, go back to the Auth Tokens tab and click Revoke (trash icon) for the old token.
2. Set up monitoring for “auth tokens not rotated in 90 days” using Cloud Guard
Cloud Guard has built-in IAM detectors that can flag this, and you can get notified or auto-remediate.2.1 Enable Cloud Guard and set a target
- In the OCI Console, go to Identity & Security → Cloud Guard.
- If Cloud Guard is not enabled, click Enable Cloud Guard.
- Create a Target:
- Click Targets → Create target.
- Give it a name.
- Select the compartment (often the root compartment to cover the tenancy).
- Choose Target type: typically Compartment (or Tenancy if available in your region/tenant).
- Save.
2.2 Enable and tune the IAM Auth Token detector
- In Cloud Guard, go to Detector Recipes.
- Find the IAM detector recipe (for example:
OCI Configuration Detector Recipeor similar; names can vary slightly but look for IAM-related). - Click the recipe in use by your target (it will show Attached to your target).
- Click Actions → View detector rules (or “Customize” if needed).
- Look for a rule named similar to:
- “IAM Auth Token not rotated in last 90 days”
or - “IAM Auth Token older than specified days”
- “IAM Auth Token not rotated in last 90 days”
- For that rule:
- Ensure it is Enabled.
- If there’s a parameter for days, set it to 90 days.
- Set the Risk Level / Severity as desired (e.g., High).
- Save changes (update the recipe if prompted).
3. Configure notifications for detected problems
To know when Cloud Guard finds old tokens, connect it to OCI Notifications via Events.3.1 Create a Notifications topic and subscription
- Go to Developer Services → Notifications.
- Click Create Topic, name it (e.g.,
cloudguard-iam-alerts), choose a compartment, and create. - Click the new Topic, then Create Subscription:
- Protocol: Email (or HTTPS/Slack via webhook as needed).
- Enter your email and create.
- Confirm the subscription from your email inbox (click the confirmation link).
3.2 Create an Events rule for Cloud Guard problems
- Go to Observability & Management → Events Service → Rules.
- Click Create rule:
- Name:
cloudguard-iam-auth-token-old-alert. - Compartment: your root or security compartment (same as Cloud Guard target, usually).
- Name:
- Rule Condition:
- Set Service Name:
Cloud Guard. - Set Event Type: something like “Problem Detected” (exact name may vary but it’s the one for new problems).
- Optionally, add a filter on
data.problemType,data.detectorRuleIdordata.riskLevelto restrict only to the IAM auth-token detector, if you want to narrow it.
- Set Service Name:
- Actions:
- Choose Notifications.
- Select the topic you created (
cloudguard-iam-alerts).
- Create the rule.
- Create a Problem in Cloud Guard.
- Emit an Event, which triggers the Notification rule.
- Send you an email (or chosen channel).
Ongoing process
- Weekly or monthly, check Cloud Guard → Problems filtered by IAM / auth token rules to see if any tokens are out of compliance.
- For each problem:
- Identify the user and auth token.
- Go back to Identity & Security → Users → Auth Tokens, rotate the token as in section 1.
- The problem will be automatically resolved on the next evaluation cycle once the old token is revoked.
Using CLI
Using CLI
Below is a concise, CLI‑only way to:
This shows each token’s
On macOS with BSD This gives you the list of non‑compliant tokens (older than 90 days) per user → use this in your monitoring/cron.
Repeat for each old token.Scripted delete of all tokens older than 90 days:
The response includes the plain‑text token only once. Save it securely and update any system that uses the old token.Optional: if you enforce “max N tokens per user”, you can delete the oldest after you confirm all clients use the new token.
Run via cron or your scheduler and integrate with your monitoring/alerting (e.g., log to a file and have your monitoring stack parse it).
If you share your OS (Linux/macOS/Windows) and how you prefer to schedule jobs, I can adapt the commands into a ready‑to‑use monitor/rotation script for that environment.
- Detect IAM auth tokens older than 90 days
- Rotate them (delete old, create new)
- Optionally make this scriptable for ongoing monitoring
- You already have
ociconfigured (oci setup configdone) - You know the user OCID(s) whose auth tokens you want to monitor/rotate
1. List IAM Auth Tokens for a User
id, description, and time-created.If you want JSON:2. Identify Tokens Older Than 90 Days (Monitoring Check)
Example (Linux/macOS) to list only tokens older than 90 days:date, use:3. Delete Old (Non‑Compliant) Auth Tokens
Once you identify IDs of old tokens, delete them:4. Create New Replacement Auth Tokens (Rotation)
Create a new token for the user:5. Automate Monitoring + Rotation (Cron / Scheduled Task)
You can combine the above into a script, e.g.rotate_oci_auth_tokens.sh:If you share your OS (Linux/macOS/Windows) and how you prefer to schedule jobs, I can adapt the commands into a ready‑to‑use monitor/rotation script for that environment.
Using Python
Using Python
You remediate this by automating detection and rotation of IAM Auth Tokens older than 90 days using the OCI Python SDK, then scheduling that script (cron/OCI Functions/DevOps).Below is a concise step‑by‑step approach and example code.
1. Prerequisites
-
Install the SDK:
-
Configure OCI credentials (for the user or instance principal that will manage tokens):
- Either
~/.oci/config: - Or use Instance/Resource Principals if running in OCI.
- Either
-
The principal must have IAM permissions to manage auth tokens:
2. Logic You Need
For each IAM user:- List all auth tokens.
- For each token:
- Compute age from
time_created. - If age > 90 days, rotate:
- Create a new token.
- Update the downstream system that uses the token (Git, Docker, etc.).
- Delete the old token.
- Compute age from
3. Python Example – Detect & Rotate Tokens Older Than 90 Days
This example assumes you’re rotating tokens for a specific user (e.g., a CI user). Adjust as needed.4. Monitoring / Alerting Only (Optional)
If you only want monitoring (no automatic rotation), modifymain():- Instead of creating/deleting tokens, just print/log tokens older than 90 days (or send to email/Slack, or push to OCI Monitoring/Logging).
5. Run on a Schedule
- On‑prem/VM: cron job running every day.
- In OCI:
- OCI Functions + OCI Events/cron‑like scheduling (via Service Connector or external scheduler).
- OCI DevOps pipeline stage run on schedule.
Using Terraform
Using Terraform
Terraform cannot enforce “rotate every 90 days” for OCI IAM auth tokens; rotation is a time‑based operational process, not a configurable property on the
oci_identity_auth_token resource or any IAM monitoring resource.There is no Terraform argument to set a max age, expiry, or rotation policy for auth tokens, and Terraform has no built‑in scheduler to recreate the token every 90 days. To remediate this finding you must rotate tokens outside Terraform, e.g.:- Using the OCI Console: for each user, go to Identity & Security → Users → User Details → Auth Tokens, delete stale tokens and create new ones.
- Or via OCI CLI/SDK scheduled by an external system (cron, CI/CD, etc.) to delete and recreate tokens on a 90‑day cadence.
terraform plan will show no changes related to this control.
