Skip to main content

More Info:

IAM policies should follow the principle of least privilege. Policies granting any-user access to manage all-resources create an excessive attack surface and violate security best practices.

Risk Level

Critical

Address

Compliance, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • 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

Below are step‑by‑step remediation instructions using the OCI Console to fix IAM policies that grant all-resources access, specifically for Monitoring–related access.

1. Locate Overly Permissive IAM Policies

  1. Sign in to the OCI Console.
  2. Open the Navigation menuIdentity & SecurityIdentityPolicies.
  3. Check both:
    • The tenancy (root) compartment.
    • Any subcompartments where Monitoring is used.
  4. In each compartment’s Policies page:
    • Open each policy and look for statements containing:
      • all-resources
      • resource-type all-resources
      • inspect all-resources in tenancy
      • read all-resources in compartment <name>
      • manage all-resources in compartment <name>
    • Also look for broad wildcards in tags or conditions (e.g., no condition narrowing users/groups).
Those are the misconfigurations you must replace with least‑privilege, Monitoring‑specific statements.

2. Determine the Actual Need for Monitoring

For each policy with all-resources, determine what the user/group is actually supposed to do with Monitoring. Common needs:
  • View metrics and alarms:
    • inspect metrics-family
    • read metrics-family
    • inspect alarms
    • read alarms
  • Create or modify alarms/metrics:
    • manage metrics-family
    • manage alarms
Scope these either at:
  • The tenancy (if absolutely necessary), or
  • A specific compartment where Monitoring resources live.

3. Replace “all-resources” with Monitoring‑Scoped Verbs/Resources

For each offending policy:
  1. Open the policy in the console.
  2. Click Edit Policy.
  3. Replace any broad lines like:
    with more specific monitoring‑related rules, for example: View only:
    Full management (Monitoring only):
    Prefer compartment scoping where possible:
  4. If the group also legitimately needs access to other services, add separate, specific statements for those service resource-types instead of using all-resources.
  5. Click Save Changes.

4. Remove Any Residual “all-resources” Access

  • Ensure there are no remaining statements like:
    • inspect all-resources in tenancy
    • read all-resources in tenancy
    • manage all-resources in tenancy
    • or the same at compartment scope.
  • If a user/group needs broad view across services, consider:
    • inspect <service>-family per service instead of all-resources.

5. Validate Access

  1. Use a test user (or ask an actual user from the group) to:
    • Navigate to Observability & ManagementMonitoring.
    • Confirm:
      • They can perform required Monitoring actions (view/create/edit alarms, view metrics).
      • They cannot perform unrelated actions (e.g., manage Compute, Networking, IAM) that the previous all-resources policy allowed.
  2. If some actions fail that should succeed, add only the minimal extra permissions needed.

6. (Optional) Use Cloud Guard / Security Advisor

If you’re using OCI Cloud Guard or Security Advisor:
  1. Go to Navigation menuIdentity & SecurityCloud Guard (or Security Advisor).
  2. Review findings related to:
    • “IAM policies granting access to all-resources” or similar.
  3. Verify that the updated policies clear those findings after your changes propagate.

If you paste a specific policy statement you’re remediating, I can give you the exact replacement lines for Monitoring.
Below is a practical, CLI‑only approach to find and fix OCI IAM policies that wrongly grant all-resources and then replace them with least-privilege for IAM/Monitoring use cases.

1. Prerequisites

Make sure:
  • OCI CLI is installed and configured (oci setup config).
  • You know your tenancy OCID.
  • You have access to list and update policies.

2. Identify Policies Granting all-resources

2.1. List all policies in the tenancy

If you have policies in sub‑compartments only, repeat for those compartment-ids.

2.2. Filter policies whose statements contain all-resources

Note the policy name and OCID for each one you must fix.

3. Inspect Each Problematic Policy

Pick a policy OCID from the previous step:
Look for statements like:

4. Design Least-Privilege Replacement

For IAM monitoring / security monitoring (typical “read-only” or “events/logs” access), replace all-resources with specific resource-types and verbs.Common examples (adapt to your use case):

4.1. Read-only IAM & Security Posture

4.2. Monitoring / Logging / Events in a compartment

Replace <group-name> and <compartment-name> accordingly, and only include what is actually needed.

5. Update the Policy Using OCI CLI

You will:
  1. Build a new JSON array of statements.
  2. Use oci iam policy update to replace the existing statements.

5.1. Create a file with the new statements

Create policy-statements.json:
Adjust to your actual requirements.

5.2. (Optional) Backup the current policy

5.3. Update the policy


6. Validate the Remediation

6.1. Confirm the new statements

Ensure there is no all-resources present:
This should return [].

6.2. Re-scan for any remaining all-resources policies

Repeat Steps 3–5 for any remaining policies.

7. (Optional) Automate Continuous Checking

You can periodically run a script that:
  1. Lists all policies in the tenancy and sub‑compartments.
  2. Flags any containing all-resources.
  3. Sends an alert (e.g., to your monitoring system).
Skeleton example:
Use this output as input to your monitoring pipeline.
If you share one current policy statement you’re using for IAM Monitoring, I can translate it into a concrete least‑privilege policy-statements.json ready to apply via CLI.
Below is a practical way to detect and remediate “all-resources” IAM policies in OCI using Python and the OCI SDK.

1. What you’re remediating

Bad pattern (overly broad policy examples):
You want to:
  1. Identify such policies.
  2. Decide what the correct least-privilege policies should be.
  3. Programmatically update or flag them using Python.

2. Prerequisites

  1. Install SDK:
  1. Configure OCI credentials: ~/.oci/config with a profile, e.g. [DEFAULT].
  2. Have policy manage permission for your user:
    • For example (granted by someone with tenancy admin rights):

3. Detection Script – Find “all-resources” Policies

This script:
  • Lists policies in tenancy (or in all compartments).
  • Flags statements that reference all-resources.
Use this first to monitor and report problems (e.g., run in a scheduled job, push results to Monitoring/Logging, etc.).

4. Plan Your Remediation

You must define what permitted resources and actions should be instead of all-resources, such as:
  • Replace:
  • With something like:
This mapping cannot be safely guessed by a script; you should define a mapping table per group/use case.Example mapping in Python:

5. Remediation Script – Replace “all-resources” Statements

This script:
  • Finds policies with all-resources.
  • For each affected statement, either:
    • Rewrites it using a custom mapping, or
    • Comments it out and leaves the policy for manual editing (safer default).
Below is a conservative version that comments out the bad statements and adds a note, which is safer for automated remediation. After that you can manually refine/replace.
Usage:
  • First run as monitoring / audit:
  • Review printed before/after.
  • After you’re confident, set DRY_RUN = False and rerun to apply.

6. Integrating With IAM Monitoring

For continuous monitoring:
  1. Run a scheduled job (e.g., OCI Functions + OCI Events + Logging or an external scheduler like cron) to:
    • Execute the detection portion.
    • Send findings to:
      • OCI Logging (via Logging API),
      • Email (via Notifications),
      • Metrics (via Monitoring API) so you can create an alarm when count > 0.
  2. Optionally have a “remediation mode” script:
    • Triggered manually (or via an approval flow),
    • Uses the remediation logic above.
If you want, I can extend this with:
  • Sample OCI Function (Python) handler for detection,
  • Or a version that actually rewrites specific “all-resources” lines into concrete least-privilege policies based on a configuration file.
Changing the statements in oci_identity_policy is an in‑place update and does not force replacement of the policy resource; OCI will update the policy text without deleting/recreating it.For verification, terraform plan should show an update to oci_identity_policy.iam_monitoring_least_privilege, with a diff only on the statements attribute, removing any Allow any-user ... manage all-resources ... entries and replacing them with the new, scoped statements.