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
CriticalAddress
Compliance, SecurityCompliance 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
Remediation
Using Console
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.
If you paste a specific policy statement you’re remediating, I can give you the exact replacement lines for Monitoring.
1. Locate Overly Permissive IAM Policies
- Sign in to the OCI Console.
- Open the Navigation menu → Identity & Security → Identity → Policies.
- Check both:
- The tenancy (root) compartment.
- Any subcompartments where Monitoring is used.
- In each compartment’s Policies page:
- Open each policy and look for statements containing:
all-resourcesresource-type all-resourcesinspect all-resources in tenancyread 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).
- Open each policy and look for statements containing:
2. Determine the Actual Need for Monitoring
For each policy withall-resources, determine what the user/group is actually supposed to do with Monitoring. Common needs:- View metrics and alarms:
inspect metrics-familyread metrics-familyinspect alarmsread alarms
- Create or modify alarms/metrics:
manage metrics-familymanage alarms
- 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:- Open the policy in the console.
- Click Edit Policy.
-
Replace any broad lines like:
with more specific monitoring‑related rules, for example: View only:Full management (Monitoring only):Prefer compartment scoping where possible:
-
If the group also legitimately needs access to other services, add separate, specific statements for those service resource-types instead of using
all-resources. - Click Save Changes.
4. Remove Any Residual “all-resources” Access
- Ensure there are no remaining statements like:
inspect all-resources in tenancyread all-resources in tenancymanage all-resources in tenancy- or the same at compartment scope.
- If a user/group needs broad view across services, consider:
inspect <service>-familyper service instead ofall-resources.
5. Validate Access
- Use a test user (or ask an actual user from the group) to:
- Navigate to Observability & Management → Monitoring.
- 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-resourcespolicy allowed.
- 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:- Go to Navigation menu → Identity & Security → Cloud Guard (or Security Advisor).
- Review findings related to:
- “IAM policies granting access to all-resources” or similar.
- 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.
Using CLI
Using CLI
Below is a practical, CLI‑only approach to find and fix OCI IAM policies that wrongly grant
2. Identify Policies Granting
If you have policies in sub‑compartments only, repeat for those 2.2. Filter policies whose statements contain
Note the policy name and OCID for each one you must fix.
Look for statements like:
Replace
Adjust to your actual requirements.
Ensure there is no This should return 6.2. Re-scan for any remaining
Repeat Steps 3–5 for any remaining policies.
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
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
compartment-ids.2.2. Filter policies whose statements contain all-resources
3. Inspect Each Problematic Policy
Pick a policy OCID from the previous step:4. Design Least-Privilege Replacement
For IAM monitoring / security monitoring (typical “read-only” or “events/logs” access), replaceall-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
<group-name> and <compartment-name> accordingly, and only include what is actually needed.5. Update the Policy Using OCI CLI
You will:- Build a new JSON array of statements.
- Use
oci iam policy updateto replace the existing statements.
5.1. Create a file with the new statements
Createpolicy-statements.json:5.2. (Optional) Backup the current policy
5.3. Update the policy
6. Validate the Remediation
6.1. Confirm the new statements
all-resources present:[].6.2. Re-scan for any remaining all-resources policies
7. (Optional) Automate Continuous Checking
You can periodically run a script that:- Lists all policies in the tenancy and sub‑compartments.
- Flags any containing
all-resources. - Sends an alert (e.g., to your monitoring system).
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.Using Python
Using Python
Below is a practical way to detect and remediate “all-resources” IAM policies in OCI using Python and the OCI SDK.
You want to:
Use this first to monitor and report problems (e.g., run in a scheduled job, push results to Monitoring/Logging, etc.).
Usage:
1. What you’re remediating
Bad pattern (overly broad policy examples):- Identify such policies.
- Decide what the correct least-privilege policies should be.
- Programmatically update or flag them using Python.
2. Prerequisites
- Install SDK:
-
Configure OCI credentials:
~/.oci/configwith a profile, e.g.[DEFAULT]. -
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.
4. Plan Your Remediation
You must define what permitted resources and actions should be instead ofall-resources, such as:- Replace:
- With something like:
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).
-
First run as monitoring / audit:
- Review printed before/after.
-
After you’re confident, set
DRY_RUN = Falseand rerun to apply.
6. Integrating With IAM Monitoring
For continuous monitoring:-
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.
-
Optionally have a “remediation mode” script:
- Triggered manually (or via an approval flow),
- Uses the remediation logic above.
- 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.
Using Terraform
Using Terraform
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.
