mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
* fix(s3): enforce auth on bucket-level config writes when enforce-auth is enabled With FLOCI_SERVICES_S3_ENFORCE_AUTH=true, unsigned object reads are refused unless a policy or ACL makes them public, and since #2326 unsigned object writes are refused the same way. Bucket management was never covered: CreateBucket, DeleteBucket, and every PUT/DELETE on a bucket subresource (?policy, ?acl, ?cors, ?lifecycle, ?versioning, ?website, ?notification, ?logging, ?encryption, ?publicAccessBlock, ?ownershipControls, ?requestPayment, ?tagging, ?accelerate, ?replication, ?object-lock, ?metrics) behaved identically with the flag on or off. An anonymous caller could PUT ?policy a public-read grant onto any bucket and then read what the previous request had correctly refused. Authorization in S3Controller is opt-in per branch, and only the three newest subresources called authorizeBucketWrite. createBucket and deleteBucket now parse the request's credentials once and check every branch against the bucket's policy with the matching s3:* action before the mutator runs, and s3:DeleteBucket before the bare delete. CreateBucket gets its own authorizeCreateBucket: there is no policy to consult and AWS never accepts it anonymously, so an unsigned request is AccessDenied and a signed one must carry a known key; authorizeBucketWrite would have answered NoSuchBucket, the wrong code and an existence oracle. Nothing changes with the flag off. With it on, anonymous bucket management now fails with 403, as it does on AWS. The enforce-auth tests created their buckets and policies anonymously, which was this bug running green; those 38 setup calls now sign with the class's legacy key, and four new tests pin CreateBucket/DeleteBucket, the policy-rewrite exploit, every subresource, and the policy-granted anonymous case. Closes #2335 * fix(s3): never let a bucket policy grant PutBucketPolicy or DeleteBucketPolicy anonymously AWS lets only an identity in the bucket owner's account manage the bucket policy, so the policy itself can never grant s3:PutBucketPolicy or s3:DeleteBucketPolicy to an anonymous caller. authorizeBucketWrite honoured a Principal "*" grant for those two actions like any other, which would have let an unsigned caller rewrite or delete a policy that named them. Refuse them before consulting the policy, and pin it with a test that installs a self-granting policy and checks anonymous PUT and DELETE ?policy are still AccessDenied and the policy survives. Raised in review on #3536.