mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
* fix(iam): authorize S3 Control routes as their own s3 actions S3 Control clients sign with the s3 scope, so under IAM enforcement its /v20180820 routes fell through to the S3 data-plane rules and were checked as s3:GetObject, PutObject or DeleteObject on a bucket named v20180820, which no policy can name: a role allowed s3:ListTagsForResource on a bucket was denied its tag list, and Terraform's AWS provider, which reads bucket tags through S3 Control, never fell back to GetBucketTagging, leaving aws_s3_bucket unrefreshable. Map the routes to the actions the Service Authorization Reference gives them: ListTagsForResource, TagResource and UntagResource are checked against the ARN the route names, as written and decoded as the handler decodes it; ListAccessPoints and the account-level Block Public Access, to which the S3 User Guide gives no resource, against every bucket in the request's partition; the account control takes the PutAccountPublicAccessBlock and GetAccountPublicAccessBlock actions. A data-plane operation under the same prefix keeps its own bucket-and-object ARN. A denial now answers in S3 Control's own ErrorResponse envelope, the only one the s3control SDK deserializers read, so the message naming the missing action survives to the client. Closes #6537 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(iam): answer the three control-route gaps the review found A tagging query on a control route still reached the data-plane override, so GET /v20180820/tags/<arn>?tagging was checked as s3:GetObjectTagging while the handler read the bucket's tags: the control rules now match before the query overrides, and a caller holding only the object action is denied where one holding the control action passes. A tagging ARN in the regional form was rewritten to the global form downstream and its bucket misread, so a policy naming the regional form the API reference requires was denied; the provider now keeps a control tagging ARN as written and reads the bucket it names. The account actions returned arn:<partition>:s3:::*, which a bucket-scoped statement matches; they now return the literal wildcard, so a bucket-scoped statement grants no account-wide action, the convention the KMS no-resource actions follow. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(iam): drive S3 Control route authorization from AWS's own data The s3control model is vendored in rest-routes.json, regen_rest_routes carries it under the s3 scope, as s3control signs with s3, and IamRestRouteCoverageTest checks every S3 Control route Floci serves against the Service Reference. The hand-written S3_CONTROL_RULES and S3_CONTROL_ACTIONS lists are gone: the control routes are entries of the one rules table, flagged to match before the S3 data-plane query overrides so ?tagging on a tagging route cannot re-point the authorization, and a denial answers in S3 Control's ErrorResponse envelope by following the route instead of an action-name list. The account-level Block Public Access is the one written-down exception, as the reference files S3's and S3 Control's Get, Put and DeletePublicAccessBlock under the bucket actions and the Block Public Access page gives the account level its own actions. A tagging ARN is read once, by the handler, the IAM check and the bucket-policy lookup together: S3ControlArnUtils decodes and parses it with AwsArnUtils.parse, and the regional form's account is the account whose bucket the request acts on, so a grant on arn:aws:s3:us-east-1:222222222222:bucket/reports no longer lets a caller in 111111111111 read and change the tags of its own same-named bucket: it reads and writes 222222222222's bucket, and answers NoSuchBucket when that account holds no bucket of the name. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(s3): read the policy provider's ARNs without decoding them The provider received every ARN already decoded, the data plane's from the request path and a control tagging one re-minted by the rule that read it off the wire, but the one-parse helper decoded again, so an object key carrying a plus sign or a literal percent sequence changed its bytes before IAM checked it: a policy on arn:aws:s3:::example/a+b.txt denied the very object it named. The provider parses without decoding now; the wire decode stays where it belongs, at the control request boundary. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>