Skip to main content

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 difficult

Risk Level

Medium

Address

Compliance, Security

Compliance 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

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:
  1. Sign in to OCI Console
    • Log in to the OCI Console with an account that has IAM administrator privileges.
  2. Go to the Users page
    • Open the main navigation menu (☰).
    • Navigate to: Identity & SecurityIdentityUsers.
  3. 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).
  4. 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.
  5. 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.
  6. 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.
  7. 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 GuardDetections (or Dashboard),
      • Confirm that the “user has multiple API keys” problem is cleared or closed for that user.
  8. (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.
Repeat these steps for every user detected as having multiple active API keys.
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.

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-keys on IAM users (or equivalent policy).

2. List Users You Want to Check

Example: list all users in the tenancy:
If you want to restrict to a specific group:

3. For Each User, List Their API Keys

For each user OCID (say $USER_OCID):
This shows all active keys (OCI doesn’t support “disabled” API keys; they’re either present or deleted).

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.
To find the newest key via CLI:
Extract the key ID you want to keep:

5. Delete All Other API Keys (Leave Only One)

List all key IDs for the user:
Example Bash loop to delete all except $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):
Run:

7. Integrate With IAM Monitoring / Cloud Guard

To monitor this condition rather than only remediate:
  1. Enable Cloud Guard in the tenancy and choose the “IAM” target.
  2. Use or create a detector recipe that checks for:
    • “Users with more than one API key” (OCI typically provides this as a managed detector).
  3. 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.
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:
  1. List all IAM users (or a subset you care about).
  2. For each user, list API keys.
  3. If a user has more than one active key, keep only one and delete the rest.
You can then run this script periodically (e.g., via a scheduled job) as your “IAM monitoring/remediation.”

1. Prerequisites

  1. Install OCI Python SDK
  2. Configure OCI credentials (for the script to talk to OCI):
    Create/verify ~/.oci/config with 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.

3. Example Python Script (Remediate to One Active Key per User)


4. How to Use for “Monitoring”

  1. 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.
  2. Monitoring with Auto-Remediation:
    • Set DRY_RUN = False.
    • Run on a schedule to automatically delete extra keys and enforce 1 key per user.

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.
This enforces exactly one active API signing key for the monitoring user in Terraform by having only a single 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_key resource for this user.
  • Any surplus oci_identity_api_key resources for this user marked with - destroy.