Skip to content

Public Access of S3 Buckets via Policy

ID: s3-bucket-policy-public-access

Severity: critical

Author: princechaddha

Tags: cloud,devops,aws,amazon,s3,aws-cloud-config

This template checks if Amazon S3 buckets are configured to prevent public access via bucket policies

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
metadata:
max-request: 2
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"'
# digest: 4a0a00473045022100c62712d0155b3a6ab8cad4c8d7a87284079288e840855539a4186055949e17f2022061849f7af633798a71f6769172339151da4f05799827c15cc680ee59bfbbf55d:922c64590222798bb761d5b6d8e72950

This template is used to detect vulnerabilities in web applications. It can be used with the Nuclei tool to scan for specific patterns or behaviors.

Terminal window
$ nuclei -u "URL" -t "cloud/aws/s3/s3-bucket-policy-public-access.yaml"

View on Github