Skip to content

S3: PutObject and CreateBucket ignore x-amz-acl, so BlockPublicAcls cannot be enforced on them #470

Closed

Description

@scttfrdmn

Follow-up from #458, which enforced BlockPublicAcls on PutBucketAcl and PutObjectAcl only.

The gap

Real BlockPublicAcls rejects four operations, per the S3 user guide's Block public access settings table:

  • PUT Bucket ACL
  • PUT Object ACL
  • PUT Object with a public ACL
  • PUT Bucket (CreateBucket) with a public ACL

#458 covers the first two. The other two are not covered because neither handler reads x-amz-acl at all — putObject and createBucket in emulator/s3_plugin.go ignore the header entirely, so there is no ACL for a check to inspect. A consumer whose upload path sets x-amz-acl: public-read on the object gets a 200 from substrate on a bucket that real S3 would refuse.

The same gap has a second consequence independent of Block Public Access: an object uploaded with x-amz-acl: public-read reports the default owner-only ACL from GetObjectAcl, because the header was dropped. So the ACL substrate reports is not the one the caller set.

What closing this needs

ACL-on-create modelled first: putObject and createBucket resolving x-amz-acl (and the x-amz-grant-* headers — see below) into a stored ACL, after which the existing s3PublicACLDenied helper from #458 wires in unchanged.

Note also that x-amz-grant-read, -write, -read-acp, -write-acp and -full-control are parsed nowhere but #458's public-access check. An ACL set through them is not stored by any operation, including PutBucketAcl/PutObjectAcl. That is worth folding into the same change, since the grantee-list parsing already exists in emulator/s3_publicaccess.go.

Acceptance criteria

  • PutObject and CreateBucket resolve x-amz-acl into a stored ACL, readable back through GetObjectAcl / GetBucketAcl
  • x-amz-grant-* headers resolve into stored grants on all four operations that accept them
  • PutObject with a public ACL on a bucket with BlockPublicAcls set returns 403 AccessDenied, and the object is not stored
  • CreateBucket with a public ACL is refused when the account-level equivalent would refuse it, or the account-level gap is documented as out of scope (substrate models no account-level BPA)
  • The S3: Block Public Access settings are recorded but not enforced #458 tests still pass unchanged
  • docs/services.md — the "not yet refused" paragraph under Block Public Access is replaced

Activity

  1. added
    type: feature
    area: s3
    on Aug 2, 2026
  2. modified the milestones: v0.86.0, v0.87.0 on Aug 2, 2026
  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in 6fe0f47 (#509), in v0.87.0 — and your fourth criterion is answered by taking its second branch, explicitly.

    ACL-on-create first, then #458's check wires in unchanged. putObject and createBucket now resolve X-Amz-Acl through the existing s3CannedACL and persist to the same keys getObjectAcl/getBucketAcl read. So the first consequence you name is fixed independently of Block Public Access: PutObject --acl public-read followed by GetObjectAcl now reports the grant that was set, where before it reported the wrong ACL entirely. With the ACL stored, s3PublicACLDenied — which already took the bucket, the ACL and the headers — needed no change: PutObject --acl public-read on a bucket with BlockPublicAcls is now 403 AccessDenied, and the object is not stored (checked before the write, the same all-or-nothing property #468 established on the EC2 side, and asserted with a subsequent 404).

    The grant-header gap is wider than your title suggests, and worth naming. s3GrantHeadersArePublic already parsed the x-amz-grant-* grantee lists for #458's check, but nothing stored them — including PutBucketAcl. So an ACL set through grants rather than a canned name was stored by no operation at all. There is now an s3GrantsFromHeaders beside that parser, applied on all four operations that accept the family, so x-amz-grant-full-control on PutBucketAcl is stored too. That is new behaviour outside what you reported, and the CHANGELOG says so.

    Your fourth criterion: the account-level gap is documented as out of scope. You offered a fork — refuse CreateBucket with a public ACL when the account-level equivalent would refuse it, or document the account-level gap. Taking the second, because substrate models no account-level Block Public Access at all, and inventing one solely to gate CreateBucket would mean modelling a control the emulator does not otherwise have and that no other operation would consult. The reason CreateBucket is the awkward case is structural: a bucket-level BPA configuration cannot exist before the bucket does, so CreateBucket is only refusable at the account level. docs/services.md states that rather than leaving the criterion ambiguously half met. If account-level BPA is worth modelling, it should be modelled for every operation at once, not conjured for one.

    The #458 tests pass unchanged, which was your own criterion, and --acl private and no header still produce owner-only.

  4. added a commit that references this issue on Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: s3fidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions