10.2 Auditing External & Unused Access with IAM Access Analyzer

Key Takeaways

  • IAM Access Analyzer uses automated reasoning and mathematical logic to provably verify resource access policies, eliminating false negatives caused by complex condition blocks and multi-statement evaluations.

  • External access analyzers use a zone of trust (an account or the organization) and analyze resource-based policies for 15 resource types, including S3 buckets, IAM role trust policies, KMS keys, Lambda, SQS, Secrets Manager, SNS, EBS and RDS snapshots, ECR, EFS, and DynamoDB.

  • Archive rules automatically triage expected cross-account access findings (such as approved third-party integrations), keeping security findings focused on genuine unintended exposure.

  • Unused access analyzers inspect IAM users and roles against a tracking period of 1–365 days, reporting unused roles, unused access keys, unused console passwords, and unused service- and action-level permissions.

  • Automated policy generation analyzes AWS CloudTrail event logs over a specified time window to synthesize fine-grained least-privilege IAM policies tailored precisely to actual historical workload activity.

Last updated: September 2026

10.2 Auditing External & Unused Access with IAM Access Analyzer

Establishing and maintaining the principle of least privilege in enterprise AWS environments is an ongoing operational challenge. As multi-account environments scale, resource-based policies, role trust configurations, and cross-account delegations proliferate across thousands of workloads. Traditional security auditing mechanisms rely on pattern matching, regex scraping, or static linters. However, static linters frequently fail when evaluating complex JSON policies containing nested conditions, NotPrincipal elements, or multi-statement evaluation rules, resulting in dangerous false negatives or overwhelming alert fatigue from false positives.

AWS IAM Access Analyzer addresses this challenge by applying automated reasoning—a field of computer science that uses mathematical logic to prove security properties. Access Analyzer delivers three foundational security capabilities: continuous auditing of external access beyond designated trust boundaries, automated discovery of unused identities, stale credentials, and dormant permissions, and automated least-privilege policy generation derived directly from historical AWS CloudTrail activity.


Mathematical Foundations: Automated Reasoning vs. Heuristic Pattern Matching

Traditional cloud security posture management (CSPM) tools inspect policies using heuristic pattern matching. For example, a basic scanner searches for "Principal": "*" to flag an Amazon S3 bucket as publicly readable. However, modern enterprise policies frequently combine wildcard principals with strict condition keys:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowAccessRestrictedToCorporateOrg",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::corp-internal-documents/*",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-enterprise123"
        },
        "Bool": {
          "aws:SecureTransport": "true"
        }
      }
    }
  ]
}

A superficial pattern matcher flags this bucket as "publicly accessible" because of the * principal, creating a false positive. Conversely, a policy with dozens of overlapping allow and deny statements might inadvertently open access to external accounts through an omitted condition—a flaw that static scanners frequently miss.

IAM Access Analyzer avoids heuristics entirely. It converts IAM policies, resource policies, permission boundaries, and condition keys into formal mathematical logic formulas using Satisfiability Modulo Theories (SMT) solvers. The automated reasoning engine mathematically proves whether a viable logical path exists for an unauthorized principal outside the defined zone of trust to access a resource. This mathematical certainty guarantees comprehensive coverage without false alarms.


External Access Analyzers: Zones of Trust & Supported Resources

An external access analyzer identifies resources within your AWS environment that have been shared with an entity outside your designated Zone of Trust.

Defining the Zone of Trust

The zone of trust defines the perimeter within which access is considered legitimate and expected:

  • Account-Level Analyzer: The zone of trust is restricted to the single AWS account where the analyzer is deployed. Access granted to any external AWS account, anonymous public user, or unauthenticated caller generates a finding.
  • Organization-Level Analyzer: The zone of trust encompasses the entire AWS Organization. Deployed via the AWS Organizations Management Account or a designated Delegated Administrator account, this analyzer monitors all member accounts. Sharing resources between member accounts inside the organization does not generate findings; findings trigger only when access is granted to an entity outside the organization.

Monitored Resource Types

External access analyzers evaluate resource-based policies for 15 resource types: S3 general purpose and directory buckets, IAM roles, KMS keys, Lambda functions and layers, SQS queues, Secrets Manager secrets, SNS topics, EBS volume snapshots, RDS DB snapshots and DB cluster snapshots, ECR repositories, EFS file systems, and DynamoDB tables and streams. The most frequently tested are:

Monitored ResourcePolicy Type EvaluatedExample Finding Trigger
Amazon S3 BucketsS3 Bucket Policies & ACLsBucket policy granting s3:GetObject to "Principal": "*" or an external vendor account.
IAM RolesIAM Role Trust PoliciesTrust policy permitting sts:AssumeRole to an external AWS account or public web identity provider.
AWS KMS KeysKMS Key Policies & GrantsCMK policy allowing kms:Decrypt or kms:GenerateDataKey to external principals.
AWS Lambda Functions & LayersLambda Resource-Based PoliciesFunction policy allowing cross-account invocation (lambda:InvokeFunction) or public layer sharing.
Amazon SQS QueuesSQS Queue Access PoliciesQueue policy permitting external accounts or anonymous callers to send or receive messages.
AWS Secrets Manager SecretsSecrets Resource PoliciesSecret policy allowing external accounts to execute secretsmanager:GetSecretValue.
EBS and RDS SnapshotsSnapshot sharing attributesSnapshot shared with another account or made public.
DynamoDB Tables and StreamsDynamoDB resource-based policiesTable policy granting dynamodb:GetItem to an external account.

Internal Access Analyzers

Internal access analyzers (added in 2025) answer the opposite question: which IAM users and roles inside your organization or account can reach selected critical resources. They combine identity policies, resource policies, SCPs, RCPs, and permissions boundaries, and support S3 buckets and directory buckets, RDS DB snapshots and cluster snapshots, and DynamoDB tables and streams. Use them to find, for example, every role in the organization that can read a payroll bucket.

Loading diagram...

Findings Lifecycle and Archive Rules

When Access Analyzer detects external access, it generates a structured finding containing the affected resource ARN, the external principal, permitted actions, and matching condition keys. Findings follow a formal lifecycle:

  • Active: The resource policy currently allows access to an external entity outside the zone of trust.
  • Resolved: Access Analyzer automatically resolves the finding when the resource policy is modified to revoke the external access, or when the resource is deleted.
  • Archived: The access has been evaluated and confirmed as intentional by a security administrator.

To prevent operational alert fatigue from known, approved external integrations (e.g., an external auditing firm assuming a read-only role or a public S3 bucket hosting static website assets), administrators configure Archive Rules:

  • Archive rules specify criteria based on resource ARNs, principal ARNs, or condition keys.
  • Incoming findings matching the archive rule criteria are automatically marked as Archived without alerting analysts.
  • Existing active findings can be retroactively archived when an archive rule is created.
  • Findings are published to Amazon EventBridge (detail-type: "Access Analyzer Finding"), enabling automated integration with AWS Security Hub, PagerDuty, or Jira ticketing pipelines.

Unused Access Analyzers: Continuous Auditing of Dormant Privileges

While external access analyzers secure perimeter boundaries, enterprise environments face an equally dangerous internal threat: dormant identities and excessive unused permissions. Over time, employees change roles, infrastructure testing roles are abandoned, and developers retain broad wildcard permissions that are never exercised in production.

An Unused Access Analyzer continuously evaluates IAM identities across an organization or individual account against an Unused Access Tracking Period (configurable from 1 to 365 days, with a standard default of 90 days).

Four Types of Unused Access Findings

  1. Unused Roles: IAM roles with no access activity during the tracking period. Dormant roles should be reviewed and deleted so attackers can't use them for lateral movement.
  2. Unused Access Keys: IAM user access keys that have not signed a request during the tracking period.
  3. Unused Passwords: IAM user console passwords that have not been used to sign in during the tracking period.
  4. Unused Permissions (Service & Action Level): Continuously compares the permissions granted in attached identity policies against actual API calls recorded in CloudTrail. If an IAM role has AmazonS3FullAccess but has only executed s3:GetObject over the past 90 days, Access Analyzer generates a finding listing all unused services (e.g., s3:DeleteBucket, s3:PutBucketPolicy) as unused.

Auditing Mechanism Comparison

CapabilityIAM Access Analyzer (Unused Access)IAM Credential ReportIAM Access Advisor
Evaluation StyleContinuous automated findings engineStatic, downloadable CSV reportConsole-based visual tab
Entities CoveredIAM Users, Access Keys, Passwords & IAM RolesIAM Users, Access Keys & Passwords onlySelected User, Group, Role, or OU
GranularityAction-level & Service-level permissionsCredential age and login dates onlyService-level last accessed date
AutomationEmits real-time EventBridge eventsManual API call (GenerateCredentialReport)Manual inspection in console
Tracking WindowConfigurable (1 to 365 days)Absolute timestamps since creation/useUp to 365 days of activity

Automated Policy Generation from CloudTrail Logs

Achieving true least privilege by manually authoring IAM policies is notoriously difficult. Developers frequently default to broad managed policies (PowerUserAccess, AmazonEC2FullAccess) because determining the exact set of dozens of micro-actions required by an application is time-consuming.

IAM Access Analyzer solves this through CloudTrail-Based Automated Policy Generation:

Loading diagram...

Step-by-Step Policy Generation Workflow

  1. Run Workload in Staging: Deploy the application in a staging or integration test environment with broader permissions, and execute end-to-end regression suites and business workflows for a representative period (e.g., 30 to 60 days).
  2. Initiate Generation (StartPolicyGeneration): Through the IAM console or CLI, start a policy generation task targeting the specific IAM role. Specify the CloudTrail trail that captures management and data events, along with the date range.
  3. Automated Log Analysis: Access Analyzer queries the CloudTrail logs stored in Amazon S3, identifying every unique API action executed by the target principal ARN and extracting the associated resource ARNs.
  4. Review Generated Policy (GetGeneratedPolicy): Access Analyzer outputs a syntactically valid JSON policy containing only the actions observed in the logs. For actions where CloudTrail cannot deterministically identify the exact resource ARN, the generated policy provides clearly marked placeholders (e.g., ${ResourceArn}) prompting the engineer to specify the exact ARN.
  5. Attachment & Deprecation: The generated least-privilege policy is attached as a customer managed policy, and the legacy broad policy is detached.

Specialty Exam Pitfalls & Architectural Traps

  1. Assuming Organization Analyzers Detect Intra-Organization Cross-Account Access: An organization-level analyzer considers all member accounts within the AWS Organization to be inside the zone of trust. If an S3 bucket in the Production Account allows access to an IAM role in the Development Account, an organization analyzer will not generate a finding! To detect cross-account sharing between internal accounts, you must deploy Account-Level Analyzers.
  2. Know the Coverage Limits: External access analyzers cover 15 resource types (including DynamoDB tables and streams, SNS topics, ECR repositories, EFS file systems, and EBS/RDS snapshots), but not every resource policy: API Gateway resource policies and Amazon OpenSearch Service domain policies, for example, are not analyzed. Unused access analyzers cover only IAM users and roles.
  3. S3 Block Public Access Is Considered: Access Analyzer accounts for S3 Block Public Access. When Block Public Access blocks a public bucket policy, no public finding remains (a cross-account access point finding may replace it). Bucket-level settings are re-evaluated whenever a policy changes, but account-level settings only every 6 hours, so findings can lag an account-level change.
  4. Archive Rules Do Not Modify Resource Policies: Creating an archive rule merely suppresses the finding in the Access Analyzer console and prevents future EventBridge notifications. It does not alter, restrict, or revoke the underlying resource-based policy.
Loading diagram...
IAM Access Analyzer Architecture: External Access, Unused Access, and CloudTrail Policy Generation
Test Your Knowledge

A security operations team oversees an AWS Organization containing over 300 member accounts. The compliance director mandates continuous automated detection of any S3 buckets, AWS KMS keys, or IAM role trust policies that permit access to entities outside the corporate organization. The solution must centralize all findings into the security tooling account, avoid alerting on resource sharing between member accounts inside the organization, and require minimal custom code. Which solution fulfills this mandate?

A

Deploy an AWS Lambda function running on an hourly schedule that queries AWS Config in each account and compares resource policy principals against an internal database of account IDs.

B

Deploy account-level IAM Access Analyzers in all 300 member accounts and configure individual archive rules in each account for every other member account ID.

C

Enable IAM Access Analyzer with an organization-level analyzer in a designated delegated administrator account, defining the zone of trust as the AWS Organization, and route findings via Amazon EventBridge to the security tooling account.

D

Write an Amazon Athena query over CloudTrail management events to flag any API calls where the caller identity account does not match the resource owner account.

Test Your Knowledge

A security administrator reviews an active finding in IAM Access Analyzer showing that an AWS KMS Customer Managed Key (CMK) allows kms:Decrypt permissions to an external AWS account owned by an authorized third-party compliance auditor. The access is verified as permanent, approved, and required for statutory reporting. How should the administrator manage this finding to prevent alert fatigue while preserving an auditable record of the approval?

A

Create an archive rule in IAM Access Analyzer with criteria matching the KMS key ARN and the external auditor account ID, and apply the rule to existing and new findings.

B

Delete the KMS key policy statement and issue static IAM user access keys to the third-party compliance auditing firm.

C

Disable IAM Access Analyzer auditing for the AWS KMS resource category in the account configuration.

D

Modify the KMS key policy to use NotPrincipal with an explicit Deny statement for all other accounts.

Test Your Knowledge

During the development of a containerized payment microservice, engineers attached the AWS-managed policy PowerUserAccess to the application's IAM role. Before promoting the microservice to production, enterprise security policy requires replacing this broad policy with a minimal, least-privilege IAM policy containing only the exact API actions and resources utilized during 45 days of staging tests. Which approach achieves this requirement with the least manual effort?

A

Manually inspect application source code repositories and create an IAM policy based on developers' documented API requirements.

B

Query the IAM Credential Report to extract the last accessed timestamps for the payment role and assemble a list of services.

C

Run the IAM Policy Simulator in the staging account against all AWS service actions to determine which operations succeed.

D

Initiate a CloudTrail-based policy generation job in IAM Access Analyzer targeting the payment role over the 45-day test window, then review and attach the generated policy.

Test Your Knowledge

A multinational corporation needs to satisfy a strict SOC 2 audit requirement by continuously identifying stale and inactive access credentials across their AWS Organization. The compliance team specifically requires continuous automated alerting for any IAM users who have not logged into the AWS console for over 90 days, any IAM access keys that have been inactive for over 90 days, and any IAM roles that have not been assumed within the last 90 days. Which service feature satisfies this requirement with native automated findings?

A

Develop an AWS Systems Manager Automation document that runs every 24 hours to download the IAM Credential Report and send SNS notifications.

B

Enable an Unused Access Analyzer in IAM Access Analyzer at the organization level with the tracking period set to 90 days.

C

Configure an AWS Config managed rule iam-user-unused-credentials-check in each member account with a 90-day parameter.

D

Create an Amazon CloudWatch metric alarm on the NumberOfCredentialsWithoutMFA metric across all member accounts.

Sections you finish are checked off in the contents.