Sub topic 2
Defining the zone of trust
This chapter assumes you can read IAM policy documents (Effect, Principal, Action, Resource, Condition) and tell identity-based from resource-based policies. It also assumes you know what an AWS account and an AWS Organizations organization are. You should be able to run AWS CLI commands.
An external access analyzer needs a definition of "outside" before it can report anything. That definition is the zone of trust. It decides which findings you see and which you never see.
What the zone of trust is
The zone of trust is the set of accounts and identities that you consider safe for a given analyzer. Access Analyzer examines resource-based policies on supported resources. These include S3 buckets, IAM role trust policies, KMS keys, Lambda functions, SQS queues, SNS topics, Secrets Manager secrets and others. For each policy, it asks whether any principal outside the zone of trust can reach the resource. If one can, the analyzer creates a finding.
You pick the zone when you create the analyzer, by choosing its type:
| Analyzer type | Zone of trust | Where you can create it |
|---|---|---|
| `ACCOUNT` | The single AWS account that owns the analyzer | Any account |
| `ORGANIZATION` | Every account in the AWS Organizations organization | The management account, or a delegated administrator account |
Two consequences follow from this table.
- With an account analyzer, a principal in another account counts as external. That is true even when the other account belongs to your own organization.
- With an organization analyzer, a principal in any member account counts as internal. Sharing between your own accounts produces no finding.
Inside versus outside: a worked comparison
Suppose your organization has two accounts, 111122223333 (production) and 444455556666 (analytics). A third account, 999988887777, belongs to a partner and is not in the organization. A bucket in production has a policy that lets the analytics account read objects.
- The account analyzer in production reports a finding. The principal
444455556666is outside the single-account zone. - The organization analyzer reports no finding for that grant. The principal is inside the organization.
- If the policy also named
999988887777, both analyzers report that grant.
Many teams run both. The organization analyzer gives a low-noise view of real external exposure. The account analyzer in a sensitive account also surfaces cross-account grants inside the organization, which you may want to review even though they are not "external".
Creating an analyzer with the zone you want
An account analyzer needs only a name and a type. An organization analyzer uses the same call with a different type. You run it from the management account or from a delegated administrator for Access Analyzer.
# Zone of trust = this account
aws accessanalyzer create-analyzer \
--analyzer-name account-external \
--type ACCOUNT
# Zone of trust = the whole organization
aws accessanalyzer create-analyzer \
--analyzer-name org-external \
--type ORGANIZATIONCheck what you created, and confirm the type:
aws accessanalyzer list-analyzers \
--query 'analyzers[].[name,type,status]' \
--output tableKeep two details in mind.
- An analyzer is a regional resource. It evaluates resources in the Region where you created it. To cover several Regions, create an analyzer in each one.
- You cannot change an analyzer's type after creation. To move from an account zone to an organization zone, create a new analyzer and then delete the old one.
What counts as external
Access Analyzer treats these principals as outside the zone, unless a condition in the policy restricts them to the zone:
- An AWS account ID or root ARN that is not in the zone.
- An IAM role or user in an account outside the zone.
"Principal": "*", which is public access.- Federated identities, such as an OIDC or SAML provider named in a role trust policy, and anonymous or unauthenticated callers.
Conditions can pull a broad grant back inside the zone. The analyzer reads condition keys and takes them into account. The keys that matter most for zone definition are:
aws:PrincipalOrgIDandaws:PrincipalOrgPaths, which limit callers to your organization or to part of it.aws:SourceAccount,aws:SourceArnandaws:SourceOrgID, which limit which account or resource a service is acting for.aws:PrincipalArnandaws:PrincipalAccount, which limit callers to named principals or accounts.
Compare two statements that both use "Principal": "*".
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AnyoneInTheWorld",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-bucket/*"
}
]
}This policy produces a public access finding for every analyzer type, because no condition limits the caller.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AnyoneInMyOrganization",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-bucket/*",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "o-exampleorgid"
}
}
}
]
}The organization analyzer reports nothing for this policy, because only organization members can satisfy the condition. The account analyzer still reports a finding. Members of the organization are outside a single-account zone, and the finding shows the aws:PrincipalOrgID condition so you can see why access is limited.
Reading a finding in terms of the zone
Every external access finding records the facts that tie it to the zone: the resource, the external principal, the actions allowed, and any conditions. List active findings for an analyzer, using the ARN that list-analyzers returned:
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/org-external \
--filter '{"status":{"eq":["ACTIVE"]}}' \
--query 'findings[].[resource,resourceType,status]' \
--output tableThen open one finding to see its detail:
aws accessanalyzer get-finding-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/org-external \
--id FINDING_IDWhen you read the output, ask three questions that map directly to the zone:
- Which principal is outside the zone? A specific account points to a sharing relationship you can verify.
*points to public access. - Which condition, if any, narrows the access? A condition that still admits outside parties does not help.
- Is this account one the zone should have included? If it is a legitimate account of yours, fix the zone (use an organization analyzer) rather than suppressing the finding.
Common mistakes
- Using only an account analyzer in a multi-account organization. Every cross-account grant between your own accounts becomes a finding. The real external exposure is buried in noise, and teams start ignoring the list. Use an organization analyzer for external exposure review.
- Creating the organization analyzer in the wrong account. Only the management account or a delegated administrator can create it. Other member accounts get an access error.
- Treating
aws:PrincipalOrgIDas protection against all risk. It limits callers to organization members. A compromised or overly permissive member account still falls inside your zone. - Forgetting Regions. A bucket in
eu-west-1is invisible to an analyzer that exists only inus-east-1. Resources that are Regional, such as KMS keys and Lambda functions, need an analyzer in their own Region. S3 buckets are global, but their findings are reported in the Region where the analyzer evaluates them, so check that you have analyzers where your resources live. - Expecting an immediate update. After you change a policy, Access Analyzer re-evaluates the resource within about 30 minutes. It also rescans periodically. A finding that still shows right after your fix is normal.
Choosing a zone: decision criteria
- Choose
ORGANIZATIONwhen you want to answer "what is exposed outside my company?" in one place. This is the usual choice for a security team. - Choose
ACCOUNTwhen you manage a single account, when you cannot get delegated administrator access, or when you want a stricter review of cross-account sharing within the organization. - Run both in accounts that hold sensitive data, such as encryption keys or secrets. The overlap costs nothing for external access analyzers. Analyzer cost applies to unused access analysis, which later chapters cover.
Exercise
Your organization contains accounts A, B and C. A bucket in account A grants s3:GetObject to account B, and also to an account D that is not in the organization. You have an ACCOUNT analyzer in account A and an ORGANIZATION analyzer in the management account. Which grants does each analyzer report, and what would you change if the account analyzer's finding for account B is noise?
Show answer
The ACCOUNT analyzer in A reports both grants, because B and D are outside the single-account zone. The ORGANIZATION analyzer reports only the grant to D, because B is inside the organization. If the finding for B is noise, rely on the organization analyzer for external exposure review instead of archiving the finding. You can also add an archive rule for B only if the account-level review of in-organization sharing is not wanted.
Exercise
A bucket policy allows Principal "*" with the condition StringEquals aws:PrincipalOrgID o-exampleorgid. Does an ORGANIZATION analyzer in that organization report it as public access? Why?
Show answer
No. The condition limits callers to members of the organization, which is the analyzer's zone of trust, so the access is not external. An unconditioned Principal "*" would be reported as public.