# AWS IAM Policy Linter & Explainer API

> Lint and explain AWS IAM policies: expand wildcards to real actions, check ARNs and condition keys, flag admin, PassRole and privilege-escalation risks.

- Endpoint: `GET | POST https://apibox.io.vn/v1/iam-policy`
- Category: Security & Crypto
- HTML docs: https://apibox.io.vn/docs/iam-policy/ (Vietnamese: https://apibox.io.vn/vi/docs/iam-policy/)
- Online tool: https://apibox.io.vn/tools/iam-policy/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send an identity-based policy, a resource-based policy (S3 bucket, KMS, SQS…), a role trust policy or an SCP (detected, or set `type`). The catalogue of ~460 services and ~22,500 actions with their access levels, resource types (ARN formats) and condition keys comes from the AWS Service Authorization Reference and is refreshed weekly. Nothing is sent to AWS and no credentials are needed.

Lint (`action=lint`, also part of the default `analyze`): grammar (Version, Effect, Action / NotAction, Resource / NotResource, Principal by policy type, Sid), unknown services and actions with "did you mean", wildcards that match nothing, ARN syntax, actions whose resource type does not match any Resource (classic: s3:GetObject on arn:aws:s3:::bucket without /*), actions that only work with Resource "*", condition operators, unknown or unsupported condition keys, value types, ForAllValues with Allow, `*` admin grants, service wildcards, Allow + NotAction / NotResource, iam:PassRole on "*", 27 known privilege-escalation paths, public principals and federated trust without conditions, size limits.

Explain (`action=explain`) lists every statement with the expanded actions and their access level (List / Read / Write / Permissions management / Tagging), resources, principals and conditions, plus a per-service summary. `action=minimize` rewrites Allow statements to explicit actions filtered by `access_levels` (e.g. `list,read`) and / or `actions_used` (from CloudTrail or IAM Access Analyzer).

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `policy` | body | object | yes |  | Policy JSON (object or string; max 200 KB). |
| `action` | body|query | string | no | `analyze` | `analyze` (lint + explain), `lint`, `explain` or `minimize` (alias `mode`). |
| `type` | body|query | string | no |  | `identity`, `resource`, `trust` or `scp` (default: detected). |
| `max_actions` | body|query | number | no | `200` | Expanded actions listed per statement. |
| `access_levels` | body|query | string | no |  | minimize: keep only these levels, e.g. `list,read`. |
| `actions_used` | body | array | no |  | minimize: actions actually used (e.g. from CloudTrail). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/iam-policy" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"lint","policy":{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:ListBucket"],"Resource":"arn:aws:s3:::my-bucket"},{"Effect":"Allow","Action":"iam:PassRole","Resource":"*"}]}}'
```

## Example response

```json
{
  "valid": true,
  "errors": 0,
  "warnings": 2,
  "info": 0,
  "summary": {
    "type": "identity",
    "statements": 2,
    "allow_all": false,
    "allowed_actions": 3,
    "services": {
      "iam": {
        "Write": 1
      },
      "s3": {
        "List": 1,
        "Read": 1
      }
    }
  },
  "findings": [
    {
      "rule": "resource-mismatch",
      "severity": "warning",
      "message": "No Resource of this statement matches the resource types of s3:GetObject (object actions need arn:aws:s3:::bucket/*, bucket actions arn:aws:s3:::bucket): this action is never granted",
      "statement": 0
    },
    {
      "rule": "passrole-wildcard",
      "severity": "warning",
      "message": "iam:PassRole on Resource \"*\": the principal can hand any role (incl. admin roles) to a service; restrict Resource to specific role ARNs and add an iam:PassedToService condition",
      "statement": 1
    }
  ],
  "source": {
    "name": "AWS Service Authorization Reference (servicereference.us-east-1.amazonaws.com)",
    "licence": "CC BY-SA 4.0 (AWS documentation)",
    "url": "https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html"
  },
  "data_built": "2026-11-16"
}
```

## Use cases

- Review IAM policies in Terraform / CloudFormation pull requests
- See what s3:Get* or ec2:Describe* really grants before approving it
- Turn a wildcard policy into a read-only least-privilege policy
- Audit customer accounts for public trust policies and escalation paths

## FAQ

### Does it call AWS?

No. Analysis is offline against the published Service Authorization Reference; send only the policy JSON.

### Is the action list current?

It is rebuilt weekly from AWS’s machine-readable reference; data_built in the answer shows the date.

### Is the effective-permission result exact?

It is an approximation: only unconditional Deny statements on "*" are subtracted, and permission boundaries / SCPs of the account are not known.
