Sub topic 5
Reading external access findings
This chapter assumes you know IAM identity-based and resource-based policies, can read a JSON policy (Effect, Principal, Action, Resource, Condition), and have created an external access analyzer. If you haven't, finish the chapter on creating analyzers first.
What an external access finding is
An external access analyzer examines resource-based policies, such as S3 bucket policies, IAM role trust policies, KMS key policies and SQS queue policies. It also examines access points and similar sharing settings. When one of them grants access to a principal outside your zone of trust (the account or organization you chose), the analyzer creates a finding.
Each finding answers four questions:
- Which resource is shared?
- Which principal outside the zone can reach it?
- Which actions are allowed?
- Which condition limits the access, if any?
A public access example
The bucket policy below allows any principal to read every object in the bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowEveryoneRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-bucket/*"
}
]
}"Principal": "*" means everyone, so the analyzer reports a finding with public access set to true for the bucket. Reading the finding, you identify:
- Resource:
arn:aws:s3:::example-bucket - Principal:
* - Action:
s3:GetObject - Condition: none, so nothing narrows the access
The fields to read
| Field | What it tells you |
|---|---|
| Resource and resource type | The shared object, such as an S3 bucket or IAM role |
| Resource owner account | The account that owns the resource |
| Principal | The external account, user, role, service or `*` that gets access |
| Action | The permissions the external principal receives |
| Condition | Keys such as `aws:SourceArn` or `aws:PrincipalOrgID` that restrict the access |
| Is public | Whether anyone can reach the resource |
| Status | `ACTIVE`, `ARCHIVED` or `RESOLVED` |
Always check the condition. A statement with Principal: "*" and a condition of aws:PrincipalOrgID limited to your organization is not public. The analyzer takes conditions into account, so a finding may list the condition that restricts the access.
Listing findings from the CLI
Use list-findings-v2 to see active findings for an analyzer. Replace the ARN with your own.
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:us-east-1:111122223333:analyzer/account-external \
--filter '{"status":{"eq":["ACTIVE"]}}' \
--query 'findings[].[findingType,resource,status]' \
--output tableTo see the full detail of one finding, call get-finding-v2 with the finding ID from this list. The detail includes the principal, actions and conditions described above.
Common mistakes
- Treating every finding as a problem. A finding means access crosses the zone boundary. It does not mean the access is wrong. A partner bucket may be shared on purpose.
- Ignoring conditions. A broad principal with a strong condition can be safe. A named account with no condition can be too open.
- Wrong zone of trust. An account-level analyzer reports other accounts in your organization as external. If you share across accounts in one organization, an organization-level analyzer produces fewer false alarms.
- Fixing the finding instead of the policy. Archiving a finding hides it but leaves the access in place. Edit the policy if the access is not intended.
Exercise
A bucket policy allows Principal "*" to call s3:GetObject, but includes the condition {"StringEquals": {"aws:PrincipalOrgID": "o-exampleorgid"}}. Should you expect a public access finding, and which field in the finding would confirm your answer?
Show answer
The condition limits access to principals in that organization, so the bucket is not public. With an account-level analyzer you would still see a finding for other accounts, but with an organization-level analyzer there should be none. The condition and the "is public" field in the finding confirm this.