Checkov fails a Terraform PR because an S3 bucket allows public access. What do you change?
BeginnerScenarioContainer and IaC Security
Answer
Situation read → A public bucket is one of the most common causes of data leaks.
What I'd do →
- Add a public access block:
resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.this.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
- Enable default encryption and versioning.
- If the bucket must serve public web content, use CloudFront with Origin Access Control instead.
- Enforce account-wide with S3 Block Public Access at account level.
Why → Block Public Access overrides any ACL or policy mistake.
Interview tip → Mention account-level block as the guardrail behind the resource-level fix.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?Beginner`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?BeginnerA Dockerfile runs the app as root. How do you fix it and prove the fix?IntermediateHow do you set up image scanning so nothing vulnerable reaches production?IntermediateAn image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?IntermediateYou find `ENV DB_PASSWORD=...` and `ARG NPM_TOKEN` in a Dockerfile. What is wrong and how do you fix it?Beginner