An S3 bucket is defined so that anyone on the internet can read it

tx0/ts:public-storage-bucketdefaultwarningsecurity/iacdepth fastsecurity, cwe-732

What it finds

A bucket with public read access, a public canned ACL or switched-off public access blocks serves its objects to everyone who guesses or finds their names. Leaked data from S3 is one of the most common cloud incidents.

Reported are Bucket and CfnBucket constructs with publicReadAccess: true, an accessControl of PUBLIC_READ, PUBLIC_READ_WRITE or AUTHENTICATED_READ, or a blockPublicAccess that sets one of its blocks to false, in files that use the CDK.

From the rule's source, public_storage_bucket.rs.

Example from the rule's tests
import * as s3 from "aws-cdk-lib/aws-s3";declare const stack: any;export const site = new s3.Bucket(stack, "Site", { publicReadAccess: true });tx0 reports: this bucket can be read by anyoneexport const logs = new s3.Bucket(stack, "Logs", { enforceSSL: true });
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:public-storage-bucket" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:public-storage-bucket] reason="..."

tx0 explain tx0/ts:public-storage-bucket shows the same in the terminal. Found a false positive? Report it.