Git Product home page Git Product logo

Comments (5)

simonw avatar simonw commented on August 19, 2024

The linked documentation says "By default, new buckets, access points, and objects do not allow public access" - which would explain why my testing has shown that buckets created by this tool do not enable public access.

Maybe there's an issue where buckets created before a certain date were public by default? Or AWS accounts created before a specific date have their buckets created public by default?

My goal with this tool is that buckets should be created to NOT be public by default, which seems to be how it is working in my testing - but are there other AWS accounts out there for which this tool would accidentally create public buckets?

Here's my bucket creation code:

# Create bucket if it doesn't exist
if not bucket_exists(s3, bucket):
if not create_bucket:
raise click.ClickException(
"Bucket does not exist: {} - try --create-bucket to create it".format(
bucket
)
)
if create_bucket:
kwargs = {}
if bucket_region:
kwargs = {
"CreateBucketConfiguration": {
"LocationConstraint": bucket_region
}
}
s3.create_bucket(Bucket=bucket, **kwargs)

There's a StackOverflow answer here which suggests the following code: https://stackoverflow.com/a/62769484/6083

s3_bucket = s3_client.create_bucket(
    Bucket=bucket_name,
    CreateBucketConfiguration={"LocationConstraint": "eu-west-1"}
)
response_public = s3_client.put_public_access_block(
    Bucket=bucket_name,
    PublicAccessBlockConfiguration={
        "BlockPublicAcls": True,
        "IgnorePublicAcls": True,
        "BlockPublicPolicy": True,
        "RestrictPublicBuckets": True,
    },
)

from s3-credentials.

simonw avatar simonw commented on August 19, 2024

This page helped me understand what these options do: https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html

The Amazon S3 Block Public Access feature provides settings for access points, buckets, and accounts to help you manage public access to Amazon S3 resources. By default, new buckets, access points, and objects don't allow public access. However, users can modify bucket policies, access point policies, or object permissions to allow public access. S3 Block Public Access settings override these policies and permissions so that you can limit public access to these resources.

With S3 Block Public Access, account administrators and bucket owners can easily set up centralized controls to limit public access to their Amazon S3 resources that are enforced regardless of how the resources are created.

So if I set PublicAccessBlockConfiguration against an S3 bucket that is created with the tool it provides defense in depth against some other configuration change making objects in that bucket public in some way.

from s3-credentials.

simonw avatar simonw commented on August 19, 2024

I'm going to apply those blocks by default unless the user passes a --enable-public-access option.

from s3-credentials.

simonw avatar simonw commented on August 19, 2024

It looks like things have changed in S3 world, and creating a bucket that has public access is actually really difficult these days. The buckets created by this tool are absolutely not public.

I still want to add PublicAccessBlockConfiguration though, as further defense in depth.

from s3-credentials.

simonw avatar simonw commented on August 19, 2024

This is obsoleted by:

from s3-credentials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.