2024-04-11 14:23:07 +00:00
|
|
|
id: s3-bucket-policy-public-access
|
|
|
|
info:
|
|
|
|
name: Public Access of S3 Buckets via Policy
|
|
|
|
author: princechaddha
|
|
|
|
severity: critical
|
|
|
|
description: |
|
|
|
|
This template checks if Amazon S3 buckets are configured to prevent public access via bucket policies
|
|
|
|
reference:
|
|
|
|
- https://docs.aws.amazon.com/cli/latest/reference/s3api/get-bucket-policy.html
|
2024-06-07 10:04:29 +00:00
|
|
|
metadata:
|
|
|
|
max-request: 2
|
2024-04-11 14:23:07 +00:00
|
|
|
tags: cloud,devops,aws,amazon,s3,aws-cloud-config
|
|
|
|
|
|
|
|
flow: |
|
|
|
|
code(1)
|
|
|
|
for(let bucketName of iterate(template.buckets)){
|
|
|
|
set("bucket", bucketName)
|
|
|
|
code(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
self-contained: true
|
|
|
|
code:
|
|
|
|
- engine:
|
|
|
|
- sh
|
|
|
|
- bash
|
|
|
|
source: |
|
|
|
|
aws s3api list-buckets --query 'Buckets[*].Name'
|
|
|
|
|
|
|
|
extractors:
|
|
|
|
- type: json # type of the extractor
|
|
|
|
internal: true
|
|
|
|
name: buckets
|
|
|
|
json:
|
|
|
|
- '.[]'
|
|
|
|
|
|
|
|
- engine:
|
|
|
|
- sh
|
|
|
|
- bash
|
|
|
|
source: |
|
|
|
|
aws s3api get-bucket-policy --bucket $bucket --query Policy --output text
|
|
|
|
|
|
|
|
matchers-condition: and
|
|
|
|
matchers:
|
|
|
|
- type: word
|
|
|
|
part: body
|
|
|
|
words:
|
|
|
|
- '"Effect":"Allow"'
|
|
|
|
|
|
|
|
- type: word
|
|
|
|
part: body
|
|
|
|
words:
|
|
|
|
- '"Principal":"*"'
|
|
|
|
- '"AWS":"*"'
|
|
|
|
|
|
|
|
extractors:
|
|
|
|
- type: dsl
|
|
|
|
dsl:
|
|
|
|
- '"The S3 bucket " + bucket +" is publicly accessible via Policy"'
|
2024-06-08 16:02:17 +00:00
|
|
|
# digest: 4a0a0047304502204fae5eb6e1f955f5a9d53c8f30d1d5fb8742e57e0c2ee96f342abbaa4e2c86fd022100dce6a398ef04206209cf3fc4714c9a933458aca9558d8387e8b42a0aabcc0c57:922c64590222798bb761d5b6d8e72950
|