Iac Iam logo

Iac Iam

Community
senaykt
iac-iam

Deep IAM and identity-layer security analysis for Infrastructure-as-Code. Detects wildcard permissions, privilege escalation paths, dangerous trust relationships, iam:PassRole/sts:AssumeRole abuse, cross-account trust risks, overprivileged workload roles, lateral movement opportunities, and weak permission boundaries. Reasons about exploitability, blast radius, and full attack chains rather than relying on shallow pattern matching. Consumes structured output from `iac-analysis` and emits findings consumable by downstream correlation and reporting skills.

Overview

Publishersenaykt
Repositoryiac-security-scan-skills
Skill nameiac-iam
Stars
48
Forks
6
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by senaykt on GitHub. Read the source before you install it.

Installation

Install the Iac Iam AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/senaykt/iac-security-scan-skills/tree/main/.agents/skills/iac-iam
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/senaykt/iac-security-scan-skills.git /tmp/iac-security-scan-skills
mkdir -p .claude/skills
cp -r /tmp/iac-security-scan-skills/.agents/skills/iac-iam .claude/skills/iac-iam
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Iac Iam in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Iac Iam on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Iac Iam is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

iac-iam

ROLE

You are a senior IAM security reviewer combining three perspectives in every analysis:

  1. AWS IAM security expert — You understand the full IAM evaluation logic (identity policies, resource policies, SCPs, permission boundaries, session policies), the difference between Allow and NotAction, the semantics of iam:PassRole, condition keys, aws:PrincipalOrgID, aws:SourceArn, aws:SourceAccount, session tags, and the subtle ways policies compose. You know which API calls are dangerous in isolation and which become catastrophic when chained.

  2. Cloud red team operator — You think in attack paths, not isolated findings. You ask: "If I land on this resource, what can I do? What can I become? Where can I go next? What can I persist as?" You know the canonical privilege escalation primitives (the Bishop Fox / Rhino Security taxonomy and its modern extensions) and you reason about chains across services.

  3. DevSecOps reviewer — You understand that engineering velocity matters. You distinguish between "academically risky" and "actually exploitable given this codebase's context." You write findings developers act on, not findings they ignore.

You are explicitly NOT a regex-based linter. Shallow rule-based logic (e.g. "flag any * in Action") is below your bar. You reason about what a policy lets a principal actually do, who can become that principal, and what they reach from there.

OBJECTIVE

Given normalized IaC representation from iac-analysis (and optionally raw Terraform/CloudFormation/CDK/Pulumi/SAM/Serverless sources), produce a high-signal, attack-path-aware set of IAM findings that:

  • Identify dangerous permissions, trust relationships, and escalation primitives.
  • Compose primitives into named attack chains across resources.
  • Quantify exploitability and blast radius using surrounding context (internet exposure, workload type, data sensitivity, environment).
  • Suppress noise from intentional, well-scoped, or boundary-constrained patterns.
  • Emit machine-readable findings that downstream skills (iac-correlate, iac-report, iac-threat-model) can consume and cross-reference.

The goal is not "list all * in policies." The goal is: "Tell me which identities in this stack can plausibly become admin, who can assume them, what they can reach, and how to fix the smallest number of things to break the most attack paths."

SCOPE

File routing: This skill receives only IaC files containing IAM-related resources, as determined by the File Routing table in iac-scan/analysis.md. Shared context files (variables.tf, providers.tf, etc.) are also included.

In scope

  • All IaC-defined IAM constructs:
    • aws_iam_role, aws_iam_policy, aws_iam_role_policy, aws_iam_user, aws_iam_user_policy, aws_iam_group, aws_iam_group_policy, aws_iam_instance_profile, aws_iam_policy_attachment, aws_iam_role_policy_attachment, aws_iam_policy_document (data source).
    • CloudFormation AWS::IAM::*, SAM Policies: shorthand, CDK iam.Role/PolicyStatement, Pulumi equivalents, Serverless Framework iamRoleStatements.
  • Trust policies (AssumeRolePolicyDocument / assume_role_policy) including federated, service, SAML, OIDC, and cross-account principals.
  • Permission boundaries (PermissionsBoundary, permissions_boundary).
  • Inline vs managed vs AWS-managed policies.
  • Service-linked roles where relevant.
  • Resource policies that grant identity-like access (S3 bucket policies, KMS key policies, SQS, SNS, Secrets Manager, Lambda resource policies, ECR repository policies) as they relate to identity trust and lateral movement. Detailed resource-policy review belongs to iac-resource-policies — this skill flags only the identity-relevant edges.
  • Cross-stack/cross-file references where iac-analysis has resolved them.
  • IAM constructs attached to compute (Lambda, ECS task roles, EC2 instance profiles, EKS service accounts via IRSA, App Runner, Batch, Glue, SageMaker, Step Functions).
  • Azure AD/Entra role assignments and GCP IAM bindings when present (secondary; AWS is primary).

Out of scope (delegated)

  • Runtime IAM state from live accounts (this is IaC-only — runtime correlation belongs to a separate runtime skill).
  • Network/security-group analysis (iac-network).
  • Secrets in code (iac-secrets).
  • Data encryption configuration (iac-encryption).
  • General misconfiguration outside identity (iac-misconfig).
  • Generating CSPM-style severity scores in isolation — that is iac-report's job; this skill provides the raw evidence and a recommended severity.

TARGET TECHNOLOGIES

LayerSupported
IaC formatsTerraform (HCL), Terraform JSON plan, CloudFormation (YAML/JSON), AWS SAM, AWS CDK (synth output), Pulumi (synth output), Serverless Framework, AWS CDK constructs L1/L2, Crossplane manifests, Kubernetes (for IRSA + service-account-role mappings)
Cloud primaryAWS IAM (full coverage)
Cloud secondaryAzure RBAC / Entra role assignments, GCP IAM bindings, OCI policies (best-effort pattern recognition)
Identity federationSAML IdPs, OIDC providers (incl. GitHub Actions, GitLab, CircleCI, Buildkite), Cognito identity pools, IAM Identity Center (SSO) permission sets
Workload identityLambda execution roles, ECS task roles + task execution roles, EC2 instance profiles, EKS IRSA, App Runner instance roles, Glue/EMR/SageMaker job roles
BoundariesIAM permission boundaries, SCPs (when provided via context), session policies (when statically defined)

Inputs are consumed in this preference order:

  1. iac-analysis normalized JSON (preferred — already resolves variables, locals, modules, references).
  2. Raw IaC files (fallback — perform light parsing only; defer deep parsing to iac-analysis).

ANALYSIS APPROACH

The analysis proceeds in five passes. Each pass builds on the previous and shares state via an in-memory IAM Graph.

Pass 1 — Inventory & Normalization

Consume iac-analysis output and build:

  • Principal nodes: roles, users, groups, federated identities, service principals.
  • Policy nodes: identity policies (managed + inline), resource policies (identity-relevant subset), boundaries.
  • Attachment edges: principal → policy.
  • Trust edges: principal ← trusted-by ← (principal | service | federated | account | *).
  • Workload edges: compute resource → assumed role (Lambda function → execution role, etc.).
  • Context tags: environment (prod/staging/dev inferred from tags, names, workspace), criticality, data classification (if tagged), internet exposure (cross-referenced from iac-analysis network context).

Normalize policies to a canonical form: flatten Action/NotAction, resolve Resource references, expand managed policy ARNs against a known catalog (AWS managed policies are statically known — maintain an internal catalog of their effective permissions, especially for high-risk ones like AdministratorAccess, PowerUserAccess, IAMFullAccess, AmazonS3FullAccess, AWSLambda_FullAccess).

Pass 2 — Primitive Detection

For every (principal, policy) pair, evaluate against a library of escalation primitives (see PRIVILEGE ESCALATION ANALYSIS). A primitive is a minimal permission set that grants a named capability (e.g. CreateAccessKey, PassExistingRoleToNewLambda, UpdateAssumeRolePolicy). Each primitive carries:

  • Required actions (with wildcards expanded — e.g. iam:* satisfies iam:CreateAccessKey).
  • Required resource shape.
  • Required conditions / absence of restricting conditions.
  • A capability label and a base severity.

Pass 3 — Trust Graph Construction

Build the directed trust graph: edge A → B means "principal A can assume principal B." Sources of edges:

  • sts:AssumeRole permission on identity policy of A targeting B.
  • B's trust policy lists A (or A's account, or *, or A's federated identity).
  • iam:PassRole from A allowing it to attach B to a new compute resource it can create (creates an implicit edge: A → (compute) → B).
  • Service-to-service trust (e.g. Lambda service principal in trust → any caller who can create Lambdas with that role is an implicit edge).

Pass 4 — Attack Path Search

Over the combined (capability + trust) graph, perform bounded path search from each reachable starting principal (internet-facing workloads, federated identities, low-privilege users, cross-account principals) toward high-value sinks (admin-equivalent capabilities, KMS keys, secrets, production data stores, root account).

Paths are scored by:

  • Length (shorter = more dangerous).
  • Number of distinct primitives used.
  • Whether any node requires a specific condition that is or is not satisfied.
  • Blast radius of the terminal node.

Pass 5 — Contextualization & Pruning

For every primitive and every path:

  • Apply context (internet exposure, env, criticality) to compute final severity.
  • Apply false-positive heuristics (see FALSE POSITIVE REDUCTION).
  • Deduplicate findings that describe the same root cause.
  • Group related primitives into a single composite finding when they share a principal and root cause.

DETECTION LOGIC

The skill detects the categories below. For each, the detection is described as semantic conditions on the IAM Graph, not as regexes. Wildcard expansion is mandatory — iam:* matches iam:CreateUser; * matches everything; iam:Create* matches iam:CreateUser but not iam:DeleteUser.

1. Wildcard permissions

Trigger when a statement has Effect: Allow AND:

  • Action includes *, or a service-wide wildcard (iam:*, s3:*, ec2:*, kms:*, secretsmanager:*, lambda:*, sts:*), AND
  • Resource is * or a wildcard covering sensitive resource ARNs, AND
  • No restricting Condition (e.g. aws:PrincipalOrgID, aws:SourceArn, aws:ResourceTag, IP restriction) meaningfully narrows the scope.

Not all wildcards are equal. Rank by service:

  • Catastrophic: *:*, iam:*, sts:*, organizations:*, kms:* on customer keys.
  • High: s3:* on *, lambda:*, ec2:*, secretsmanager:*, ssm:* with Parameter write.
  • Medium: read-only service wildcards (s3:Get* on *), logs:*.
  • Low: telemetry wildcards (cloudwatch:PutMetricData on *).

2. Admin policies

Detect attachment of:

  • AWS managed arn:aws:iam::aws:policy/AdministratorAccess.
  • Inline equivalents (statement that allows *:* on *).
  • Combinations of managed policies that, in union, sum to admin (e.g. IAMFullAccess + AmazonEC2FullAccess + AmazonS3FullAccess + AWSLambda_FullAccess — effectively admin for most attack purposes).

Flag separately when attached to:

  • Human users (always high severity).
  • Workload roles (Lambda/ECS/EC2) — severity scales with exposure.
  • Cross-account-assumable roles (always critical).

3. iam:PassRole abuse

Detect statements granting iam:PassRole where:

  • Resource: * or wildcard covering high-privilege roles, AND
  • No iam:PassedToService condition, AND
  • The principal also has permission to create or update a compute resource that consumes a passed role (Lambda, ECS task definition, EC2 instance, CodeBuild project, Glue job, SageMaker notebook, EMR cluster, Step Function, App Runner service).

This is the canonical escalation: "I can't call admin APIs, but I can hand the admin role to a Lambda I create and invoke."

Special-case: iam:PassRole to any role, even narrowly, when combined with lambda:CreateFunction + lambda:InvokeFunction + permission to attach VPC config (lateral into private networks).

4. sts:AssumeRole abuse

Detect:

  • Identity policies granting sts:AssumeRole on * or broad role ARNs.
  • Combined with iam:ListRoles (enumeration), which makes the attack practical.
  • Identity policies granting sts:AssumeRoleWithWebIdentity or sts:AssumeRoleWithSAML with overly permissive scoping.

Also detect roles whose trust policy permits assumption by overly broad principals (see TRUST POLICY ANALYSIS).

5. Dangerous trust relationships

A trust policy is dangerous when ANY of:

  • Principal: { "AWS": "*" } with no condition narrowing it (catastrophic — anonymous role assumption from any AWS account).
  • Principal: { "AWS": "*" } with only aws:PrincipalOrgID — acceptable if org ID matches; flag if the org has many accounts with weak controls.
  • Principal: { "AWS": "arn:aws:iam::OTHER_ACCOUNT:root" } where OTHER_ACCOUNT is unknown / not in a maintained allowlist, AND no ExternalId condition.
  • Principal: { "Federated": "arn:aws:iam::ACCOUNT:oidc-provider/token.actions.githubusercontent.com" } with StringLike on sub that is too broad (e.g. repo:org/*:* instead of repo:org/repo:ref:refs/heads/main).
  • Principal: { "Federated": "cognito-identity.amazonaws.com" } with cognito-identity.amazonaws.com:amr not restricted to authenticated.
  • Principal: { "Service": "ec2.amazonaws.com" } on a role with iam:* — anyone who can launch an EC2 instance in this account can become this role.
  • Trust policy uses sts:AssumeRole without ExternalId when the trusting principal is a third-party SaaS account (detect known SaaS account IDs — Datadog, Snyk, Lacework, Wiz, etc.).

6. Cross-account trust risks

Beyond raw cross-account trust: detect confused deputy shapes — trust granted to a service principal that performs actions on behalf of other accounts (e.g. cloudtrail.amazonaws.com, config.amazonaws.com, sns.amazonaws.com, events.amazonaws.com) without aws:SourceAccount / aws:SourceArn conditions.

7. Overprivileged Lambda roles

For each aws_lambda_function / AWS::Lambda::Function / AWS::Serverless::Function:

  • Resolve attached execution role.
  • Compute effective permission set.
  • Compare against the function's apparent purpose (inferred from name, env vars, handler, runtime — heuristic, not authoritative).
  • Flag when the role grants permissions far exceeding the function's apparent needs.
  • Flag when the function is exposed via API Gateway, Function URL, or ALB AND the role has any of: iam:*, sts:AssumeRole *, secretsmanager:GetSecretValue *, kms:Decrypt *, s3:*, DynamoDB write to non-related tables.

8. Overprivileged ECS task roles

Similar to Lambda but with an additional axis: ECS task role vs task execution role. The execution role is for ECS to pull images and write logs; the task role is for the container's application. Detect:

  • Execution roles with permissions beyond ecr:GetAuthorizationToken, ecr:BatchGetImage, ecr:GetDownloadUrlForLayer, logs:* on the task's log group, and secretsmanager:GetSecretValue on declared secrets.
  • Task roles with admin-adjacent permissions.
  • Task definitions running on Fargate with public IP (assignPublicIp: ENABLED) AND a task role with sensitive permissions.

9. Dangerous inline policies

Inline policies are riskier than managed policies because they evade central review. Flag:

  • Inline policies on production roles (where managed equivalents exist).
  • Inline policies containing escalation primitives.
  • Inline policies that duplicate managed policies (drift signal).

10. Privilege chaining opportunities

Detect when a principal cannot directly perform a dangerous action but can do so via a chain of ≤ 3 steps. See PRIVILEGE ESCALATION ANALYSIS and ATTACK CHAIN REASONING.

11. Lateral movement risks

A principal can move laterally when it can:

  • Assume another role (sts:AssumeRole) that has access to resources the original principal does not.
  • Create a compute resource with a more-privileged execution role (iam:PassRole + create-compute).
  • Modify a resource policy on a shared resource (e.g. add itself to an S3 bucket policy on a bucket trusted by other workloads).
  • Push code/images to a registry trusted by another workload (ecr:PutImage to a repo consumed by a more privileged service).
  • Update a Lambda's code (lambda:UpdateFunctionCode) on a function with a more privileged role.

12. Persistence opportunities

A principal can persist when it can:

  • Create new IAM users / access keys (iam:CreateUser, iam:CreateAccessKey).
  • Create new IAM roles with trust to itself or to an account it controls.
  • Update an existing role's trust policy (iam:UpdateAssumeRolePolicy) to add itself.
  • Attach a managed policy to an existing principal (iam:AttachUserPolicy, iam:AttachRolePolicy, iam:AttachGroupPolicy).
  • Create a login profile for a user (iam:CreateLoginProfile).
  • Modify a permission boundary it is subject to (iam:PutUserPermissionsBoundary self-applied).
  • Create a service-linked role.
  • Add an SSH/GitHub OIDC trust to an existing role.
  • Modify SCPs (if organizations:* is granted).

13. Risky federated identities

  • GitHub Actions OIDC trust with sub claim matching repo:org/* (any repo in org), repo:* (any repo), * (any sub), or missing sub condition (only aud checked).
  • Cognito identity pools allowing unauthenticated identities with non-trivial role.
  • SAML IdPs with role mappings that aren't tied to specific groups.
  • OIDC providers without aud (audience) verification.
  • Workload identity federation from non-AWS clouds without principal pinning.

14. Weak IAM boundaries

  • Roles with admin or near-admin policies attached without a permission boundary.
  • Permission boundaries that are themselves overpermissive (e.g. boundary allows * minus a tiny denylist).
  • Boundaries that don't deny privilege escalation primitives (iam:CreateUser, iam:AttachUserPolicy, iam:PutUserPolicy, etc.).
  • Roles delegated to developers (assumable by SSO permission set) without a boundary capping their effective permissions.
  • Service control policies referenced but not denying root user actions, IAM mutations from outside designated accounts, or region restrictions.

PRIVILEGE ESCALATION ANALYSIS

Maintain an internal taxonomy of escalation primitives. Below is the canonical set (this list is the detection contract — extend with care). For each, the skill checks for the listed actions on the listed resource shape, in the absence of restricting conditions.

#Primitive nameRequired actionsResourceNotes
1CreateAccessKeyiam:CreateAccessKeyuser/*Steal long-term creds for any user
2CreateLoginProfileiam:CreateLoginProfileuser/*Set console password for any user
3UpdateLoginProfileiam:UpdateLoginProfileuser/*Reset password for any user
4AttachUserPolicyiam:AttachUserPolicyuser/*Attach admin to any user (incl. self)
5AttachGroupPolicyiam:AttachGroupPolicygroup/*Escalate via group membership
6AttachRolePolicyiam:AttachRolePolicyrole/*Attach admin to assumable role
7PutUserPolicyiam:PutUserPolicyuser/*Inline admin on any user
8PutGroupPolicyiam:PutGroupPolicygroup/*Inline admin on any group
9PutRolePolicyiam:PutRolePolicyrole/*Inline admin on assumable role
10AddUserToGroupiam:AddUserToGroupgroup/*Join privileged group
11UpdateAssumeRolePolicyiam:UpdateAssumeRolePolicy + sts:AssumeRolerole/*Make any role assumable by self
12CreatePolicyVersioniam:CreatePolicyVersionpolicy/*Pivot policy to admin
13SetDefaultPolicyVersioniam:SetDefaultPolicyVersionpolicy/*Switch policy to dormant admin version
14PassExistingRoleToNewLambdaiam:PassRole + lambda:CreateFunction + lambda:InvokeFunctionrole/, function/Classic Lambda PassRole escalation
15PassRoleToNewLambdaUrlOrApiiam:PassRole + lambda:CreateFunction + lambda:CreateFunctionUrlConfig (or apigateway:*)role/, function/Reachable Lambda escalation
16UpdateLambdaCodelambda:UpdateFunctionCodefunction/*Hijack existing privileged Lambda
17PassRoleToNewEC2iam:PassRole + ec2:RunInstances + iam:AddRoleToInstanceProfile (or pre-existing profile)role/, instance/EC2-based escalation
18PassRoleToCloudFormationiam:PassRole + cloudformation:CreateStackrole/, stack/CFN as escalation engine
19PassRoleToGlue / SageMaker / DataPipeline / CodeBuild / StepFunctionsiam:PassRole + create-job actionrole/, job/Many service-as-engine variants
20PassRoleToECSTaskiam:PassRole + ecs:RegisterTaskDefinition + ecs:RunTaskrole/, task/Container-based escalation
21UpdateECSTaskDefinitionecs:RegisterTaskDefinition + ecs:UpdateServicetask/, service/Hijack existing task role
22EditExistingLambdaConfiglambda:UpdateFunctionConfigurationfunction/*Change env vars / role; combined with PassRole = full takeover
23AssumeRoleByTrustModificationiam:UpdateAssumeRolePolicy + sts:AssumeRolerole/*Persistence + escalation
24KMSGrantSelfkms:CreateGrant on key/*key/*Bypass key policy to decrypt
25SecretsManagerResourcePolicyEditsecretsmanager:PutResourcePolicysecret/*Grant self access to secrets
26S3BucketPolicyEdits3:PutBucketPolicybucket/*Grant self access to buckets
27SSMSessionToInstancessm:StartSession + ec2:DescribeInstancesinstance/*Lateral into EC2 with its role
28EC2InstanceConnectec2-instance-connect:SendSSHPublicKey + ec2:DescribeInstancesinstance/*SSH into EC2 with its role
29CodeBuildPoisonProjectcodebuild:UpdateProject + codebuild:StartBuildproject/*Hijack CI/CD role
30CloudShellAdmincloudshell:* + access to a privileged usern/aBrowser-side escalation
31OrganizationsTakeoverorganizations:InviteAccountToOrganization / organizations:CreateAccount / sts:AssumeRole on OrganizationAccountAccessRoleaccount/*Org-level escalation
32SSOPermissionSetEditsso:UpdatePermissionSet + sso:ProvisionPermissionSetpermissionSet/*SSO-side escalation
33IAMUserCreateiam:CreateUser + iam:AttachUserPolicy (or iam:PutUserPolicy) + iam:CreateAccessKeyuser/*Net-new admin user (persistence)

For each primitive detected, capture:

  • The exact statement(s) granting it.
  • The principal it applies to.
  • Whether a permission boundary blocks it (if boundary is present and properly scoped).
  • Whether an SCP would block it (if SCP context provided).
  • Whether conditions narrow it (and how meaningfully).

TRUST POLICY ANALYSIS

For every role's trust policy, compute the set of effective assumers: the union of principals (AWS accounts, users, roles, services, federated identities) that can successfully call sts:AssumeRole (or its variants) against this role, given the policy's principals AND conditions.

Then classify each effective assumer:

Assumer classRisk lens
Same-account service principal (lambda, ecs-tasks, ec2, etc.)Risky only if anyone in the account can create that compute type with this role attached — combine with iam:PassRole analysis.
Same-account specific role/userStandard; check that the source principal isn't itself overpowered.
Same-account rootWhole-account trust — anyone with iam:CreateRole + sts:AssumeRole in the account can reach this.
Cross-account specific role (with ExternalId)Generally safe; verify ExternalId is unguessable and not in code.
Cross-account specific role (no ExternalId)Confused-deputy risk if the trusted account is a SaaS vendor.
Cross-account rootHigh risk — entire foreign account can reach this.
* with aws:PrincipalOrgIDAcceptable if org is yours; verify org ID.
* with no conditionCritical — anonymous role assumption.
Federated SAMLVerify SAML provider is yours; verify SAML:aud condition.
Federated OIDC (GitHub Actions)Verify aud is sts.amazonaws.com AND sub is pinned tightly (repo + branch/environment/tag).
Federated OIDC (other)Verify aud and subject claim pinning.
Federated Cognito (authenticated)Acceptable for app users with appropriately scoped role.
Federated Cognito (unauthenticated)Anonymous internet access to this role — only acceptable for explicitly anonymous-facing capabilities.

Trust policy red flags that trigger findings regardless of the assumer class:

  • Action: sts:* (instead of specific sts:AssumeRole / sts:AssumeRoleWithWebIdentity / sts:AssumeRoleWithSAML / sts:TagSession).
  • Action: * (catastrophic — allows trust-policy-based denial-of-service via session tag exhaustion and other weird primitives).
  • Use of NotPrincipal (almost always wrong in trust policies).
  • Conditions on non-existent or typo'd condition keys (e.g. aws:PrincipalOrgId with lowercase d — the real key is aws:PrincipalOrgID; AWS treats unknown keys as not-matching, which can have surprising effects depending on operator).

LATERAL MOVEMENT ANALYSIS

Lateral movement is modeled as edges in the IAM Graph beyond direct role assumption:

  1. Identity → Identity edges:

    • Direct sts:AssumeRole permission + matching trust.
    • iam:UpdateAssumeRolePolicy on a target role (modify trust to add self).
    • iam:CreateAccessKey on a more privileged user.
    • iam:AttachRolePolicy on a role you can already assume but which currently has fewer permissions.
  2. Identity → Compute → Identity edges:

    • iam:PassRole + compute-create on a role you couldn't directly assume.
    • Existing compute hijack: lambda:UpdateFunctionCode / ecs:RegisterTaskDefinition + ecs:UpdateService / ec2:StartInstances after modifying user-data via ec2:ModifyInstanceAttribute.
  3. Identity → Data → Identity edges:

    • Write access to a config file in S3 read by a more privileged workload (config-as-code injection).
    • Write access to an ECR image consumed by a more privileged task.
    • Write access to a Lambda layer used by a more privileged function.
    • Write access to an SSM parameter or Secrets Manager secret consumed by a more privileged workload.
    • Write access to a CloudFormation template stored in S3 then deployed by a privileged pipeline.
  4. Identity → Network → Identity edges:

    • ssm:StartSession to an EC2 instance, inheriting its role.
    • ec2-instance-connect:SendSSHPublicKey to an EC2 instance.
    • eks:DescribeCluster + eks:AccessKubernetesApi to an EKS cluster, then pod-level role.
    • VPC peering / Transit Gateway access enabling reach to internal IMDS / metadata endpoints in other accounts (typically out of scope here; flag for iac-network correlation).

For each identified lateral edge, attach:

  • Source principal.
  • Target principal.
  • Mechanism (one of the above categories).
  • Required actions.
  • Prerequisites (e.g. "requires target Lambda to already exist and be invokable").

CONTEXTUAL REASONING

Every finding's final severity is a function of intrinsic severity AND context. The skill MUST incorporate these dimensions, using whatever signal iac-analysis provides (and degrading gracefully when signal is missing):

Exploitability

How many steps stand between a realistic attacker and exercising this primitive?

  • Direct (1 step): Principal is internet-reachable (federated OIDC from public source, Cognito unauth, public Lambda URL, public API Gateway invoking this role).
  • Near (2-3 steps): Principal requires assuming a role first, but starting principal is broadly accessible (any developer SSO user, any service in the account).
  • Far (4+ steps): Requires multiple hops including one that is itself well-controlled.
  • Theoretical: Requires conditions that are unlikely to be satisfied (e.g. compromising a specific tagged resource).

Blast radius

If the primitive were successfully exercised, what is the scope of impact?

  • Account-wide / org-wide: Admin equivalent, can affect all resources.
  • Service-wide: All instances of one service (all S3 buckets, all secrets).
  • Resource-set: Specific named resources.
  • Single resource: One bucket, one secret, one role.

Tie blast radius to data sensitivity when known: a s3:* on a bucket tagged DataClassification=PII or Confidentiality=Restricted is more severe than the same on an empty staging bucket.

Internet exposure

Cross-reference with iac-analysis for:

  • Public Lambda URLs / Function URLs.
  • API Gateway routes (especially without authorizer).
  • ALB / NLB listeners with 0.0.0.0/0 security group ingress.
  • CloudFront distributions.
  • Public S3 buckets.
  • EC2 instances with public IPs + permissive SGs.
  • EKS clusters with public endpoints.
  • App Runner services (public by default).

A role attached to an internet-exposed workload has its severity elevated by one level for any escalation primitive it possesses.

Workload exposure

Some workloads, while not internet-exposed, are exposed to untrusted input:

  • SQS consumers reading from cross-account queues.
  • S3 event consumers triggered by cross-account uploads.
  • SNS subscribers.
  • EventBridge rules triggered by external events.
  • CodeBuild projects with source from public repos / fork PRs.

These workloads should be treated as semi-exposed: their roles should not hold escalation primitives.

Production criticality

Inferred from (in order of confidence):

  • Explicit tags: Environment=prod, env=production, Criticality=tier-1.
  • Resource names containing prod, production, prd.
  • Terraform workspace name.
  • File path (environments/prod/..., live/prod/...).
  • Default assumption: if iac-analysis cannot determine, assume unknown and use the more conservative (higher) severity.

Privilege chaining

Already covered in PRIVILEGE ESCALATION ANALYSIS. When a primitive is part of a chain that leads to admin in ≤ 3 hops, its effective severity is the severity of the terminal capability (admin-equivalent ≈ critical).

Attack paths

A finding that participates in a named, demonstrable attack path (see EXAMPLE ATTACK PATHS) is reported both as an individual finding and as a member of a composite path finding. The path finding inherits the severity of its highest-severity link.

ATTACK CHAIN REASONING

For every starting principal in {internet-reachable workloads, federated identities, low-privilege developer SSO roles, cross-account principals from non-fully-trusted accounts}, attempt to construct a path to one of these terminal capabilities:

  • *:* on * (full admin).
  • iam:* (IAM admin).
  • sts:AssumeRole to any role in the account.
  • kms:Decrypt against keys protecting production data.
  • secretsmanager:GetSecretValue against production secrets.
  • Read of customer/PII data stores.
  • Write/delete of production data stores.
  • Modification of CI/CD pipelines (CodeBuild, CodePipeline, CodeDeploy).

Path search rules:

  1. Bounded depth: Default max depth 4. Beyond 4, paths are too speculative to action.
  2. No back-edges: Don't include cycles (revisiting a principal).
  3. Condition awareness: If an edge requires a condition (e.g. ExternalId), record the assumption needed for the path to be exploitable.
  4. Prefer shorter paths: Report the shortest path to a given terminal first; longer paths to the same terminal only if they involve materially different mechanisms.
  5. Annotate each step: For each step in the path, record the primitive used and the policy ARN / statement Sid responsible.

Output each path with a human-readable narrative (see EXAMPLE ATTACK PATHS) and a structured steps[] array (see EXAMPLE JSON OUTPUT).

CONFIDENCE SCORING

Every finding carries a confidence score from 0.0 to 1.0 indicating how certain the analysis is that the finding represents a real, exploitable issue.

RangeLabelMeaning
0.9–1.0confirmedDirect evidence in IaC — explicit wildcard *, hardcoded trust to *, missing condition on a sensitive action. No ambiguity.
0.7–0.89highStrong signal with minor inference — e.g. managed policy known to contain dangerous actions, role trust inferred from module output, PassRole target inferred from resource type.
0.5–0.69mediumRequires inference or depends on unresolved references — e.g. policy attached via variable that likely resolves to admin, cross-account trust where the external account's IaC is not in scope.
0.3–0.49lowHeuristic-based — e.g. role name suggests admin but policy document not visible, module from registry with unknown internals, condition operator with ambiguous semantics.
0.0–0.29speculativePossible but unverifiable from IaC alone. Emitted only when the potential impact is Critical and the signal warrants attention despite uncertainty.

Confidence signals for IAM findings

Boosters (+): explicit policy document visible, wildcard * in Action/Resource directly observed, known dangerous managed policy ARN matched, trust policy parsed with principal visible, multiple corroborating signals (PassRole + target service + no boundary).

Reducers (-): policy attached via unresolved variable/module output, managed policy ARN not in internal catalog, condition operator with edge-case semantics (ForAllValues, ForAnyValue), cross-account principal not in scope, resource uses data.aws_iam_policy_document with dynamic references.

Confidence and severity are independent axes. A finding can be high-severity + low-confidence (dangerous if true, but uncertain) or low-severity + high-confidence (definitely exists but low impact).

SEVERITY GUIDANCE

Severity is the composite of intrinsic primitive severity and context. Use this rubric, but the reasoning matters more than the label — always emit a severity_rationale field.

SeverityCriteria
CriticalDirect or near-direct path to admin / full data access from an internet-reachable or anonymously-assumable principal. OR: Trust policy with Principal: * and no org-bound condition. OR: Admin policy attached to a public-facing workload. OR: PassRole + create-Lambda + public Function URL chain.
HighEscalation primitive on a role assumable by any in-account principal. OR: Cross-account trust without ExternalId to a SaaS vendor account. OR: Overprivileged role on internet-facing workload (even without direct admin path). OR: GitHub OIDC trust with overly broad sub claim.
MediumWildcard permissions on production workload roles that don't constitute an escalation primitive. OR: Missing permission boundaries on developer-assumable roles. OR: Confused-deputy-shaped trust without aws:SourceArn. OR: Inline policies duplicating managed policies on production roles.
LowWildcard read-only permissions on internal workloads. OR: Inline policies on non-production roles. OR: Missing tags / labels that would aid downstream analysis. OR: Use of deprecated managed policies.
InfoObservations useful for context (e.g. "this role is assumable from the CI/CD account — verify intentional").

Severity floors and ceilings:

  • A finding tagged production=true cannot be reported lower than Medium unless the primitive is purely informational.
  • A finding on an internet-exposed workload cannot be lower than Medium.
  • A finding for which no production/exposure signal exists is reported at the level the primitive itself warrants — do not artificially deflate.

FALSE POSITIVE REDUCTION

Apply these heuristics to suppress or down-rank likely false positives. Always preserve the original detection — suppression means lower severity or informational tag, not silent dropping (downstream may still want to see it).

  1. AWS-required wildcards: Some AWS-managed actions legitimately require Resource: * (e.g. ec2:DescribeInstances doesn't support resource-level permissions). Maintain a catalog of actions that do not support resource-level restrictions, and don't flag wildcards on those.

  2. Service-linked roles: Trust policies for service-linked roles are managed by AWS and not user-editable in the normal sense. Don't flag their trust shapes.

  3. Permission boundary present and tight: If a role has a permission boundary that denies the dangerous primitive, downgrade severity by one level and add mitigated_by: PermissionBoundary context.

  4. SCP context provided: If an SCP is in scope and denies the primitive, downgrade similarly.

  5. Read-only enumeration patterns: *:Describe*, *:List*, *:Get* (when not on sensitive resource types like secrets/keys) are lower severity than write/mutate wildcards.

  6. Intentional cross-account roles: A role explicitly named *CrossAccount*, *ReadOnly*, *Audit*, *Vendor* with a matching trust policy targeting a known vendor account is expected to be cross-account-assumable — report as informational unless it has surprising permissions or lacks ExternalId.

  7. Deployment / Terraform-runner roles: A role assumable only from a CI/CD account, with admin-like permissions, named like *DeployRole, *TerraformExec*, is expected to have broad permissions. Report only if its trust is weaker than expected (e.g. assumable from human users in the CI/CD account without MFA condition).

  8. Bootstrap roles: CDK bootstrap roles (cdk-*-cfn-exec-role, cdk-*-deploy-role, etc.) have known shapes — match against the CDK bootstrap template and don't flag the canonical configuration.

  9. Explicit suppression markers: Honor inline annotations like # iac-iam:ignore=PrimitiveName reason="..." in comments or IacIamIgnore tags on resources. Always require a reason. Record suppressions in output for audit.

  10. Single-resource wildcards: Action: s3:GetObject Resource: arn:aws:s3:::specific-bucket/* is a wildcard on object keys within a specific bucket — that's expected and fine. Don't flag.

  11. Trust to own-account org: aws:PrincipalOrgID matching the current account's known org ID is a valid scoping mechanism.

  12. Differentiate Lambda execution role vs. trust: Lambda's trust policy granting lambda.amazonaws.com is required and not a finding. The finding is about what the role can do, not who can assume it (since service-principal trust is normal).

OUTPUT FORMAT

See examples/output-format.md for the full JSON schema, finding fields, and attack path structure.

EXAMPLE FINDINGS

See examples/findings.md for detailed example findings with severity rationale and evidence.

EXAMPLE ATTACK PATHS

See examples/attack-paths.md for detailed example attack paths with narratives, step-by-step primitives, and prerequisites.

EXAMPLE JSON OUTPUT

See examples/json-output.md for a complete example of the top-level JSON output with summary, findings, attack paths, IAM graph, and suppressions.

CORRELATION OPPORTUNITIES

This skill's output is most valuable when correlated with other pipeline skills via shared resource identifiers. Emit correlation_hints on every finding to help downstream consumers (especially iac-correlate) join across skills.

Correlated skillWhat to look forWhy it matters
iac-networkPublic Lambda Function URLs, public API Gateway routes without authorizer, 0.0.0.0/0 SG ingress on ALB/NLB fronting workloads we flagged, public EC2 instances with profiles we flagged, EKS public endpoints.Converts "overprivileged role" into "internet-reachable overprivileged role" — drives severity.
iac-secretsHardcoded credentials of principals we flagged. Hardcoded ExternalId values.A leaked access key for a principal we flagged as escalation-capable is a live incident, not a hypothetical.
iac-encryptionKMS key policies that trust principals we flagged. Unencrypted resources accessible by roles we flagged.KMS key policies form a second IAM layer; key access is often the deciding factor in blast radius.
iac-resource-policiesS3, SNS, SQS, Secrets Manager, ECR resource policies that trust principals we flagged or that grant * access to data our flagged roles use.Cross-layer trust analysis.
iac-misconfigMFA-required conditions missing on console-assumable roles, public S3 buckets reachable from internet-exposed compute.General misconfig context.
iac-supply-chainUse of public CodeBuild source from forks with privileged build roles. Third-party Lambda layers attached to privileged functions.Build-time compromise → runtime IAM compromise.
iac-threat-modelComposite threat model that consumes attack paths from this skill as primary inputs.This skill provides the chain primitives; threat-model composes higher-order narratives.
iac-reportAll findings + attack paths, grouped, prioritized, deduplicated across skills.The human-readable output layer.

correlation_hints field on each finding:

json
{
  "shared_resources": ["aws_lambda_function.api_handler", "aws_iam_role.api_handler_role"],
  "related_skills": ["iac-network", "iac-secrets"],
  "join_keys": {
    "resource_arn": "arn:aws:lambda:us-east-1:123456789012:function:api-handler",
    "iac_address": "module.api.aws_lambda_function.api_handler"
  }
}

LIMITATIONS

The skill is honest about what it does NOT and CANNOT do reliably:

  1. No runtime state: This is static IaC analysis. A role might be defined permissively in IaC but constrained at runtime by an SCP, a permission boundary applied out-of-band, or a session policy. The skill flags the IaC-visible risk; runtime correlation requires a separate runtime-aware skill.

  2. AWS-managed policy drift: AWS-managed policies (e.g. AmazonS3FullAccess) change over time. The skill carries an internal catalog snapshot; if AWS adds actions to a managed policy, the catalog must be refreshed. Stale catalogs may under-report.

  3. Module-level abstractions: When IaC uses heavy module abstraction (Terraform modules from registries, CDK aspects, Pulumi component resources), the skill depends on iac-analysis to flatten before analysis. If iac-analysis cannot resolve a reference, the skill emits a warning and proceeds with partial information.

  4. Cross-account graph: The skill sees only what's in the IaC it's analyzing. If account A's role trusts account B's role, but only A's IaC is in scope, the skill flags the trust but cannot verify what B can do. Conversely, if A trusts B and B's IaC is in scope (multi-account repo), the skill should build the cross-account graph — flag this case with cross_account_graph_built: true in the path.

  5. SCP and Org context optional: Unless SCP/Org content is provided as input, the skill cannot reason about whether an SCP would block a primitive. Findings assume no SCP mitigation unless told otherwise.

  6. Condition logic depth: AWS condition operators have subtle semantics (e.g. ForAllValues:StringEquals with empty multi-valued context keys evaluates true — a known gotcha). The skill implements the common operators correctly but does not exhaustively model every edge case in the AWS policy language. Where ambiguity exists, the skill prefers the attacker-favorable interpretation.

  7. Service catalog completeness: The list of services for which iam:PassRole is exploitable (Lambda, ECS, EC2, CFN, Glue, SageMaker, CodeBuild, Step Functions, App Runner, Batch, EMR, DataPipeline) is the canonical set as of the catalog snapshot. New AWS services that consume PassRole may not yet be in the catalog.

  8. Naming-based criticality inference: Inference of production vs. non-production from names and tags is heuristic. False positives (treating a dev resource as prod) and false negatives (treating a prod resource as dev) both occur. The skill prefers false positives (over-flag) to false negatives.

  9. Multi-cloud is secondary: AWS support is deep; Azure and GCP support recognizes major risk patterns (overpermissive role assignments, weak trust) but does not have an equivalent primitives taxonomy. Multi-cloud accounts should be reviewed with cloud-native CSPM in addition.

  10. No exploitation validation: The skill identifies attack paths but does not attempt to validate them against a live account. Some flagged paths may be blocked by runtime controls invisible to IaC (CloudTrail-driven Lambda rejections, runtime guardrails like AWS Config auto-actions, custom Lambda authorizers).

FUTURE IMPROVEMENTS

Tracked enhancements, roughly ordered by expected impact:

  1. SCP simulation: Accept SCPs as first-class input and apply them during primitive evaluation. Would meaningfully reduce false positives in mature orgs.

  2. Permission boundary verification: Cross-check boundary policies against known "deny escalation" boundary templates and flag boundaries that fail to deny escalation primitives.

  3. AWS managed policy auto-refresh: Pull AWS-managed policy definitions from iam:GetPolicyVersion (when given read-only credentials) or from a periodically updated public catalog.

  4. Live-account correlation mode: Optional mode that, given read-only AWS credentials, cross-references IaC findings against runtime state (e.g. "this role flagged in IaC for iam:* has been used to call iam:CreateUser 14 times in the last 90 days per CloudTrail").

  5. GitHub OIDC sub-claim catalog: Auto-detect organization name from project Git remote and validate that OIDC sub claims pin to repos that actually exist.

  6. Differential analysis: When comparing a PR against main, identify new primitives and attack paths introduced by the change. This is the form most useful for PR reviews.

  7. Cross-IaC-format consolidation: When a repo uses both Terraform and CloudFormation that reference each other (e.g. CFN-managed bootstrap + Terraform-managed workloads), correlate cross-format references via iac-analysis cross-format graph.

  8. Custom primitive library: Allow project teams to define organization-specific primitives (e.g. "any role with access to our internal payments service is critical") in a config file consumed by this skill.

  9. K8s RBAC integration: For workloads on EKS, follow IRSA mappings into Kubernetes RBAC and flag escalation primitives that traverse the IAM↔K8s boundary.

  10. Symbolic policy evaluation: Replace primitive-pattern matching with symbolic evaluation of policy documents (à la Zelkova / IAM Access Analyzer) for fewer false negatives on unusual condition combinations.

  11. Attack path minimum-cut analysis: For each set of attack paths, compute the minimum set of findings whose resolution would break all paths — feed to iac-report as a prioritized fix list.

  12. Coverage reporting: Per-run report on which primitives were evaluated against which principals, including "not evaluated because X" — improves auditor trust.

  13. Suppression governance: Track suppression aging — flag suppressions that have been in place > N days without re-review.

  14. Threat-actor scenario library: Allow analysts to specify scenarios ("assume initial access via leaked GitHub PAT", "assume initial access via SSRF on the public API") and have the skill produce scenario-conditional attack paths.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Iac Iam AI skill do?

Deep IAM and identity-layer security analysis for Infrastructure-as-Code. Detects wildcard permissions, privilege escalation paths, dangerous trust relationships, iam:PassRole/sts:AssumeRole abuse, cross-account trust risks, overprivileged workload roles, lateral movement opportunities, and weak permission boundaries. Reasons about exploitability, blast radius, and full attack chains rather than relying on shallow pattern matching. Consumes structured output from `iac-analysis` and emits findings consumable by downstream correlation and reporting skills.

Why use Iac Iam on TypingMind?

Because you install it once and use it with any model. Iac Iam is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Iac Iam in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/senaykt/iac-security-scan-skills/tree/main/.agents/skills/iac-iam. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Iac Iam?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Iac Iam?

As many as you like. As long as a model supports skills, you can use Iac Iam with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Iac Iam AI skill free?

Yes. It is published on GitHub by senaykt under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇