[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7A91MK2ZSJ2X41B379EGWVT":3,"skill-same:01M7A91MK2ZSJ2X41B379EGWVT":130},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":6,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M7A91MK2ZSJ2X41B379EGWVT","iam-least-privilege-advisor",null,"Analyzes AWS IAM policies to identify over-permissive grants — wildcard actions, wildcard resources, privilege-escalation actions (PassRole, AssumeRole), inverse wildcards (NotAction\u002FNotResource), and condition-key bypasses — then provides least-privilege remediation. Use when reviewing IAM policies, checking for wildcard or escalation permissions, auditing role or user privileges, or tightening access control scope.","jhkchan\u002Faws-agent-skills","jhkchan","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1083902?v=4","01M7A2SVQYP9GQTPTDXP5JKYQ4","Jacky Chan","01M7A2SVS117YWCTZABB75HZR1",4,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: iam-least-privilege-advisor\ndescription: Analyzes AWS IAM policies to identify over-permissive grants — wildcard actions, wildcard resources, privilege-escalation actions (PassRole, AssumeRole), inverse wildcards (NotAction\u002FNotResource), and condition-key bypasses — then provides least-privilege remediation. Use when reviewing IAM policies, checking for wildcard or escalation permissions, auditing role or user privileges, or tightening access control scope.\nlicense: Apache-2.0\ncompatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf). No AWS CLI required for offline policy-document classification. Live-account audits use aws iam simulate-principal-policy and aws cloudtrail lookup-events (AWS CLI v2, SSO or key-based credentials).\nmetadata:\n  domain: aws-cloudops\n  complexity: high\n  requires_llm: 'true'\n  phase: '2'\n  supports_pipeline: 'true'\n  entry_point: 'false'\n  family: Security\n  verdict_shape: OVERPERMISSIVE | LEAST_PRIVILEGE | AMBIGUOUS\n  when_to_use: Reviewing an IAM policy document (inline or managed), auditing a role or user before production deployment, checking for wildcard or escalation permissions, tightening access-control scope, or scoping down a policy derived from CloudTrail activity.\n  version: 0.3.0\n  author: Jacky Chan — AWS Community Builder\n  keywords: IAM, least privilege, policy analysis, wildcard permissions, privilege escalation, over-permissive, IAM audit, PassRole, AssumeRole, NotAction, NotResource, condition bypass, policy remediation\n  tags: iam, security, least-privilege, policy-analysis, privilege-escalation\n---\n\n# IAM Least-Privilege Advisor\n\n## Activation\n\nActivate this skill when the user provides an IAM policy document (JSON),\nreferences a role\u002Fuser\u002Fgroup policy for review, or asks whether a policy is\nsafe, least-privilege, or over-permissive. Trigger phrases: \"review this\npolicy\", \"is this least privilege?\", \"check my IAM policy\", \"tighten these\npermissions\", \"audit this role\", \"scan for wildcard permissions\", \"is this\npolicy secure?\".\n\n## Mindset\n\nClassify IAM policy documents against least-privilege principles and provide\nspecific remediation. The goal is not just \"avoid wildcards\" — it is to\nidentify the **blast radius** of every statement: what could a principal with\nthis policy actually do, and could an attacker chain these permissions for\nprivilege escalation?\n\nA policy with `s3:GetObject` on one bucket has a narrow blast radius. A policy\nwith `iam:PassRole` on `\"*\"` has a catastrophic blast radius even though\nneither the action nor the resource is `\"*\"`. The classification must catch\nboth obvious wildcards and subtle escalation paths.\n\n## Quick reference\n\nIf the policy has `Action: \"*\"` on `Resource: \"*\"` or a service wildcard on\n`\"*\"`, it is OVERPERMISSIVE. If it uses `NotAction`\u002F`NotResource`, it is\nOVERPERMISSIVE. If it grants `iam:PassRole` or `sts:AssumeRole` on `\"*\"`, it\nis OVERPERMISSIVE. Named actions on specific ARNs are LEAST_PRIVILEGE. See\nthe steps below for edge cases (conditions, resource scope, exceptions).\n\n## Process — Classification logic (apply in order)\n\n### Step 0: Validate input and policy version\n\nIf the policy document is not valid JSON (malformed syntax, trailing commas,\nunquoted keys, YAML where JSON is expected), output:\n\n```text\nPOLICY: \u003Cname>\nVERDICT: ERROR\nREASON: Policy document is not valid JSON — cannot parse statements.\nREMEDIATION: Validate the policy JSON with a linter or aws iam simulate-custom-policy --policy-input-list.\n```\n\nDo not attempt classification on malformed input. Additionally, check the\n`Version` field: if it is `\"2008-10-17\"` (the legacy version), flag it —\npolicy variables like `${aws:username}` silently fail to resolve, and\nseveral condition operators are unsupported. The correct version is\n`\"2012-10-17\"`. A policy with the wrong version may behave differently\nthan its text suggests, making classification unreliable.\n\n### Step 1: Separate Deny from Allow (with overlap resolution)\n\nIf a statement has `Effect: Deny`, it **narrows** effective permissions — it\nnever grants access. Deny statements are security controls. **Exclude Deny\nstatements from the verdict** — they can only reduce the policy's blast\nradius, never increase it. However, if a Deny statement uses `NotAction` or\n`NotResource`, append a **DENY_FLAG** note to the REMEDIATION field:\n\n```text\nDENY_FLAG: Statement \u003CN> uses NotAction\u002FNotResource in a Deny — this denies\nall actions\u002Fresources except those listed, which may break workloads\nsilently. Review whether the deny is intentionally broad.\n```\n\n**Allow\u002FDeny overlap resolution:** when the same action+resource pair appears\nin both an Allow and a Deny statement within the same policy, the Deny\n**always** wins regardless of statement order or Sid. This is the IAM\nevaluation rule: explicit Deny takes absolute precedence. For classification,\ndo NOT let the presence of a Deny \"cancel\" an over-permissive Allow for a\n*different* action+resource — only the exact overlapping pair is denied. A\npolicy that Allows `s3:*` on `*` and Denies `s3:DeleteBucket` on a specific\nbucket is still OVERPERMISSIVE for every other S3 action and resource.\n\n**Cross-policy overlap:** if a permissions boundary or SCP denies the action,\nthe effective permission is denied even though the identity-based policy\nallows it. However, classify the identity-based policy on its own text — a\nboundary can be removed, so the identity policy's blast radius is the\nclassification truth. Note the boundary presence in REMEDIATION.\n\n### Step 2: Admin wildcard — maximum blast radius\n\nIf a statement has `Effect: Allow` with `Action: \"*\"` AND `Resource: \"*\"`,\nthe policy is **OVERPERMISSIVE** with **CRITICAL** risk. This grants every\naction on every resource in the account — equivalent to\n`AdministratorAccess`.\n\n### Step 3: Service-level wildcards on all resources\n\nIf a statement has `Effect: Allow` with any wildcard action (e.g., `s3:*`,\n`ec2:*`, `s3:Get*`, `iam:List*`) AND `Resource: \"*\"`, the policy is\n**OVERPERMISSIVE** with **HIGH** risk — no scope restriction on either axis.\nA generic service wildcard (e.g., `s3:*`, `ec2:*`) is **HIGH**, NOT CRITICAL —\nonly the privilege-escalation-service wildcards (Step 5) escalate to **CRITICAL**.\n\n**Risk-level mapping (emit exactly one RISK per statement, derived from VERDICT):**\n- `OVERPERMISSIVE` + admin wildcard (`Action: \"*\"` `Resource: \"*\"`) → **CRITICAL**\n- `OVERPERMISSIVE` + privilege-escalation-service wildcard (Step 5 list) → **CRITICAL**\n- `OVERPERMISSIVE` + any other service wildcard on `Resource: \"*\"` → **HIGH**\n- `AMBIGUOUS` → **MODERATE** (access is conditionally restricted — bounded exposure)\n- `LEAST_PRIVILEGE` → **LOW**\n\n**Severity escalation:** If the wildcard action is on a **privilege-escalation\nservice**, escalate risk to **CRITICAL**:\n\n- `iam:*` — full IAM control; can create users, roles, policies, and attach\n  them to any principal.\n- `sts:*` — can assume any role in the account or cross-account if the trust\n  policy allows.\n- `kms:*` — can decrypt any ciphertext, modify key policies, schedule key\n  deletion. KMS is a data-access multiplier because most encrypted data\n  flows through it.\n- `secretsmanager:*` — can read every secret in the vault.\n- `ssm:*` — can read all Parameter Store `SecureString` values (often\n  credentials stored outside Secrets Manager).\n- `lambda:*` — can create functions with any execution role when combined\n  with `iam:PassRole`.\n- `cloudformation:*` — can create stacks that instantiate any AWS resource\n  with any passed role, bypassing the principal's own policy.\n\n### Step 4: Inverse wildcards (NotAction \u002F NotResource)\n\nIf a statement uses `NotAction` or `NotResource`, classify as\n**OVERPERMISSIVE** regardless of what actions or resources are listed.\n`NotAction` grants every action EXCEPT the listed ones — when AWS ships a\nnew API for that service, it is automatically included in the grant.\n`NotResource` similarly grants access to all resources except those\nexplicitly excluded. These are inverse wildcards and are almost always a\nmisconfiguration or a debugging shortcut left in production.\n\n### Step 5: Privilege-escalation actions on wildcard resources\n\nIf a statement grants any of these specific actions with `Resource: \"*\"`\n(even without wildcard actions), classify as **OVERPERMISSIVE**. These\nactions enable privilege escalation by design — a principal can use them to\ngain permissions beyond their own policy:\n\n- `iam:PassRole` on `\"*\"` — the single most common privesc vector. Allows\n  passing any role to EC2, Lambda, CloudFormation, or any service that\n  accepts a role ARN. The passed role's permissions then execute under that\n  service's identity, not the caller's.\n- `sts:AssumeRole` on `\"*\"` — allows assuming any role in the account.\n- `iam:CreatePolicy` \u002F `iam:CreatePolicyVersion` on `\"*\"` — can create\n  arbitrary permission documents and attach them to any principal.\n- `iam:AttachRolePolicy` \u002F `iam:PutRolePolicy` on `\"*\"` — can attach any\n  managed policy or inject an inline policy into any role.\n- `iam:UpdateAssumeRolePolicy` on `\"*\"` — can modify the trust policy of any\n  role, allowing arbitrary principals to assume it.\n- `iam:CreateServiceLinkedRole` on `\"*\"` — frequently overlooked. Creates a\n  service-linked role that grants the linked service permissions to act on\n  the caller's behalf (e.g., `AWSServiceRoleForEC2Spot` grants Spot Fleet\n  access). The principal effectively delegates escalated permissions to the\n  service, bypassing their own policy limits.\n\n### Step 6: Wildcard actions scoped to specific resources\n\nIf a statement has `Effect: Allow` with wildcard actions (e.g., `s3:Get*`,\n`s3:List*`) but scoped to specific concrete ARNs, the policy is\n**AMBIGUOUS**. Wildcard action patterns on narrow resources are often\nacceptable for read-only workloads, but AWS adds new APIs over time —\n`s3:Get*` silently included `s3:GetObjectTorrent`, and any future `Get*`\naction is automatically granted.\n\n### Step 7: Evaluate Condition keys for bypass paths\n\nIf an Allow statement includes a `Condition` block, check whether the\ncondition actually restricts access or creates a bypass. See the\n**Condition-key bypass catalog** in the Expert edge cases section for the\nfull list with exploitation mechanics. Quick checklist:\n\n- `aws:SourceIp` containing `0.0.0.0\u002F0` — equivalent to no IP restriction.\n- `ForAllValues:StringEquals` — evaluates true when request has zero\n  matching values (absent-key bypass).\n- `Null` operator with `\"false\"` — means \"key must be ABSENT\".\n- `StringLike` without `*` anchors — exact match, but with unanchored\n  wildcards like `${aws:username}`, user-controlled values may match\n  unintended resources.\n\nStatements with bypass-prone conditions classify as **AMBIGUOUS** at best.\n\n### Step 8: Check resource ARN scope\n\nIf the resource ARN uses a partition wildcard (`arn:aws-*:`), it spans all\npartitions — commercial, AWS GovCloud (US), and AWS China. If it uses a\nbroad pattern like `arn:aws:s3:::*`, it includes every S3 bucket globally,\nnot just the caller's account. These classify as **OVERPERMISSIVE** even\nwhen the action is explicitly named — the resource scope is effectively\nunconstrained.\n\n### Step 9: Specific named actions on specific resources (LEAST_PRIVILEGE)\n\nIf all Allow statements have specific named actions (no wildcards, no\n`NotAction`) AND specific resource ARNs (no `\"*\"`, no `NotResource`), the\npolicy is **LEAST_PRIVILEGE**.\n\n**Legitimate `Resource: \"*\"` exception:** Some AWS actions only support\n`Resource: \"*\"` by design and do NOT break LEAST_PRIVILEGE when paired with\nexplicitly named actions:\n\n- `s3:ListAllMyBuckets`, `s3:HeadBucket`\n- `iam:ListRoles`, `iam:ListUsers`, `iam:GetAccountSummary`\n- `ec2:Describe*` (describe operations — resource-level permissions optional)\n- `organizations:DescribeOrganization`, `organizations:ListAccounts`\n- `cloudwatch:GetMetricStatistics`, `logs:DescribeLogGroups`,\n  `sts:GetCallerIdentity`\n\nThese are safe as long as the action is explicitly named, not a service\nwildcard like `ec2:*`.\n\n### Step 10: IAM policy size check\n\nAfter classification, verify the policy's serialized JSON size against IAM\nlimits:\n\n- **Managed policy:** 6,144 characters max\n- **Inline policy:** 10,240 characters max\n- **Managed policy versions:** 10 versions max (oldest auto-deleted)\n\nIf the policy exceeds the limit, append a **SIZE_WARNING** to the\nREMEDIATION field regardless of verdict:\n\n```text\nSIZE_WARNING: Policy is \u003CN> characters, exceeding the \u003Cmanaged|inline> limit\nof \u003Climit>. Split into multiple statements scoped by service or resource\ngroup. Use AWS IAM Access Analyzer policy generation to produce a compressed\nform. If derived from CloudTrail, partition by service prefix.\n```\n\n### Step 11: Aggregation\n\nWhen a policy contains multiple statements, the policy-level verdict is the\n**worst** verdict across all Allow statements, where OVERPERMISSIVE is worse\nthan AMBIGUOUS and AMBIGUOUS is worse than LEAST_PRIVILEGE.\n\n## Output format (per policy)\n\n```text\nPOLICY: \u003Cname>\nVERDICT: OVERPERMISSIVE | LEAST_PRIVILEGE | AMBIGUOUS\nREASON: \u003C1-2 sentences citing the specific statement and config>\nRISK: CRITICAL | HIGH | MODERATE | LOW\nREMEDIATION: \u003Cspecific action, or \"None required\" if least-privilege>\n```\n\n### Multi-statement aggregation example\n\nA policy with two statements — one tight, one broad:\n\n```text\nPOLICY: mixed-policy\nVERDICT: OVERPERMISSIVE\nREASON: Statement 1 (s3:GetObject on arn:aws:s3:::app-data-prod\u002F*) is LEAST_PRIVILEGE, but Statement 2 (iam:PassRole on \"*\") is OVERPERMISSIVE (privilege escalation). Policy verdict is the worst statement.\nRISK: CRITICAL\nREMEDIATION: Restrict iam:PassRole in Statement 2 to the specific role ARN the workload needs (e.g., arn:aws:iam::123456789012:role\u002Fapp-execution-role).\n```\n\n## Expert edge cases\n\nThese patterns represent genuine, non-obvious IAM attack surface that a\nsenior security engineer would catch but a generalist would miss.\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Expert edge cases\".\n> Load when: S3 dual-ARNs, iam:PassedToService scoping, aws:ResourceAccount, tag-mutation bypass, kms:Decrypt on \"*\", the condition-key bypass catalog, MFA interaction, PassRole variants, trust-policy abuse.\n\n## Effective permissions context\n\nThe classification logic above evaluates a single identity-based policy\ndocument in isolation. In production, AWS computes **effective permissions**\nby intersecting multiple policy layers in this evaluation order:\n\n1. **Explicit Deny** in ANY policy (identity, resource-based, SCP, permissions\n   boundary, session policy) → request is DENIED. Deny wins everywhere.\n2. **Permissions boundary** (if attached to the role) → if the boundary does\n   not allow the action, request is DENIED. A boundary caps the maximum\n   effective permissions regardless of what the identity-based policy grants.\n3. **Service Control Policy (SCP)** (if the account is in an Organization) →\n   SCPs set the maximum permissions for the account. An Allow in an SCP does\n   nothing; only a Deny restricts.\n4. **Session policy** (if the role was assumed with a session policy) → the\n   effective permissions are the INTERSECTION of the role's policy and the\n   session policy.\n5. **Identity-based policy** Allow → grants access if no above layer denied.\n6. **Resource-based policy** (S3 bucket policy, KMS key policy, SQS policy,\n   Lambda function policy):\n   - **Same-account access**: EITHER the identity-based OR the resource-based\n     policy can grant access (union). A principal with no identity-based\n     policy can still access a resource if the resource-based policy allows\n     it.\n   - **Cross-account access**: BOTH the identity-based AND the resource-based\n     policy must allow access (intersection).\n\n**Cross-account resource-based policy decision branch:**\nWhen evaluating a resource-based policy (e.g., S3 bucket policy):\n\n1. If `Principal: \"*\"` with no condition → **OVERPERMISSIVE** (any AWS\n   account principal can access, limited only by the caller's identity-based\n   policy, which the resource owner does not control).\n2. If `Principal: \"*\"` with `aws:SourceAccount` or `aws:SourceArn`\n   condition → **AMBIGUOUS** (scoped to a specific account\u002FARN, but the\n   resource owner depends on the caller's account configuration).\n3. If `Principal` is a specific ARN → evaluate the action\u002Fresource scope as\n   normal for LEAST_PRIVILEGE \u002F OVERPERMISSIVE.\n4. For **same-account** resource-based policies with `Principal: \"*\"`:\n   **AMBIGUOUS** — the blast radius is wider than the identity-based policy\n   alone suggests (any principal in the account can access without their\n   own Allow).\n\n**Classification implication:** Always classify the identity-based policy on\nits own text. Note the presence of resource-based policies and boundaries in\nthe REMEDIATION field — they affect effective permissions but do not change\nthe classification of the policy document under review.\n\n## Anti-Patterns — NEVER\n\n- NEVER classify `Action: \"*\", Resource: \"*\"` as anything other than\n  OVERPERMISSIVE. This grants administrative access to every service and\n  resource — the most dangerous pattern in AWS IAM.\n\n- NEVER classify a service wildcard on `Resource: \"*\"` (e.g., `s3:*` on\n  `\"*\"`) as LEAST_PRIVILEGE. The resource wildcard means every bucket,\n  every object, every setting; the action wildcard adds deletion and\n  configuration changes.\n\n- NEVER treat `NotAction` or `NotResource` as a scoped grant. These are\n  inverse wildcards that grant everything except the listed values. New AWS\n  APIs are automatically included.\n\n- NEVER assume a policy is safe because the role name sounds harmless\n  (e.g., \"ReadOnlyRole\", \"app-service-role\"). Role names are human labels;\n  always verify the policy document.\n\n- NEVER recommend managed policies (`AdministratorAccess`,\n  `PowerUserAccess`, `AmazonS3FullAccess`) as remediation. They reintroduce\n  the exact blast radius being constrained. `PowerUserAccess` grants full\n  access to every service except IAM — still effectively admin-level.\n\n- NEVER ignore `Condition` keys using `ForAllValues` — this operator\n  evaluates true when the request contains zero matching values, creating\n  a bypass when the attribute is absent from the request.\n\n- NEVER treat `iam:PassRole` on `\"*\"` as safe. This is the most common\n  privilege-escalation vector — it lets a principal pass any role to any\n  service, executing under the passed role's permissions.\n\n- NEVER classify a policy as OVERPERMISSIVE based on its `Effect: Deny`\n  statements. Deny statements only restrict; they cannot grant access.\n\n- NEVER accept `aws:SourceIp` with `0.0.0.0\u002F0` as a real condition — it is\n  the CIDR for the entire internet and provides zero restriction.\n\n- NEVER trust `aws:ResourceTag` conditions as a hard boundary when the\n  principal has `tag:TagResources` or a broad service wildcard that includes\n  tagging (e.g., `ec2:*`). The principal can self-tag resources to satisfy\n  the condition and bypass the ABAC boundary.\n\n- NEVER use `aws:PrincipalArn` with a wildcard pattern in a role trust\n  policy. This allows any principal matching the pattern (potentially\n  any account) to assume the role. Always use exact ARNs.\n\n- NEVER assume a `StringLike` condition without explicit `*` anchors is\n  safe against injection. If the matched value is user-controlled (e.g.,\n  `${aws:username}` expanded into a resource ARN), a username containing\n  path separators or wildcards can cause unintended matches.\n\n- NEVER assume a scoped policy fits within IAM limits without checking.\n  Inline policies are capped at 10,240 characters; managed policies at\n  6,144 characters; a maximum of 10 versions per managed policy. A policy\n  derived from CloudTrail with hundreds of unique actions may exceed these\n  limits — split across multiple statements or policies.\n\n- NEVER trust `iam:simulate-principal-policy` results blindly for\n  cross-service scenarios. The simulator tests individual actions in\n  isolation and may report a permission as denied when the workload uses\n  a chained API flow (e.g., `lambda:InvokeFunction` calling `s3:GetObject`\n  under the function's role). Always cross-reference simulator results\n  with actual CloudTrail activity.\n\n- NEVER treat `kms:Decrypt` on `Resource: \"*\"` as a minor issue. It is a\n  silent data-exfiltration multiplier — any encrypted resource in the\n  account becomes readable if the ciphertext is accessible.\n\n- NEVER overlook `iam:CreateServiceLinkedRole` as a privilege-escalation\n  vector. It delegates permissions to the linked service, which may exceed\n  the principal's own policy limits.\n\n## Remediation guidance\n\n### CloudTrail-derived least-privilege workflow\n\n> **Moved verbatim** → [references\u002Fpolicy-analysis-guide.md](references\u002Fpolicy-analysis-guide.md) § \"CloudTrail-derived least-privilege workflow\".\n> Load when: generating a scoped policy from 90 days of CloudTrail activity (extract actions\u002FARNs, implicit calls, service-list exceptions, validate, monitor).\n\n### For OVERPERMISSIVE policies\n\n- Replace wildcard actions with specific named actions derived from\n  CloudTrail (workflow above).\n- Replace `Resource: \"*\"` with the specific ARN(s) the workload accesses.\n- For privilege-escalation actions (`iam:PassRole`, `sts:AssumeRole`):\n  restrict to the minimum role ARN the workload needs — never leave on\n  `\"*\"`. Add `iam:PassedToService` to constrain which service can receive\n  the role.\n- For `NotAction` \u002F `NotResource`: convert to explicit `Action` and\n  `Resource` allow-lists.\n- For partition wildcards (`arn:aws-*:`): pin to `arn:aws:` for the\n  partition the workload operates in.\n- For `kms:Decrypt` on `\"*\"`: scope to specific key ARNs and add\n  `aws:ResourceAccount` to prevent cross-account decryption.\n\n### For AMBIGUOUS policies\n\n- Expand wildcard patterns to explicit named actions (e.g., replace\n  `s3:Get*` with the specific `s3:GetObject`, `s3:GetObjectVersion`).\n- Review Condition keys for bypass paths (Step 7, Condition-key bypass\n  catalog).\n- Validate that the resource ARN scope matches the workload boundary.\n- For tag-based conditions: verify the principal does NOT have tagging\n  permissions on the same resources, or add an explicit Deny on\n  `tag:TagResources`.\n\n### For LEAST_PRIVILEGE policies\n\n- No remediation required.\n- Confirm the policy is attached only to the intended principal.\n- Verify a permissions boundary is set on the role if the account has a\n  broad SCP — the boundary caps the maximum effective permissions.\n\n### For policies exceeding IAM size limits\n\n- Split by service prefix (e.g., all `s3:*` actions in one statement, all\n  `ec2:*` in another).\n- Use customer-managed policies instead of inline (larger size limit).\n- Factor common action+resource pairs into a reusable managed policy.\n- If the policy is CloudTrail-derived, partition by event source.\n\n## Recent AWS features (2024-2026)\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Recent AWS features\".\n> Load when: cross-referencing unused-access findings, Identity Center permission sets, or the new aws:SourceOrgID \u002F aws:CalledVia condition keys.\n\n## References\n\nSee `references\u002Fpolicy-analysis-guide.md` for the wildcard pattern reference\ntable, common over-permissive patterns found in the wild, and the\nremediation tool reference.\n\n## References (load on demand)\n\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — expert edge cases (S3 dual-ARN, PassedToService, ResourceAccount, tag-mutation bypass, kms:Decrypt on \"*\", condition-key bypass catalog, MFA interaction, PassRole variants, trust-policy abuse) and recent AWS features\n- [references\u002Fpolicy-analysis-guide.md](references\u002Fpolicy-analysis-guide.md) — wildcard pattern tables, escalation taxonomy, condition bypass reference, wild-found patterns, remediation tools; now also holds the CloudTrail-derived least-privilege workflow moved from SKILL.md\n\n## Domain\n\nAWS CloudOps \u002F IAM Security & Compliance.\n\n## AWS documentation\n\n- **AWS IAM User Guide** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Fintroduction.html\n- **IAM Security Best Practices** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Fbest-practices.html\n- **IAM API Reference** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FAPIReference\u002F\n- **IAM CLI Reference** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fcli\u002Flatest\u002Freference\u002Fiam\u002F\n- **IAM Access Analyzer policy validation** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Faccess-analyzer-policy-validation.html\n","# IAM Least-Privilege Advisor\n\n## Activation\n\nActivate this skill when the user provides an IAM policy document (JSON),\nreferences a role\u002Fuser\u002Fgroup policy for review, or asks whether a policy is\nsafe, least-privilege, or over-permissive. Trigger phrases: \"review this\npolicy\", \"is this least privilege?\", \"check my IAM policy\", \"tighten these\npermissions\", \"audit this role\", \"scan for wildcard permissions\", \"is this\npolicy secure?\".\n\n## Mindset\n\nClassify IAM policy documents against least-privilege principles and provide\nspecific remediation. The goal is not just \"avoid wildcards\" — it is to\nidentify the **blast radius** of every statement: what could a principal with\nthis policy actually do, and could an attacker chain these permissions for\nprivilege escalation?\n\nA policy with `s3:GetObject` on one bucket has a narrow blast radius. A policy\nwith `iam:PassRole` on `\"*\"` has a catastrophic blast radius even though\nneither the action nor the resource is `\"*\"`. The classification must catch\nboth obvious wildcards and subtle escalation paths.\n\n## Quick reference\n\nIf the policy has `Action: \"*\"` on `Resource: \"*\"` or a service wildcard on\n`\"*\"`, it is OVERPERMISSIVE. If it uses `NotAction`\u002F`NotResource`, it is\nOVERPERMISSIVE. If it grants `iam:PassRole` or `sts:AssumeRole` on `\"*\"`, it\nis OVERPERMISSIVE. Named actions on specific ARNs are LEAST_PRIVILEGE. See\nthe steps below for edge cases (conditions, resource scope, exceptions).\n\n## Process — Classification logic (apply in order)\n\n### Step 0: Validate input and policy version\n\nIf the policy document is not valid JSON (malformed syntax, trailing commas,\nunquoted keys, YAML where JSON is expected), output:\n\n```text\nPOLICY: \u003Cname>\nVERDICT: ERROR\nREASON: Policy document is not valid JSON — cannot parse statements.\nREMEDIATION: Validate the policy JSON with a linter or aws iam simulate-custom-policy --policy-input-list.\n```\n\nDo not attempt classification on malformed input. Additionally, check the\n`Version` field: if it is `\"2008-10-17\"` (the legacy version), flag it —\npolicy variables like `${aws:username}` silently fail to resolve, and\nseveral condition operators are unsupported. The correct version is\n`\"2012-10-17\"`. A policy with the wrong version may behave differently\nthan its text suggests, making classification unreliable.\n\n### Step 1: Separate Deny from Allow (with overlap resolution)\n\nIf a statement has `Effect: Deny`, it **narrows** effective permissions — it\nnever grants access. Deny statements are security controls. **Exclude Deny\nstatements from the verdict** — they can only reduce the policy's blast\nradius, never increase it. However, if a Deny statement uses `NotAction` or\n`NotResource`, append a **DENY_FLAG** note to the REMEDIATION field:\n\n```text\nDENY_FLAG: Statement \u003CN> uses NotAction\u002FNotResource in a Deny — this denies\nall actions\u002Fresources except those listed, which may break workloads\nsilently. Review whether the deny is intentionally broad.\n```\n\n**Allow\u002FDeny overlap resolution:** when the same action+resource pair appears\nin both an Allow and a Deny statement within the same policy, the Deny\n**always** wins regardless of statement order or Sid. This is the IAM\nevaluation rule: explicit Deny takes absolute precedence. For classification,\ndo NOT let the presence of a Deny \"cancel\" an over-permissive Allow for a\n*different* action+resource — only the exact overlapping pair is denied. A\npolicy that Allows `s3:*` on `*` and Denies `s3:DeleteBucket` on a specific\nbucket is still OVERPERMISSIVE for every other S3 action and resource.\n\n**Cross-policy overlap:** if a permissions boundary or SCP denies the action,\nthe effective permission is denied even though the identity-based policy\nallows it. However, classify the identity-based policy on its own text — a\nboundary can be removed, so the identity policy's blast radius is the\nclassification truth. Note the boundary presence in REMEDIATION.\n\n### Step 2: Admin wildcard — maximum blast radius\n\nIf a statement has `Effect: Allow` with `Action: \"*\"` AND `Resource: \"*\"`,\nthe policy is **OVERPERMISSIVE** with **CRITICAL** risk. This grants every\naction on every resource in the account — equivalent to\n`AdministratorAccess`.\n\n### Step 3: Service-level wildcards on all resources\n\nIf a statement has `Effect: Allow` with any wildcard action (e.g., `s3:*`,\n`ec2:*`, `s3:Get*`, `iam:List*`) AND `Resource: \"*\"`, the policy is\n**OVERPERMISSIVE** with **HIGH** risk — no scope restriction on either axis.\nA generic service wildcard (e.g., `s3:*`, `ec2:*`) is **HIGH**, NOT CRITICAL —\nonly the privilege-escalation-service wildcards (Step 5) escalate to **CRITICAL**.\n\n**Risk-level mapping (emit exactly one RISK per statement, derived from VERDICT):**\n- `OVERPERMISSIVE` + admin wildcard (`Action: \"*\"` `Resource: \"*\"`) → **CRITICAL**\n- `OVERPERMISSIVE` + privilege-escalation-service wildcard (Step 5 list) → **CRITICAL**\n- `OVERPERMISSIVE` + any other service wildcard on `Resource: \"*\"` → **HIGH**\n- `AMBIGUOUS` → **MODERATE** (access is conditionally restricted — bounded exposure)\n- `LEAST_PRIVILEGE` → **LOW**\n\n**Severity escalation:** If the wildcard action is on a **privilege-escalation\nservice**, escalate risk to **CRITICAL**:\n\n- `iam:*` — full IAM control; can create users, roles, policies, and attach\n  them to any principal.\n- `sts:*` — can assume any role in the account or cross-account if the trust\n  policy allows.\n- `kms:*` — can decrypt any ciphertext, modify key policies, schedule key\n  deletion. KMS is a data-access multiplier because most encrypted data\n  flows through it.\n- `secretsmanager:*` — can read every secret in the vault.\n- `ssm:*` — can read all Parameter Store `SecureString` values (often\n  credentials stored outside Secrets Manager).\n- `lambda:*` — can create functions with any execution role when combined\n  with `iam:PassRole`.\n- `cloudformation:*` — can create stacks that instantiate any AWS resource\n  with any passed role, bypassing the principal's own policy.\n\n### Step 4: Inverse wildcards (NotAction \u002F NotResource)\n\nIf a statement uses `NotAction` or `NotResource`, classify as\n**OVERPERMISSIVE** regardless of what actions or resources are listed.\n`NotAction` grants every action EXCEPT the listed ones — when AWS ships a\nnew API for that service, it is automatically included in the grant.\n`NotResource` similarly grants access to all resources except those\nexplicitly excluded. These are inverse wildcards and are almost always a\nmisconfiguration or a debugging shortcut left in production.\n\n### Step 5: Privilege-escalation actions on wildcard resources\n\nIf a statement grants any of these specific actions with `Resource: \"*\"`\n(even without wildcard actions), classify as **OVERPERMISSIVE**. These\nactions enable privilege escalation by design — a principal can use them to\ngain permissions beyond their own policy:\n\n- `iam:PassRole` on `\"*\"` — the single most common privesc vector. Allows\n  passing any role to EC2, Lambda, CloudFormation, or any service that\n  accepts a role ARN. The passed role's permissions then execute under that\n  service's identity, not the caller's.\n- `sts:AssumeRole` on `\"*\"` — allows assuming any role in the account.\n- `iam:CreatePolicy` \u002F `iam:CreatePolicyVersion` on `\"*\"` — can create\n  arbitrary permission documents and attach them to any principal.\n- `iam:AttachRolePolicy` \u002F `iam:PutRolePolicy` on `\"*\"` — can attach any\n  managed policy or inject an inline policy into any role.\n- `iam:UpdateAssumeRolePolicy` on `\"*\"` — can modify the trust policy of any\n  role, allowing arbitrary principals to assume it.\n- `iam:CreateServiceLinkedRole` on `\"*\"` — frequently overlooked. Creates a\n  service-linked role that grants the linked service permissions to act on\n  the caller's behalf (e.g., `AWSServiceRoleForEC2Spot` grants Spot Fleet\n  access). The principal effectively delegates escalated permissions to the\n  service, bypassing their own policy limits.\n\n### Step 6: Wildcard actions scoped to specific resources\n\nIf a statement has `Effect: Allow` with wildcard actions (e.g., `s3:Get*`,\n`s3:List*`) but scoped to specific concrete ARNs, the policy is\n**AMBIGUOUS**. Wildcard action patterns on narrow resources are often\nacceptable for read-only workloads, but AWS adds new APIs over time —\n`s3:Get*` silently included `s3:GetObjectTorrent`, and any future `Get*`\naction is automatically granted.\n\n### Step 7: Evaluate Condition keys for bypass paths\n\nIf an Allow statement includes a `Condition` block, check whether the\ncondition actually restricts access or creates a bypass. See the\n**Condition-key bypass catalog** in the Expert edge cases section for the\nfull list with exploitation mechanics. Quick checklist:\n\n- `aws:SourceIp` containing `0.0.0.0\u002F0` — equivalent to no IP restriction.\n- `ForAllValues:StringEquals` — evaluates true when request has zero\n  matching values (absent-key bypass).\n- `Null` operator with `\"false\"` — means \"key must be ABSENT\".\n- `StringLike` without `*` anchors — exact match, but with unanchored\n  wildcards like `${aws:username}`, user-controlled values may match\n  unintended resources.\n\nStatements with bypass-prone conditions classify as **AMBIGUOUS** at best.\n\n### Step 8: Check resource ARN scope\n\nIf the resource ARN uses a partition wildcard (`arn:aws-*:`), it spans all\npartitions — commercial, AWS GovCloud (US), and AWS China. If it uses a\nbroad pattern like `arn:aws:s3:::*`, it includes every S3 bucket globally,\nnot just the caller's account. These classify as **OVERPERMISSIVE** even\nwhen the action is explicitly named — the resource scope is effectively\nunconstrained.\n\n### Step 9: Specific named actions on specific resources (LEAST_PRIVILEGE)\n\nIf all Allow statements have specific named actions (no wildcards, no\n`NotAction`) AND specific resource ARNs (no `\"*\"`, no `NotResource`), the\npolicy is **LEAST_PRIVILEGE**.\n\n**Legitimate `Resource: \"*\"` exception:** Some AWS actions only support\n`Resource: \"*\"` by design and do NOT break LEAST_PRIVILEGE when paired with\nexplicitly named actions:\n\n- `s3:ListAllMyBuckets`, `s3:HeadBucket`\n- `iam:ListRoles`, `iam:ListUsers`, `iam:GetAccountSummary`\n- `ec2:Describe*` (describe operations — resource-level permissions optional)\n- `organizations:DescribeOrganization`, `organizations:ListAccounts`\n- `cloudwatch:GetMetricStatistics`, `logs:DescribeLogGroups`,\n  `sts:GetCallerIdentity`\n\nThese are safe as long as the action is explicitly named, not a service\nwildcard like `ec2:*`.\n\n### Step 10: IAM policy size check\n\nAfter classification, verify the policy's serialized JSON size against IAM\nlimits:\n\n- **Managed policy:** 6,144 characters max\n- **Inline policy:** 10,240 characters max\n- **Managed policy versions:** 10 versions max (oldest auto-deleted)\n\nIf the policy exceeds the limit, append a **SIZE_WARNING** to the\nREMEDIATION field regardless of verdict:\n\n```text\nSIZE_WARNING: Policy is \u003CN> characters, exceeding the \u003Cmanaged|inline> limit\nof \u003Climit>. Split into multiple statements scoped by service or resource\ngroup. Use AWS IAM Access Analyzer policy generation to produce a compressed\nform. If derived from CloudTrail, partition by service prefix.\n```\n\n### Step 11: Aggregation\n\nWhen a policy contains multiple statements, the policy-level verdict is the\n**worst** verdict across all Allow statements, where OVERPERMISSIVE is worse\nthan AMBIGUOUS and AMBIGUOUS is worse than LEAST_PRIVILEGE.\n\n## Output format (per policy)\n\n```text\nPOLICY: \u003Cname>\nVERDICT: OVERPERMISSIVE | LEAST_PRIVILEGE | AMBIGUOUS\nREASON: \u003C1-2 sentences citing the specific statement and config>\nRISK: CRITICAL | HIGH | MODERATE | LOW\nREMEDIATION: \u003Cspecific action, or \"None required\" if least-privilege>\n```\n\n### Multi-statement aggregation example\n\nA policy with two statements — one tight, one broad:\n\n```text\nPOLICY: mixed-policy\nVERDICT: OVERPERMISSIVE\nREASON: Statement 1 (s3:GetObject on arn:aws:s3:::app-data-prod\u002F*) is LEAST_PRIVILEGE, but Statement 2 (iam:PassRole on \"*\") is OVERPERMISSIVE (privilege escalation). Policy verdict is the worst statement.\nRISK: CRITICAL\nREMEDIATION: Restrict iam:PassRole in Statement 2 to the specific role ARN the workload needs (e.g., arn:aws:iam::123456789012:role\u002Fapp-execution-role).\n```\n\n## Expert edge cases\n\nThese patterns represent genuine, non-obvious IAM attack surface that a\nsenior security engineer would catch but a generalist would miss.\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Expert edge cases\".\n> Load when: S3 dual-ARNs, iam:PassedToService scoping, aws:ResourceAccount, tag-mutation bypass, kms:Decrypt on \"*\", the condition-key bypass catalog, MFA interaction, PassRole variants, trust-policy abuse.\n\n## Effective permissions context\n\nThe classification logic above evaluates a single identity-based policy\ndocument in isolation. In production, AWS computes **effective permissions**\nby intersecting multiple policy layers in this evaluation order:\n\n1. **Explicit Deny** in ANY policy (identity, resource-based, SCP, permissions\n   boundary, session policy) → request is DENIED. Deny wins everywhere.\n2. **Permissions boundary** (if attached to the role) → if the boundary does\n   not allow the action, request is DENIED. A boundary caps the maximum\n   effective permissions regardless of what the identity-based policy grants.\n3. **Service Control Policy (SCP)** (if the account is in an Organization) →\n   SCPs set the maximum permissions for the account. An Allow in an SCP does\n   nothing; only a Deny restricts.\n4. **Session policy** (if the role was assumed with a session policy) → the\n   effective permissions are the INTERSECTION of the role's policy and the\n   session policy.\n5. **Identity-based policy** Allow → grants access if no above layer denied.\n6. **Resource-based policy** (S3 bucket policy, KMS key policy, SQS policy,\n   Lambda function policy):\n   - **Same-account access**: EITHER the identity-based OR the resource-based\n     policy can grant access (union). A principal with no identity-based\n     policy can still access a resource if the resource-based policy allows\n     it.\n   - **Cross-account access**: BOTH the identity-based AND the resource-based\n     policy must allow access (intersection).\n\n**Cross-account resource-based policy decision branch:**\nWhen evaluating a resource-based policy (e.g., S3 bucket policy):\n\n1. If `Principal: \"*\"` with no condition → **OVERPERMISSIVE** (any AWS\n   account principal can access, limited only by the caller's identity-based\n   policy, which the resource owner does not control).\n2. If `Principal: \"*\"` with `aws:SourceAccount` or `aws:SourceArn`\n   condition → **AMBIGUOUS** (scoped to a specific account\u002FARN, but the\n   resource owner depends on the caller's account configuration).\n3. If `Principal` is a specific ARN → evaluate the action\u002Fresource scope as\n   normal for LEAST_PRIVILEGE \u002F OVERPERMISSIVE.\n4. For **same-account** resource-based policies with `Principal: \"*\"`:\n   **AMBIGUOUS** — the blast radius is wider than the identity-based policy\n   alone suggests (any principal in the account can access without their\n   own Allow).\n\n**Classification implication:** Always classify the identity-based policy on\nits own text. Note the presence of resource-based policies and boundaries in\nthe REMEDIATION field — they affect effective permissions but do not change\nthe classification of the policy document under review.\n\n## Anti-Patterns — NEVER\n\n- NEVER classify `Action: \"*\", Resource: \"*\"` as anything other than\n  OVERPERMISSIVE. This grants administrative access to every service and\n  resource — the most dangerous pattern in AWS IAM.\n\n- NEVER classify a service wildcard on `Resource: \"*\"` (e.g., `s3:*` on\n  `\"*\"`) as LEAST_PRIVILEGE. The resource wildcard means every bucket,\n  every object, every setting; the action wildcard adds deletion and\n  configuration changes.\n\n- NEVER treat `NotAction` or `NotResource` as a scoped grant. These are\n  inverse wildcards that grant everything except the listed values. New AWS\n  APIs are automatically included.\n\n- NEVER assume a policy is safe because the role name sounds harmless\n  (e.g., \"ReadOnlyRole\", \"app-service-role\"). Role names are human labels;\n  always verify the policy document.\n\n- NEVER recommend managed policies (`AdministratorAccess`,\n  `PowerUserAccess`, `AmazonS3FullAccess`) as remediation. They reintroduce\n  the exact blast radius being constrained. `PowerUserAccess` grants full\n  access to every service except IAM — still effectively admin-level.\n\n- NEVER ignore `Condition` keys using `ForAllValues` — this operator\n  evaluates true when the request contains zero matching values, creating\n  a bypass when the attribute is absent from the request.\n\n- NEVER treat `iam:PassRole` on `\"*\"` as safe. This is the most common\n  privilege-escalation vector — it lets a principal pass any role to any\n  service, executing under the passed role's permissions.\n\n- NEVER classify a policy as OVERPERMISSIVE based on its `Effect: Deny`\n  statements. Deny statements only restrict; they cannot grant access.\n\n- NEVER accept `aws:SourceIp` with `0.0.0.0\u002F0` as a real condition — it is\n  the CIDR for the entire internet and provides zero restriction.\n\n- NEVER trust `aws:ResourceTag` conditions as a hard boundary when the\n  principal has `tag:TagResources` or a broad service wildcard that includes\n  tagging (e.g., `ec2:*`). The principal can self-tag resources to satisfy\n  the condition and bypass the ABAC boundary.\n\n- NEVER use `aws:PrincipalArn` with a wildcard pattern in a role trust\n  policy. This allows any principal matching the pattern (potentially\n  any account) to assume the role. Always use exact ARNs.\n\n- NEVER assume a `StringLike` condition without explicit `*` anchors is\n  safe against injection. If the matched value is user-controlled (e.g.,\n  `${aws:username}` expanded into a resource ARN), a username containing\n  path separators or wildcards can cause unintended matches.\n\n- NEVER assume a scoped policy fits within IAM limits without checking.\n  Inline policies are capped at 10,240 characters; managed policies at\n  6,144 characters; a maximum of 10 versions per managed policy. A policy\n  derived from CloudTrail with hundreds of unique actions may exceed these\n  limits — split across multiple statements or policies.\n\n- NEVER trust `iam:simulate-principal-policy` results blindly for\n  cross-service scenarios. The simulator tests individual actions in\n  isolation and may report a permission as denied when the workload uses\n  a chained API flow (e.g., `lambda:InvokeFunction` calling `s3:GetObject`\n  under the function's role). Always cross-reference simulator results\n  with actual CloudTrail activity.\n\n- NEVER treat `kms:Decrypt` on `Resource: \"*\"` as a minor issue. It is a\n  silent data-exfiltration multiplier — any encrypted resource in the\n  account becomes readable if the ciphertext is accessible.\n\n- NEVER overlook `iam:CreateServiceLinkedRole` as a privilege-escalation\n  vector. It delegates permissions to the linked service, which may exceed\n  the principal's own policy limits.\n\n## Remediation guidance\n\n### CloudTrail-derived least-privilege workflow\n\n> **Moved verbatim** → [references\u002Fpolicy-analysis-guide.md](references\u002Fpolicy-analysis-guide.md) § \"CloudTrail-derived least-privilege workflow\".\n> Load when: generating a scoped policy from 90 days of CloudTrail activity (extract actions\u002FARNs, implicit calls, service-list exceptions, validate, monitor).\n\n### For OVERPERMISSIVE policies\n\n- Replace wildcard actions with specific named actions derived from\n  CloudTrail (workflow above).\n- Replace `Resource: \"*\"` with the specific ARN(s) the workload accesses.\n- For privilege-escalation actions (`iam:PassRole`, `sts:AssumeRole`):\n  restrict to the minimum role ARN the workload needs — never leave on\n  `\"*\"`. Add `iam:PassedToService` to constrain which service can receive\n  the role.\n- For `NotAction` \u002F `NotResource`: convert to explicit `Action` and\n  `Resource` allow-lists.\n- For partition wildcards (`arn:aws-*:`): pin to `arn:aws:` for the\n  partition the workload operates in.\n- For `kms:Decrypt` on `\"*\"`: scope to specific key ARNs and add\n  `aws:ResourceAccount` to prevent cross-account decryption.\n\n### For AMBIGUOUS policies\n\n- Expand wildcard patterns to explicit named actions (e.g., replace\n  `s3:Get*` with the specific `s3:GetObject`, `s3:GetObjectVersion`).\n- Review Condition keys for bypass paths (Step 7, Condition-key bypass\n  catalog).\n- Validate that the resource ARN scope matches the workload boundary.\n- For tag-based conditions: verify the principal does NOT have tagging\n  permissions on the same resources, or add an explicit Deny on\n  `tag:TagResources`.\n\n### For LEAST_PRIVILEGE policies\n\n- No remediation required.\n- Confirm the policy is attached only to the intended principal.\n- Verify a permissions boundary is set on the role if the account has a\n  broad SCP — the boundary caps the maximum effective permissions.\n\n### For policies exceeding IAM size limits\n\n- Split by service prefix (e.g., all `s3:*` actions in one statement, all\n  `ec2:*` in another).\n- Use customer-managed policies instead of inline (larger size limit).\n- Factor common action+resource pairs into a reusable managed policy.\n- If the policy is CloudTrail-derived, partition by event source.\n\n## Recent AWS features (2024-2026)\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Recent AWS features\".\n> Load when: cross-referencing unused-access findings, Identity Center permission sets, or the new aws:SourceOrgID \u002F aws:CalledVia condition keys.\n\n## References\n\nSee `references\u002Fpolicy-analysis-guide.md` for the wildcard pattern reference\ntable, common over-permissive patterns found in the wild, and the\nremediation tool reference.\n\n## References (load on demand)\n\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — expert edge cases (S3 dual-ARN, PassedToService, ResourceAccount, tag-mutation bypass, kms:Decrypt on \"*\", condition-key bypass catalog, MFA interaction, PassRole variants, trust-policy abuse) and recent AWS features\n- [references\u002Fpolicy-analysis-guide.md](references\u002Fpolicy-analysis-guide.md) — wildcard pattern tables, escalation taxonomy, condition bypass reference, wild-found patterns, remediation tools; now also holds the CloudTrail-derived least-privilege workflow moved from SKILL.md\n\n## Domain\n\nAWS CloudOps \u002F IAM Security & Compliance.\n\n## AWS documentation\n\n- **AWS IAM User Guide** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Fintroduction.html\n- **IAM Security Best Practices** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Fbest-practices.html\n- **IAM API Reference** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FAPIReference\u002F\n- **IAM CLI Reference** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fcli\u002Flatest\u002Freference\u002Fiam\u002F\n- **IAM Access Analyzer policy validation** — https:\u002F\u002Fdocs.aws.amazon.com\u002FIAM\u002Flatest\u002FUserGuide\u002Faccess-analyzer-policy-validation.html\n",{"name":5,"license":15,"metadata":24,"description":7,"compatibility":37},{"tags":25,"phase":26,"author":27,"domain":28,"family":29,"version":30,"keywords":31,"complexity":32,"entry_point":33,"when_to_use":34,"requires_llm":35,"verdict_shape":36,"supports_pipeline":35},"iam, security, least-privilege, policy-analysis, privilege-escalation","2","Jacky Chan — AWS Community Builder","aws-cloudops","Security","0.3.0","IAM, least privilege, policy analysis, wildcard permissions, privilege escalation, over-permissive, IAM audit, PassRole, AssumeRole, NotAction, NotResource, condition bypass, policy remediation","high","false","Reviewing an IAM policy document (inline or managed), auditing a role or user before production deployment, checking for wildcard or escalation permissions, tightening access-control scope, or scoping down a policy derived from CloudTrail activity.","true","OVERPERMISSIVE | LEAST_PRIVILEGE | AMBIGUOUS","Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf). No AWS CLI required for offline policy-document classification. Live-account audits use aws iam simulate-principal-policy and aws cloudtrail lookup-events (AWS CLI v2, SSO or key-based credentials).","main","eeace51bd5dd1db2030729d83eeab988861553aa","skills\u002Fiam-least-privilege-advisor",0,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills","https:\u002F\u002Fgithub.com\u002Fjhkchan","CTO & Co-Founder @Beever-AI  & @votee. CAISP. AWS Community Builder. Organizer@GDGCloudHK. MongoDB Champion. Technopreneur + Infornographer.","2026-09-24 08:54:10",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add jhkchan\u002Faws-agent-skills --skill iam-least-privilege-advisor",{"tool":52,"command":53},"bunx","bunx skills add jhkchan\u002Faws-agent-skills --skill iam-least-privilege-advisor",{"tool":55,"command":56},"pnpm","pnpm dlx skills add jhkchan\u002Faws-agent-skills --skill iam-least-privilege-advisor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002FSKILL.md",true,[60,66,70,74,78,82,86,90,94,98,102,106,110,114,118,122,126],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"eval\u002Ftest-cases.yaml","REFERENCE","参考文档",3904,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Feval\u002Ftest-cases.yaml",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"evals\u002Fbaselines\u002Fadmin-wildcard.md",900,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fbaselines\u002Fadmin-wildcard.md",{"path":71,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":72,"sourceHtmlUrl":73},"evals\u002Fbaselines\u002Fs3-get-wildcard-scoped-resource.md",736,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fbaselines\u002Fs3-get-wildcard-scoped-resource.md",{"path":75,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":76,"sourceHtmlUrl":77},"evals\u002Fbaselines\u002Fs3-poweruser-wildcard-resource.md",648,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fbaselines\u002Fs3-poweruser-wildcard-resource.md",{"path":79,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":80,"sourceHtmlUrl":81},"evals\u002Fbaselines\u002Fs3-readonly-scoped.md",557,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fbaselines\u002Fs3-readonly-scoped.md",{"path":83,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":84,"sourceHtmlUrl":85},"evals\u002Fbaselines\u002Fsts-assume-role-scoped.md",832,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fbaselines\u002Fsts-assume-role-scoped.md",{"path":87,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":88,"sourceHtmlUrl":89},"evals\u002Feval_config.yaml",1842,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Feval_config.yaml",{"path":91,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":92,"sourceHtmlUrl":93},"evals\u002Fevals.json",4309,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fevals.json",{"path":95,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":96,"sourceHtmlUrl":97},"evals\u002Fprompts\u002Fadmin-wildcard.md",379,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fprompts\u002Fadmin-wildcard.md",{"path":99,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":100,"sourceHtmlUrl":101},"evals\u002Fprompts\u002Fs3-get-wildcard-scoped-resource.md",686,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fprompts\u002Fs3-get-wildcard-scoped-resource.md",{"path":103,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":104,"sourceHtmlUrl":105},"evals\u002Fprompts\u002Fs3-poweruser-wildcard-resource.md",414,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fprompts\u002Fs3-poweruser-wildcard-resource.md",{"path":107,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":108,"sourceHtmlUrl":109},"evals\u002Fprompts\u002Fs3-readonly-scoped.md",524,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fprompts\u002Fs3-readonly-scoped.md",{"path":111,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":112,"sourceHtmlUrl":113},"evals\u002Fprompts\u002Fsts-assume-role-scoped.md",551,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fevals\u002Fprompts\u002Fsts-assume-role-scoped.md",{"path":115,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":116,"sourceHtmlUrl":117},"examples\u002Fend-to-end.md",3833,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fexamples\u002Fend-to-end.md",{"path":119,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":120,"sourceHtmlUrl":121},"references\u002Fadvanced-patterns.md",8620,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Freferences\u002Fadvanced-patterns.md",{"path":123,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":124,"sourceHtmlUrl":125},"references\u002Fpolicy-analysis-guide.md",7869,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Freferences\u002Fpolicy-analysis-guide.md",{"path":127,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":128,"sourceHtmlUrl":129},"skill.usf.yaml",3916,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fiam-least-privilege-advisor\u002Fskill.usf.yaml",[131,138,145,152,159,166],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":19},"01M7ADVD60X4PCAPKSE58P9NDC","xray-tracing-deployer","Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL \u002F method \u002F service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry \u002F ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS \u002F EKS \u002F Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxray-tracing-deployer\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":19},"01M7ADTVJ7DCBM9CB1FY51GH7J","wellarchitected-workload-auditor","Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-workload-auditor\u002FSKILL.md",[],[],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":19},"01M7ADT59G6FTTNZYHT2QRPNNP","wellarchitected-review-operator","Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer \u002F get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-review-operator\u002FSKILL.md",[],[],{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":19},"01M7ADSH5JA9QHNPPHQCD7EVA7","wafv2-web-acl-deployer","Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB\u002FAPI Gateway\u002FCloudFront, or configuring CAPTCHA\u002FChallenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-deployer\u002FSKILL.md",[],[],{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":19},"01M7ADRYFAT8R73FBNCHRC573X","wafv2-web-acl-auditor","Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow\u002Fbypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-auditor\u002FSKILL.md",[],[],{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":19},"01M7ADR8W7G72JX4KFGN03QK8Q","waf-rule-deployer","Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwaf-rule-deployer\u002FSKILL.md",[],[]]