More Info:
Each IAM user should have only one active API signing key. Multiple active keys increase the attack surface and make key rotation and compromise detection more difficultRisk Level
MediumAddress
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
- 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 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
Remediation
Using Console
Using Console
To remediate “OCI IAM Users Should Have Only One Active API Key” using the OCI Console, you need to remove extra API keys from each affected user so that only one remains.Follow these steps for each flagged IAM user:
-
Sign in to OCI Console
- Log in to the OCI Console with an account that has IAM administrator privileges.
-
Go to the Users page
- Open the main navigation menu (☰).
- Navigate to: Identity & Security → Identity → Users.
-
Select the affected user
- In the user list, find and click the name of the user that has more than one API key (as indicated by your monitoring/detector).
-
Open the API Keys tab
- Inside the user details page, click the API Keys tab.
- You’ll see a list of all API keys associated with this user.
-
Determine which key to keep
- Identify the key currently used by applications/automation (use:
- the Fingerprint, and
- the Created timestamp,
- any internal documentation or configuration files where the key is referenced).
- Decide one key to keep active. If you’re unsure, coordinate with the team using the key before deleting any.
- Identify the key currently used by applications/automation (use:
-
Delete extra API keys
- For each unneeded API key:
- Click the Actions (⋮) menu next to that key.
- Select Delete (or Remove).
- Confirm the deletion when prompted.
- Repeat until the user has only one remaining API key.
- For each unneeded API key:
-
Verify compliance
- Confirm under the API Keys tab that only one key remains.
- If you use Cloud Guard / IAM Monitoring, allow a few minutes and then:
- Go to Cloud Guard → Detections (or Dashboard),
- Confirm that the “user has multiple API keys” problem is cleared or closed for that user.
-
(Optional) Standardize going forward
- Update your internal process to:
- Issue only one active API key per IAM user.
- Rotate by replacing a key (create new, update workloads, then delete old) so that you never leave more than one active longer than necessary.
- Update your internal process to:
Using CLI
Using CLI
Below is a practical, CLI‑only way to enforce “OCI IAM Users Should Have Only One Active API Key”:Goal: For each IAM user, keep only one active API key, and delete all others.
If you want to restrict to a specific group:
This shows all active keys (OCI doesn’t support “disabled” API keys; they’re either present or deleted).
Extract the key ID you want to keep:
Example Bash loop to delete all except
Run:
If you tell me whether you prefer newest key, oldest key, or a specific naming/fingerprint rule, I can adapt the loop/query exactly to that policy.
1. Prerequisites
- OCI CLI installed and configured (
oci setup config) - You’re using a tenancy admin or IAM user with permissions to manage users’ API keys:
inspect users,read users,manage api-keyson IAM users (or equivalent policy).
2. List Users You Want to Check
Example: list all users in the tenancy:3. For Each User, List Their API Keys
For each user OCID (say$USER_OCID):4. Decide Which API Key to Keep
Typical rules:- Keep the newest key (largest
time-created). - Or keep a specific fingerprint you know is used by automation.
5. Delete All Other API Keys (Leave Only One)
List all key IDs for the user:$KEEP_KEY_ID:
Note: In the API & CLI, the API key is deleted using its fingerprint, but the CLI returns it as id which equals the fingerprint.
6. Automate for All Users (Tenancy‑Wide)
Example Bash script (run from an admin machine):7. Integrate With IAM Monitoring / Cloud Guard
To monitor this condition rather than only remediate:- Enable Cloud Guard in the tenancy and choose the “IAM” target.
- Use or create a detector recipe that checks for:
- “Users with more than one API key” (OCI typically provides this as a managed detector).
- Configure this script as:
- A remediation function (OCI Functions) called by a Cloud Guard responder, or
- A scheduled job (OCI DevOps/cron) that runs periodically using the CLI.
If you tell me whether you prefer newest key, oldest key, or a specific naming/fingerprint rule, I can adapt the loop/query exactly to that policy.
Using Python
Using Python
Below is a simple, practical way to enforce “OCI IAM Users Should Have Only One Active API Key” using Python and the OCI Python SDK. The idea:
- List all IAM users (or a subset you care about).
- For each user, list API keys.
- If a user has more than one active key, keep only one and delete the rest.
1. Prerequisites
-
Install OCI Python SDK
-
Configure OCI credentials (for the script to talk to OCI):
Create/verify~/.oci/configwith at least:Make sure this user has enough IAM permissions to:- List and manage users
- List and manage API keys
2. High-Level Strategy
- Get the compartment/tenancy where IAM users live (IAM is global, but you use tenancy OCID).
- For each IAM user (or filtered ones):
- Use
list_api_keys(user_id)to get keys. - If
len(keys) > 1, decide a rule:- Keep newest, delete older ones OR
- Keep oldest, delete others.
- Use
delete_api_key(user_id, fingerprint)to remove extra keys.
- Use
3. Example Python Script (Remediate to One Active Key per User)
4. How to Use for “Monitoring”
-
Monitoring-only:
- Keep
DRY_RUN = True. - Run the script on a schedule (e.g., cron, OCI Functions + Events).
- Collect output/logs to alert if any noncompliant users are found.
- Keep
-
Monitoring with Auto-Remediation:
- Set
DRY_RUN = False. - Run on a schedule to automatically delete extra keys and enforce 1 key per user.
- Set
5. Optional: Scope / Safeguards
- Add filters so you only enforce this on:
- Specific groups (e.g., only human users, not service users).
- Users with certain tags.
- Log every change (user ID, key fingerprint, timestamp) to a file or logging system.
- Test first in a non-production tenancy with
DRY_RUN = True, then live.
Using Terraform
Using Terraform
oci_identity_api_key resource tied to that IAM user; remove any additional oci_identity_api_key resources for this user from your Terraform configuration (or import existing keys and then remove them) to have Terraform destroy them.Note: Destroying extra oci_identity_api_key resources will immediately revoke those keys and can break any clients still using them.To verify, terraform plan should show:- No changes to
oci_identity_user.oci_iam_monitoring_user. - At most one
oci_identity_api_keyresource for this user. - Any surplus
oci_identity_api_keyresources for this user marked with- destroy.

