Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3: feature flag to make AWS's new blockPublicAccess and ownershipControls defaults explicit #26788

Closed
2 tasks
plumdog opened this issue Aug 17, 2023 · 3 comments
Closed
2 tasks
Assignees
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. documentation This is a problem with documentation. p1

Comments

@plumdog
Copy link
Contributor

plumdog commented Aug 17, 2023

Describe the feature

A feature flag that removes reliance on Cloudformation defaults for blockPublicAccess and ownershipControls (or objectOwnership as BucketProps calls it) and instead sets them explicitly in the generated Cloudformation.

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#blockpublicaccess says:

default: CloudFormation defaults will apply. New buckets and objects don't allow public access, but users can modify bucket policies or object permissions to allow public access

Which I think is a usability bug, and I think "users can modify bucket policies or object permissions to allow public access" might be false as of 27th April 2023.

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#objectownership say:

default: No ObjectOwnership configuration, uploading account will own the object.

Which I think might actually be false as of 27th April 2023.

Use Case

In the light of https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/, we have a problem where the birthdate of a bucket affects how they behave unless that behaviour is set explicitly.

So we have CDK projects where the same code deployed two essentially identical stacks, but either side of the behaviour change date. A diff or update to the older stack finds no changes. But I don't want this variance, I want two CDK stacks that are the same - up to naming - behave the same.

Proposed Solution

A CDK feature flag so that there is some consistent default behaviour explicitly applied to all s3.Bucket resources.

This should almost certainly match S3's new defaults, so should set:

blockPublicAccess.BlockPublicAccess.BLOCK_ALL,
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,

In other words:

new s3.Bucket(this, 'MyBucket');

would produce an L1 like

new s3.CfnBucket(this, 'MyBucket', {
    // ...
    publicAccessBlockConfiguration: {
        blockPublicAcls: true,
        blockPublicPolicy: true,
        ignorePublicAcls: true,
        restrictPublicBuckets: true,
    },
    ownershipControls: {
        rules: [{
            objectOwnership: 'BucketOwnerEnforced',
        }],
    },
});

Enabling this feature flag would mean ensure that all buckets managed by the CDK would have consistent behaviour regardless of creation date.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2

Environment details (OS name and version, etc.)

n/a

@plumdog plumdog added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 17, 2023
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Aug 17, 2023
@indrora indrora added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Aug 17, 2023
@peterwoodworth peterwoodworth added bug This issue is a bug. p1 documentation This is a problem with documentation. and removed p2 feature-request A feature should be added or improved. labels Aug 17, 2023
@peterwoodworth
Copy link
Contributor

Thank you for reporting this, our docstrings are incorrect and need to be updated.

Regarding the feature flag suggestion - I can't figure out exactly what value it provides. To me it seems the feature flag would only explicitly declare this for people who are creating new stacks past the date of changes. People who have already created CDK apps before the date will need to manually add this flag to their app, and if they do this it would cause all buckets to automatically change behavior if no settings are specified, which may be undesired for some buckets.

@paulhcsun
Copy link
Contributor

Hi @plumdog, could you clarify what you mean by the docstrings are incorrect? According to the to links attached to the properties, the current docstrings are up to date with the new defaults being in place for Block Public Access being enabled and ACLs disabled:

  • blockPublicAccess: "...However, users can modify bucket policies, access point policies, or object permissions to allow public access..."
  • objectOwnership: "...Bucket owner enforced (default) – ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket..."

I also agree that a feature flag is not the right fix here. It could be possible to create a tool in cdklabs that can be used to update existing buckets but without changing the code in a users stack it's possible that the old settings will just override the changes when the stack is deployed again.

I'll close this for now as we won't be accepting a feature flag for this fix and if we do create a tool it would not live in aws-cdk, and also the current docuentation appears to be correct and aligns with S3's documentation. Feel free to reopen if you feel the docstrings are indeed incorrect and need to be changed.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. documentation This is a problem with documentation. p1
Projects
None yet
Development

No branches or pull requests

4 participants