Inferensys

Prompt

Cloud IAM Policy Over-Permission Review Prompt

A practical prompt playbook for using Cloud IAM Policy Over-Permission Review Prompt in production AI workflows.
Legal team reviewing EU AI Act compliance documents on laptop in modern office, coffee cups and papers on table, casual meeting.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the job-to-be-done, the ideal user, required context, and explicit boundaries for the Cloud IAM Policy Over-Permission Review Prompt.

This prompt is designed for cloud security engineers and DevSecOps teams who need to audit existing IAM policies for excessive permissions. The core job-to-be-done is triage: you have a raw IAM policy document (JSON) and a clear definition of intended access patterns—ideally derived from actual CloudTrail logs or a well-scoped requirements document—and you need a structured, actionable finding that identifies which roles or statements grant more access than necessary. The ideal user is someone who understands IAM evaluation logic, can provide a precise [INTENDED_ACCESS] specification, and will treat the model's output as a starting point for remediation, not a final authority.

You should use this prompt when you have a specific policy to review and a concrete, machine-readable or clearly enumerated definition of what access is actually needed. For example, you might provide a policy attached to an EC2 instance role and a list of required S3 buckets and KMS keys, or a summary of CloudTrail events for the last 90 days. The prompt works best as an interpretation layer that sits between raw policy data and your vulnerability management workflow (e.g., Jira tickets, Security Hub findings). It is not a replacement for automated reasoning tools. Always run the policy through IAM Access Analyzer and the IAM Policy Simulator first; use this prompt to interpret the results, identify over-privileges that policy simulator warnings might not explicitly flag, and draft the specific permission removal recommendations in plain English.

Do not use this prompt for real-time authorization decisions, for generating new policies from scratch, or as a substitute for a full policy-as-code review pipeline. It is also inappropriate for policies where the intended access is unknown or purely speculative—the quality of the output depends entirely on the precision of the [INTENDED_ACCESS] input. If you cannot define what access is needed, the model will produce unreliable or overly aggressive recommendations. Finally, never apply the model's suggested policy changes directly to production without human review and testing in a staging environment. The prompt is a triage accelerator, not an auto-remediator.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Cloud IAM Policy Over-Permission Review Prompt delivers reliable results and where it introduces unacceptable risk. Use these cards to decide if this prompt fits your workflow before integrating it into a security review pipeline.

01

Good Fit: Policy-to-Usage Gap Analysis

Use when: You have an IAM policy document and corresponding access logs (or an intended access pattern) and need to identify permissions granted but never used. Guardrail: The prompt must receive structured usage data; it cannot infer actual usage from policy alone. Pair with IAM Access Analyzer or policy simulator output for grounding.

02

Bad Fit: Real-Time Access Decisions

Avoid when: You need a sub-second authorization decision in a request path. This prompt is designed for asynchronous review, not enforcement. Guardrail: Use a policy evaluation engine (e.g., OPA, Cedar) for real-time decisions. Reserve this prompt for offline audit and remediation planning.

03

Required Inputs: Policy Document and Usage Evidence

What to watch: The prompt degrades sharply without both the IAM policy JSON and a usage summary. Missing usage data leads to hallucinated permission assessments. Guardrail: Validate that both [POLICY_DOCUMENT] and [USAGE_LOG_SUMMARY] placeholders are populated before invocation. If usage data is unavailable, scope the prompt to static policy analysis only and lower confidence thresholds.

04

Operational Risk: Over-Confident Removal Recommendations

What to watch: The model may recommend removing permissions that appear unused but are required for infrequent operations (e.g., disaster recovery, quarterly audits). Guardrail: Require human approval for any permission removal that affects production roles. Cross-reference recommendations against runbooks and incident response procedures before executing changes.

05

Operational Risk: Cross-Account and Federated Role Blindness

What to watch: The prompt may miss over-permission risks in cross-account roles, federated access, or chained assume-role patterns because usage logs often fragment across accounts. Guardrail: Aggregate usage data across all accounts in the trust chain before analysis. Flag any role with cross-account access for manual review regardless of prompt output.

06

Operational Risk: Condition Key and Policy Boundary Complexity

What to watch: IAM conditions, resource policies, permission boundaries, and SCPs can restrict effective permissions in ways the prompt may not fully model, leading to false positives in over-permission detection. Guardrail: Run prompt output through IAM policy simulator to verify effective permissions before filing remediation tickets. Treat the prompt as a triage tool, not the final authority.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt template for identifying over-privileged roles in cloud IAM policies by comparing granted permissions against actual usage or intended access patterns.

This section provides the core prompt template you will paste into your AI harness. The template is designed to ingest a cloud IAM policy document alongside a set of usage logs or an intended access specification. It instructs the model to perform a structured, permission-by-permission analysis, identifying any granted permissions that are not justified by actual usage. The output is a strict JSON schema that maps directly to a downstream remediation or ticketing system, ensuring the review is actionable rather than conversational.

Below is the copy-ready template. Replace every square-bracket placeholder with real data before sending. The [POLICY_DOCUMENT] should contain the raw JSON of your IAM policy. The [USAGE_DATA] placeholder should be populated with a summary of actions from CloudTrail logs, IAM Access Analyzer findings, or a list of intended permissions from your architecture specification. The [CONSTRAINTS] field is where you define exceptions, such as permissions required for emergency break-glass roles or known service-linked role defaults that should not be flagged. The [RISK_LEVEL] placeholder allows you to set a threshold for the analysis, such as 'Medium' or 'High', to filter out low-severity findings.

text
You are a cloud security auditor specializing in IAM policy least-privilege analysis. Your task is to compare the granted permissions in an IAM policy against actual usage data or an intended access pattern specification. You must identify any permissions that are over-privileged and recommend specific actions to remove them.

## INPUT

**IAM Policy Document:**
```json
[POLICY_DOCUMENT]

Usage Data or Intended Access Specification:

text
[USAGE_DATA]

CONSTRAINTS

  • Do not flag permissions that are part of the following exception list: [CONSTRAINTS]
  • Only report findings with a severity level of [RISK_LEVEL] or higher.
  • If a permission is granted via a wildcard ("*"), but only a subset of actions under that service are used, you must recommend replacing the wildcard with the specific used actions.
  • For each finding, you must provide a direct quote from the policy document as evidence.
  • If the usage data is empty or unavailable, you must state this clearly and mark all findings as "unverified" with a confidence score of "Low".

OUTPUT_SCHEMA

You must respond with a valid JSON object conforming to this schema:

json
{
  "analysis_metadata": {
    "policy_name": "string",
    "analysis_timestamp": "string (ISO 8601)",
    "usage_data_source": "string",
    "total_permissions_granted": "integer",
    "total_permissions_used": "integer"
  },
  "findings": [
    {
      "finding_id": "string",
      "severity": "High | Medium | Low",
      "policy_statement_sid": "string",
      "overly_permissive_action": "string (e.g., 's3:DeleteBucket')",
      "evidence": "string (direct quote from policy)",
      "actual_usage": "string (e.g., 's3:GetObject, s3:PutObject')",
      "recommendation": "string (specific new policy JSON snippet or action list)",
      "confidence": "High | Medium | Low"
    }
  ],
  "summary": {
    "total_findings": "integer",
    "high_severity_count": "integer",
    "medium_severity_count": "integer",
    "low_severity_count": "integer",
    "overall_risk_assessment": "string"
  }
}

After pasting the template, the most critical adaptation step is populating the [USAGE_DATA] field with high-quality information. Do not rely on a human's memory of what a service should access. Instead, programmatically generate this data from AWS CloudTrail event histories, GCP Audit Logs, or Azure Activity Logs, filtering for successful actions taken by the specific role in the last 90 days. If you are reviewing a policy before deployment, use your infrastructure-as-code definitions or a formal access matrix as the intended specification. The quality of this input is the single biggest factor in the prompt's success. Before integrating this prompt into a CI/CD pipeline, run it against a set of policies with known over-permissions, validated by IAM Access Analyzer, to calibrate the severity and confidence thresholds.

IMPLEMENTATION TABLE

Prompt Variables

Each variable must be populated before the prompt is sent. Missing or malformed inputs are the most common cause of unreliable output in this workflow.

PlaceholderPurposeExampleValidation Notes

[IAM_POLICY_DOCUMENT]

The full IAM policy JSON to review for over-permission

{"Version": "2012-10-17", "Statement": [...]}

Must be valid JSON. Parse check required. Reject if policy exceeds 50KB or contains non-IAM top-level keys.

[USAGE_LOG_SUMMARY]

Aggregated last-access timestamps and service usage per role or principal from CloudTrail or equivalent

Role/AdminAccess: unused 90d; Role/ReadOnly: s3:GetObject 2d ago

Must include a time window (e.g., 90d). Null allowed if no usage data exists, but output must flag lower confidence.

[INTENDED_ACCESS_PATTERN]

Natural language description of what access the principal should have

Read-only access to app-logs bucket in us-east-1; no write or delete

Required. If absent, the prompt cannot distinguish over-permission from intended broad access. Minimum 10 characters.

[ACCESS_ANALYZER_FINDINGS]

Output from IAM Access Analyzer or equivalent external reachability analysis

Finding: Role/AdminAccess grants s3:* to external account 111122223333

Null allowed. If provided, must be valid JSON array of findings. Findings without Resource or Action fields are rejected.

[POLICY_SIMULATOR_RESULTS]

Results from IAM policy simulator for test actions against the policy

Action s3:DeleteBucket on resource arn:aws:s3:::prod-data: ALLOWED

Null allowed. If provided, each entry must include Action, Resource, and Decision fields. Incomplete entries trigger a pre-flight warning.

[EXCLUSION_LIST]

List of permissions or roles to exclude from review because they are known-acceptable

["iam:ChangePassword", "Role/BreakGlassAccess"]

Null allowed. If provided, must be a JSON array of strings. Entries not matching any Action or Role in the policy are flagged as stale exclusions.

[OUTPUT_SCHEMA]

Target JSON schema for the structured finding output

{"findings": [{"role": "string", "excess_permissions": ["string"], "evidence": "string", "severity": "string"}]}

Must be a valid JSON Schema object. If absent, the default schema is used. Reject schemas that lack required fields for findings.

[CONFIDENCE_THRESHOLD]

Minimum confidence score (0.0-1.0) required to include a finding in the output

0.7

Must be a float between 0.0 and 1.0. Defaults to 0.6 if absent. Values below 0.5 produce noisy output; values above 0.9 suppress true positives.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Cloud IAM Policy Over-Permission Review Prompt into a security review pipeline or CI/CD workflow.

This prompt is designed to operate as a batch analysis step within a cloud security posture management workflow, not as a real-time interactive chatbot. The primary integration point is a security review pipeline that periodically (or on-demand) exports IAM policy documents and corresponding access advisor or policy simulator results, feeds them to the model, and processes the structured findings. The prompt expects a complete policy document and a set of usage or intended-access records as input, so the harness must assemble this context before calling the model. Because IAM misconfigurations can directly lead to privilege escalation and data exposure, the harness must treat every model output as a recommendation requiring human or automated policy-simulator verification before any policy change is applied.

Input assembly and validation: The harness should collect the raw IAM policy JSON from the cloud provider's API (e.g., aws iam get-policy-version or gcloud iam roles describe) and pair it with access activity data from IAM Access Analyzer, CloudTrail, or equivalent usage logs. Before calling the model, validate that the policy document is well-formed JSON and that the usage records contain the expected fields (principal, action, resource, last accessed timestamp). Reject malformed inputs early and log the failure for operator review. The prompt's [POLICY_DOCUMENT] placeholder should receive the full policy JSON as a string, while [ACCESS_ACTIVITY] should receive a structured summary of which permissions were actually used, formatted as a table or JSON array. If usage data is unavailable, the harness should substitute intended access patterns from a configuration file or architecture document, and the prompt's [CONTEXT] field should explicitly note that the analysis is based on intended rather than observed usage.

Model selection and tool use: This is a reasoning-heavy task that benefits from models with strong analytical capabilities and large context windows to hold entire policy documents. GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate choices. The prompt does not require function calling or external tool use during generation, but the harness should consider a two-pass architecture: first, call the model to extract the list of over-privileged permissions with their justifications; second, run each recommended removal through the cloud provider's IAM policy simulator (e.g., iam simulate-principal-policy) to confirm that the removal would not break legitimate access. The harness should flag any recommendation that fails simulation and append the simulation result to the finding before presenting it to a human reviewer.

Output validation and retries: The prompt instructs the model to return a JSON array of findings with a specific schema. The harness must validate that the response is parseable JSON and that each finding object contains the required fields (role_name, permission, resource, last_used_or_intended, risk_level, recommendation, justification). If validation fails, implement a single retry with the validation error message appended to the prompt as additional [CONSTRAINTS] context. If the retry also fails, log the raw response and escalate for manual review rather than silently dropping the analysis. For high-risk environments, consider requiring a second model call (from a different model or temperature setting) to independently verify the findings and flag disagreements.

Logging, audit trail, and human review: Every invocation should produce an audit record containing the input policy hash, the model version, the raw and parsed outputs, validation results, and any simulation outcomes. Store these records in an append-only log for compliance and retrospective analysis. The harness should route findings with risk_level: critical or risk_level: high to an immediate review queue (e.g., a Jira ticket or PagerDuty alert) and batch lower-severity findings for weekly review. Never automatically apply IAM policy changes based solely on model output. The harness should generate a proposed policy diff and require explicit human approval or a break-glass automation with compensating controls before any modification reaches the cloud environment. This is the single most important safety boundary in the implementation.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structured output schema for the Cloud IAM Policy Over-Permission Review Prompt. Use this contract to validate model responses before integrating findings into your vulnerability management workflow.

Field or ElementType or FormatRequiredValidation Rule

findings

Array of objects

Must be a non-null array. If no over-permissions are found, return an empty array.

findings[].policy_id

String

Must match a policy identifier from [INPUT_POLICY_DOCUMENT]. Regex check against source IDs.

findings[].over_permission_summary

String

Must be a single sentence under 200 characters. Cannot be null or empty.

findings[].excessive_actions

Array of strings

Each string must match a valid cloud provider action format (e.g., 'service:ActionName'). Array must contain at least one entry.

findings[].recommended_removal_actions

Array of strings

Must be a subset of excessive_actions. Cannot recommend removing actions not listed as excessive.

findings[].evidence

Object

Must contain usage_logs_evidence and access_analyzer_evidence fields.

findings[].evidence.usage_logs_evidence

String or null

If [INPUT_USAGE_LOGS] was provided, must cite specific unused permissions with a 90-day lookback. If no logs provided, must be null.

findings[].evidence.access_analyzer_evidence

String or null

If [INPUT_ACCESS_ANALYZER_RESULTS] was provided, must reference specific analyzer findings. If no analyzer results provided, must be null.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when using LLMs to review IAM policies for over-permission, and how to guard against it.

01

Wildcard Blindness

What to watch: The model fails to flag overly broad permissions when they use wildcards (*) in resources or actions, treating them as normal entries. This is the most common and dangerous failure mode in IAM review. Guardrail: Pre-process the policy document to extract and explicitly enumerate all wildcard statements in a dedicated section of the prompt. Add a specific instruction: 'Flag every statement containing * in Action or Resource. Explain what a least-privilege replacement would look like.'

02

Usage-Context Disconnect

What to watch: The model recommends removing a permission that appears unused in access logs but is required for infrequent operations like disaster recovery, key rotation, or quarterly reporting. This creates a latent availability risk. Guardrail: Always include a [REQUIRED_OPERATIONS] input field listing known infrequent but critical tasks. Instruct the model to cross-reference every removal recommendation against this list and flag conflicts.

03

Condition Key Neglect

What to watch: The model focuses exclusively on the Action and Resource blocks while ignoring Condition clauses that already scope down access. It recommends removing permissions that are already safely constrained by conditions like aws:SourceIp or aws:RequestedRegion. Guardrail: Add a validation step that requires the model to explicitly state the effect of any Condition block before recommending permission removal. If a condition adequately scopes the permission, the finding severity must be downgraded.

04

Service-Linked Role Confusion

What to watch: The model flags permissions granted to AWS service-linked roles or managed policies as over-privileged, failing to recognize that these are controlled by the service and cannot be modified without breaking the integration. Guardrail: Include a [MANAGED_POLICY_ALLOWLIST] input that lists known service-linked and AWS-managed policies. Instruct the model to skip findings on these policies and note that they are externally governed.

05

Cross-Account Assumption Oversight

What to watch: The model treats a role's broad permissions in isolation, missing that the role can only be assumed by a specific external account or SAML provider. The effective permissions are much narrower than the raw policy suggests. Guardrail: Require the prompt to ingest the role's trust policy alongside the permission policy. Add an instruction: 'Before scoring severity, evaluate who can assume this role. If the trust policy restricts assumption to a known safe principal, reduce the effective risk rating.'

06

NotAction and NotResource Misinterpretation

What to watch: The model incorrectly interprets policies using NotAction or NotResource negation, either missing the broad exclusion effect or flagging it as an error when it is an intentional advanced policy pattern. Guardrail: Add a dedicated instruction block that explains how to interpret NotAction and NotResource with an example. Require the model to output its interpreted effective permission set for any policy containing these elements before making a judgment.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the Cloud IAM Policy Over-Permission Review Prompt before integrating it into a security review pipeline. Each row defines a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Permission-to-Usage Mapping Accuracy

At least 90% of identified over-permissions match unused permissions in the provided [ACCESS_LOG] or [INTENDED_ACCESS_PATTERN]

Findings list permissions that are actively used in the provided usage data or contradict the stated intended access pattern

Run prompt on 10 policy documents with known usage data; compare identified over-permissions against a ground-truth set of unused permissions

False Positive Rate on Wildcard Permissions

Prompt correctly identifies that s3:Get* is not over-privileged when [ACCESS_LOG] shows usage of s3:GetObject and s3:GetBucketLocation

Prompt flags a wildcard permission as over-privileged when all actions covered by the wildcard appear in the usage log

Test with 5 policies containing wildcard permissions where usage logs show full coverage of the wildcard scope

Remediation Specificity

Every removal recommendation includes the exact permission string to remove and the IAM statement line reference from [POLICY_DOCUMENT]

Recommendations say 'reduce permissions' without specifying which permission strings to remove or reference vague policy sections

Parse output against a schema requiring permission_string and statement_reference fields; verify both are present and non-empty for each finding

IAM Access Analyzer Alignment

At least 80% of prompt-identified over-permissions also appear in IAM Access Analyzer findings for the same policy and usage period

Prompt misses over-permissions that IAM Access Analyzer flags as unused, or flags permissions that Access Analyzer considers active

Run prompt and Access Analyzer on the same policy and access log; compute overlap percentage and investigate mismatches

Policy Simulator Consistency

Removal recommendations do not break simulated actions that [INTENDED_ACCESS_PATTERN] requires

Applying the recommended permission removals causes Policy Simulator to deny an action that the intended access pattern says should be allowed

Extract recommended removals, apply them to a policy copy, run Policy Simulator with intended access actions, and verify no denials for required actions

Service-Level Over-Permission Detection

Prompt identifies when a role grants permissions to a service that [ACCESS_LOG] shows zero usage for, and recommends removing the entire service block

Prompt only flags individual actions within a service but misses that the entire service is unused

Test with policies containing permissions for unused services like unused AWS services; verify output recommends service-level removal

Condition Key Awareness

Prompt does not flag a permission as over-privileged when a condition key in the same statement restricts access to specific resources matching [INTENDED_ACCESS_PATTERN]

Prompt ignores condition keys and flags permissions as over-privileged despite condition-based restrictions that align with intended access

Test with policies containing resource-level conditions; verify that condition-restricted permissions are not flagged when conditions match intended access

Output Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and correctly typed

Output is missing required fields, contains malformed JSON, or uses incorrect types for fields like severity or confidence

Validate output with a JSON Schema validator configured against the expected output contract; reject on any schema violation

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single IAM policy document and a small set of usage logs. Keep the output format loose (bulleted findings with permission names and a brief risk note). Skip strict schema validation and focus on whether the model correctly identifies obviously unused permissions.

code
Analyze this IAM policy against the provided access logs. List any permissions that appear unused or overly broad.

Policy: [POLICY_JSON]
Access Logs (last 90 days): [ACCESS_LOG_SUMMARY]

Watch for

  • The model flagging permissions that are used infrequently but are still necessary (e.g., quarterly audit roles)
  • Missing distinction between "unused" and "overly broad" (wildcard actions vs. specific unused actions)
  • No confidence indicators on findings, making it hard to know which to trust
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.