For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform/aws/s3_bucket_without_restriction_of_public_bucket.md.
A documentation index is available at /llms.txt.
This check verifies whether public access to an Amazon S3 bucket is properly restricted using the restrict_public_buckets attribute within the aws_s3_bucket_public_access_block resource. If restrict_public_buckets is set to false or omitted, as shown below, the bucket may still be publicly accessible through policies, even if other public access blocks are enabled:
Leaving public bucket restriction disabled increases the risk of unintended data exposure, as users could still attach bucket policies that override ACLs and grant public access. To mitigate this vulnerability and ensure S3 buckets cannot be made public by any means, the restrict_public_buckets attribute should be explicitly set to true:
Failure to enforce this protection may lead to unauthorized access to sensitive data stored in S3, resulting in data breaches and compliance violations.