Skip to content

fix(s3): add missing safe actions to grantWrite, grantReadWrite and grantPut methods#18494

Merged
mergify[bot] merged 13 commits intoaws:masterfrom
flavioleggio:feature/fix-s3-write-permissions
Jan 25, 2022
Merged

fix(s3): add missing safe actions to grantWrite, grantReadWrite and grantPut methods#18494
mergify[bot] merged 13 commits intoaws:masterfrom
flavioleggio:feature/fix-s3-write-permissions

Conversation

@flavioleggio
Copy link
Copy Markdown
Contributor

In this pull request I try to fix a big behavioral change in the bucket grant methods for write actions. This change was introduced due to security issues as stated in this pull request and substituted the s3:PutObject* action glob pattern with the simple s3:PutObject to exclude the dangerous s3:PutObjectAcl and s3:PutObjectVersionAcl from the equation.

While I agree about the security issues, I think that other useful actions - if safe, obviously - should be added when calling the grantWrite, grantReadWrite and grantPut methods. This pull request adds the following actions:

  • s3:PutObjectLegalHold
  • s3:PutObjectRetention
  • s3:PutObjectTagging
  • s3:PutObjectVersionTagging

I also added the s3:PutObjectVersionAcl action to the grantPutAcl method, along with the existing s3:PutObjectAcl.

I adapted existing unit and integ tests to accept these new actions.

Fixes #13616


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jan 18, 2022

@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Jan 18, 2022
@flavioleggio flavioleggio force-pushed the feature/fix-s3-write-permissions branch from 7c25c6d to f0da7e9 Compare January 19, 2022 09:41
@otaviomacedo
Copy link
Copy Markdown
Contributor

Thanks, @flavioleggio. We got approval from AppSec for this. Can you just resolve the conflicts please?

@flavioleggio flavioleggio force-pushed the feature/fix-s3-write-permissions branch from 0e61d96 to 17b926d Compare January 25, 2022 17:33
@flavioleggio
Copy link
Copy Markdown
Contributor Author

@otaviomacedo done!

@mergify mergify bot dismissed otaviomacedo’s stale review January 25, 2022 20:07

Pull request has been modified.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 25, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: e7d3f86
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 940d043 into aws:master Jan 25, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 25, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@flavioleggio flavioleggio deleted the feature/fix-s3-write-permissions branch January 25, 2022 21:45
LukvonStrom pushed a commit to LukvonStrom/aws-cdk that referenced this pull request Jan 26, 2022
…nd `grantPut` methods (aws#18494)

In this pull request I try to fix a big behavioral change in the bucket grant methods for write actions. This change was introduced due to security issues as stated in [this pull request](aws#12391) and substituted the `s3:PutObject*` action glob pattern with the simple `s3:PutObject` to exclude the dangerous `s3:PutObjectAcl` and `s3:PutObjectVersionAcl` from the equation.

While I agree about the security issues, I think that other useful actions - if safe, obviously - should be added when calling the `grantWrite`, `grantReadWrite` and `grantPut` methods. This pull request adds the following actions:
* s3:PutObjectLegalHold
* s3:PutObjectRetention
* s3:PutObjectTagging
* s3:PutObjectVersionTagging

I also added the `s3:PutObjectVersionAcl` action to the `grantPutAcl` method, along with the existing `s3:PutObjectAcl`.

I adapted existing unit and integ tests to accept these new actions.

Fixes aws#13616

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…nd `grantPut` methods (aws#18494)

In this pull request I try to fix a big behavioral change in the bucket grant methods for write actions. This change was introduced due to security issues as stated in [this pull request](aws#12391) and substituted the `s3:PutObject*` action glob pattern with the simple `s3:PutObject` to exclude the dangerous `s3:PutObjectAcl` and `s3:PutObjectVersionAcl` from the equation.

While I agree about the security issues, I think that other useful actions - if safe, obviously - should be added when calling the `grantWrite`, `grantReadWrite` and `grantPut` methods. This pull request adds the following actions:
* s3:PutObjectLegalHold
* s3:PutObjectRetention
* s3:PutObjectTagging
* s3:PutObjectVersionTagging

I also added the `s3:PutObjectVersionAcl` action to the `grantPutAcl` method, along with the existing `s3:PutObjectAcl`.

I adapted existing unit and integ tests to accept these new actions.

Fixes aws#13616

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@quixoticmonk
Copy link
Copy Markdown

Shouldn't the api docs reflect this change ? https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#grantwbrputidentity-objectskeypattern
States Grants s3:PutObject* and s3:Abort* permissions for this bucket to an IAM principal.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-s3: grantPut not working as advertised

4 participants