Skip to main content
MEDIUMIAMSecurity

IAM Cross-Account Trust

iam-cross-account-trust

What this rule checks

Detects IAM roles with cross-account trust relationships.

How to fix it

  1. 1Verify cross-account trust is intentional
  2. 2Add conditions to restrict access (e.g., external ID)
  3. 3Document the business justification
FlaggedThe role's trust policy allows another AWS account (111122223333) to assume it. Cross-account trust widens your security boundary, so it must be deliberate and scoped.
import { Role, ArnPrincipal } from 'aws-cdk-lib/aws-iam';

new Role(this, 'PartnerAccessRole', {
  assumedBy: new ArnPrincipal('arn:aws:iam::111122223333:root'),
});
FixedThe role is now assumed by an AWS service principal within your own account instead of an external account, so there is no cross-account trust to review. If cross-account access is genuinely required, keep the external principal but add a Condition (e.g. sts:ExternalId) to lock it down.
import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';

new Role(this, 'PartnerAccessRole', {
  assumedBy: new ServicePrincipal('lambda.amazonaws.com'),
});

CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.

Affected resource types

AWS::IAM::Role

Compliance frameworks

SOC2HIPAAPCI-DSSNIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

Sometimes a flag is deliberate โ€” a genuinely public endpoint, say. You can dismiss iam-cross-account-trust and the reason is kept in the report, not silently hidden.

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "iam-cross-account-trust", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::iam-cross-account-trust',
  reason: 'Why this is intentional',
});

Use the rule ID iam-cross-account-trust shown above โ€” not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs โ†’

Catch this in your stack

$ npx cdk-insights scan

CDK Insights runs this and 118+ other rules locally against your synthesised CDK app โ€” free, no account, your code never leaves your machine.

More IAM rules