More Info:
Admin full-access policies (manage all-resources) should include WHERE conditions. Unconditional full access violates least privilege and increases blast radius if admin credentials are compromised.Risk Level
HighAddress
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 the minimal, practical steps to remediate this using the OCI Console by tightening IAM admin policies with
These are what need conditions.
3. Decide on Appropriate
You must decide what constraint is appropriate for your environment. Common patterns:or:Or even better, change it to more specific statements per compartment, each with conditions.
After (remediated):Or:
If you tell me:
where conditions and aligning them with OCI IAM Monitoring findings.1. Find the Violating Policy from IAM Monitoring
- Sign in to the OCI Console.
- Open the navigation menu → Identity & Security → Identity & Access Monitoring (or IAM Monitoring / Security Center → IAM Monitoring, depending on your tenancy UI).
- Go to Findings / Risky Policies.
- Filter by rule / description containing:
OCI IAM Admin Full Access Policies Should Have WHERE Conditions - Open the finding and note:
- Policy name
- Compartment (or Tenancy)
- Policy statement(s) that are flagged (you will usually see statements like
Allow group <Admins> to manage all-resources in tenancyor similar full admin rights withoutwhere).
2. Open and Edit the Policy
- From the navigation menu → Identity & Security → Identity & Governance → Policies.
- In the Compartment dropdown, choose:
- Tenancy (root) if the policy is at tenancy level, or
- The compartment containing the policy as seen in the finding.
- Search for the policy name you noted in step 1.
- Click the policy, then click Edit Policy Statements (or Edit Policy).
3. Decide on Appropriate where Conditions
You must decide what constraint is appropriate for your environment. Common patterns:a) Tag-based restriction (recommended for fine-grained admin)
b) Network-based restriction (admin only from trusted IPs / CIDRs)
c) Time-based restriction (admin only within business hours)
d) Restrict to specific compartments (if using overly broad “tenancy”)
Instead ofin tenancy, use compartment-scoped statements, or compensate with conditions:4. Rewrite the Problematic Statement(s)
For each flagged full-admin statement:- Copy the existing statement to a text editor.
- Add a WHERE clause that matches your control choice (tag, IP, time, compartment, etc.).
- Replace the old statement with the new one in the policy editor.
- Review for typos (invalid conditions can break policy evaluation).
- Click Save changes.
5. Validate in IAM Monitoring
- Return to Identity & Access Monitoring / IAM Monitoring.
- Open the previous finding.
- After a short interval (or by manually triggering re-evaluation, if available), verify that:
- The finding is now Resolved or No longer detected, OR
- A new finding clearly indicates any further issue (e.g., syntactic problem with your
whereclause).
6. If You Need a Safe Migration Approach
If you are worried about locking out admins:- Create a new policy with the intended
where-restricted statements. - Have one or two admins verify they can still perform required operations.
- Once confirmed:
- Edit the original policy and remove or tighten the overly broad statements.
- Re-check IAM Monitoring findings.
If you tell me:
- Your current exact policy statement(s), and
- How you prefer to restrict admin (by IP, tag, compartment, or time),
where-clause example tailored to your tenancy.Using CLI
Using CLI
Below is a minimal, CLI‑only workflow you can use to remediate the finding “OCI IAM Admin Full Access Policies Should Have WHERE Conditions” for IAM Monitoring.Assumptions:
Adjust the regex if your statements use
could be tightened to something like:Pick and design the
Optionally preserve / update description:
Confirm every “full access” /
- You already have the OCI CLI configured (
oci setup configdone). - You know (or can discover) the compartment(s) where the IAM policies are defined.
- Your goal is to add a WHERE condition to “admin” / “full access” style statements such as
manage all-resources.
1. Identify affected IAM policies
List policies in the tenancy (or a specific compartment) and search for “manage all-resources” without awhere clause.in compartment <name> instead of in tenancy.From this output, note:id– the policy OCIDstatements– the existing statements that need to be edited
2. Decide the appropriate WHERE condition
You must pick a condition that makes sense for IAM Monitoring. Common patterns:-
Limit by compartment:
-
Limit to IAM‑related resources:
-
Limit to read‑only monitoring:
where that matches your security requirement.3. Build the updated list of statements (locally)
-
Export the current policy to a file:
-
Extract the current
statementsto a simple JSON array: -
Edit
statements-orig.jsonwith any text editor.-
Replace each “admin/full access” statement, e.g.:
-
With a version that includes an appropriate WHERE condition, e.g.:
-
Replace each “admin/full access” statement, e.g.:
4. Update the policy with the new statements (CLI)
Oncestatements-orig.json contains your fixed statements:5. Verify
manage all-resources statement now contains a where clause.6. Automate (optional)
To remediate many policies, you can script:- Use the
list+jqfilter from step 1 to enumerate candidate policies. - For each:
- Pull policy JSON
- Use a small script (bash +
jqor Python) to find statements matchingmanage all-resourcesor other full‑admin patterns and append a standardwhereclause for IAM Monitoring. - Call
oci iam policy updatewith the transformed list of statements.
where template and a sample automation script.Using Python
Using Python
Below is a practical way to detect and then remediate overly‑permissive IAM policies in OCI (those with admin/full access and no
orThese give broad “admin” rights without any limiting The goal is to:
(You can weaken
If you tell me your preferred restriction model (for example: “all admin policies must be limited to
where conditions) using Python and the OCI SDK.1. What “Admin Full Access Without WHERE” Means
In OCI, a risky policy typically looks like:where clause such as:- Find statements that are “full access” (e.g.,
manage all-resources,manage *). - Ensure they have a
wherecondition. - If not, either:
- Automatically replace them with a safer version, or
- Alert and require a human to decide the proper condition.
2. Prerequisites
- Install the OCI Python SDK:
-
Configure your OCI credentials (e.g.,
~/.oci/config) and note:- Tenancy OCID
- User OCID
- Key file path
- Fingerprint
- Region
- Give your monitoring principal (user or dynamic group) permission to read and update policies, for example:
manage to specific compartments if needed.)3. Detection Logic (Python)
This script:- Lists all policies
- Parses each statement
- Flags those that appear to be “admin/full access” and that do not include
where
4. Remediation Strategy (What to Actually Change)
You must decide what restriction makes sense for your environment. Some common patterns:-
Limit to users (not instance principals / services):
-
Exclude specific break‑glass / automation accounts:
-
Restrict by compartment:
-
Combine:
SAFE_WHERE_CLAUSE (or build more complex logic) in remediate_policy() to match your standard.5. Safe Rollout Pattern
- Run with
DRY_RUN = Trueand just log all risky statements. - Export findings and decide per policy what the correct
whereconditions should be. - Implement a mapping (e.g., dict by policy name or compartment) to apply the right
wherecondition. - Change
DRY_RUN = False, run in a test tenancy/compartment. - Then run in production.
If you tell me your preferred restriction model (for example: “all admin policies must be limited to
request.principal.type = 'user' and only to two specific compartments”), I can adjust the sample remediation function to match that exactly.Using Terraform
Using Terraform
terraform plan should show the existing oci_identity_policy with its statements argument changing from a manage all-resources in tenancy statement without a where clause to one that includes the where target.compartment.id = 'OCID_OF_ALLOWED_COMPARTMENT' condition.
