S3 security: bucket policies, access points & presigned URLs
Grant exactly the access a scenario requires and nothing more.
By Invicly Tech, , in AWS Solutions Architect – Associate. About 12 minutes to read.
In short
S3 access is controlled by IAM policies, bucket policies and Block Public Access, with ACLs disabled by default. Access points give each application its own policy and endpoint on a shared bucket. Presigned URLs grant time-limited access to one object without sharing credentials.
Explained simply
Every S3 bucket starts private. Only the account that owns it, and the users and roles that account allows, can read or write. Most S3 data leaks happen because someone opened a bucket on purpose to share one file and then forgot about it.
There are two main places to write permissions. An IAM policy is attached to a user or role and says what that identity may do. A bucket policy is attached to the bucket and says who may use it, which is also how you let other AWS accounts in. Both are JSON documents with Effect, Action, Resource and sometimes a Condition.
Block Public Access is a safety switch on top of all policies. When it is on, S3 refuses any policy or ACL that would make data public. It is on by default for new buckets, and you can also turn it on for the whole account so nobody can make that mistake later.
Sometimes you must share one private file with someone who has no AWS login, like a customer downloading an invoice. A presigned URL is a link with a signature and an expiry time built in. Anyone with the link can do that one action, on that one object, until it expires.
Big shared buckets end up with long, messy policies. An access point is a named door into a bucket with its own policy. Each team or app gets its own door with a short set of rules, and the bucket policy stays simple.
Press Play on a diagram to walk through it one step at a time.
- User browser to App server: Request a private file1Request a private file
- 2Check user, sign URL with roleApp server to App server: Check user, sign URL with role
- App server to User browser: Return presigned URL3Return presigned URL
- User browser to Amazon S3: GET object with signature4GET object with signature
- Amazon S3 to User browser: Object if signature valid5Object if signature valid
- One object, one action
- Expires after minutes or hours
- Receiver needs no AWS account
- Limited by the signer's permissions
- Other AWS accounts or the whole org
- Long-term access
- Conditions like VPC endpoint or TLS
- Public websites and downloads
- Bucket stays private
- Caching and HTTPS at the edge
- Browser to App API: I want to upload avatar.png1I want to upload avatar.png
- 2Check login, choose key users/42/avatar.pngApp API to App API: Check login, choose key users/42/avatar.png
- App API to Browser: Presigned PUT URL, valid 5 minutes3Presigned PUT URL, valid 5 minutes
- Browser to Amazon S3: PUT the file directly4PUT the file directly
- Amazon S3 to Browser: 200 OK5200 OK
- Browser to App API: Upload finished, save the key6Upload finished, save the key
In depth
How S3 decides allow or deny
S3 looks at every policy that applies to a request. An explicit Deny anywhere always wins. Inside one account, an Allow in either the IAM policy or the bucket policy is enough. Across accounts, both sides must agree: the bucket policy must allow the other account, and that account's IAM policy must allow its user or role.
On top of that come guardrails. Block Public Access can override public grants. Service Control Policies (SCPs) in AWS Organizations cap what an account may do. If the object is encrypted with SSE-KMS, the KMS key policy must also let the caller use the key. A common surprise: a user with s3:GetObject still gets Access Denied because nobody allowed kms:Decrypt on the key.
- 1Collect policies
IAM, bucket, access point, SCP, KMS key
- 2Explicit Deny?
If any policy denies, the request fails
- 3Guardrails pass?
SCPs and Block Public Access allow it
- 4Grant found?
Same account: IAM or bucket policy. Cross-account: both
- 5Key usable?
SSE-KMS objects also need kms:Decrypt
- 6Allowed
With no Allow, the default is deny
Bucket policy patterns you will reuse
Many real bucket policies are Deny statements with conditions, because a Deny protects the bucket no matter what IAM policies say. Useful condition keys: aws:SecureTransport to force HTTPS, aws:SourceVpce to allow access only through one VPC endpoint, aws:PrincipalOrgID to let in every account of your organization without listing them, and s3:x-amz-server-side-encryption-aws-kms-key-id to require a specific KMS key on uploads.
Watch the Resource. Bucket-level actions such as s3:ListBucket use arn:aws:s3:::bucket, while object actions such as s3:GetObject use arn:aws:s3:::bucket/*. Mixing them up gives an Access Denied that looks mysterious. Be careful with a Deny on aws:SourceVpce: it also blocks the console and your own admins unless you add an exception for them.
- Force HTTPS: Deny when aws:SecureTransport is false
- VPC only: Deny when aws:SourceVpce is not your endpoint
- Whole organization: Allow with aws:PrincipalOrgID
- s3:ListBucket on the bucket ARN, s3:GetObject on bucket/*
Block Public Access and Object Ownership
Block Public Access has four settings. BlockPublicAcls rejects new public ACLs. IgnorePublicAcls ignores public ACLs that already exist. BlockPublicPolicy rejects bucket policies that grant public access. RestrictPublicBuckets limits a bucket that already has a public policy to AWS services and users in the owner's account. Set all four at account level and every bucket is covered, including ones created later.
ACLs (access control lists) are the old permission system from before IAM. Since April 2023, new buckets use the Object Ownership setting Bucket owner enforced, which turns ACLs off completely: the bucket owner owns every object, even objects uploaded by other accounts, and only policies decide access. Keep it that way unless an old tool really needs ACLs. For a public website, keep the bucket private and serve it through CloudFront with origin access control (OAC).
Access points for shared buckets
A data lake bucket used by 20 teams can end up with a bucket policy near its 20 KB size limit. Access points split it up. Each access point has its own name, ARN, hostname and policy. Team A reads through finance-ap, the ingest job writes through ingest-ap, and each policy stays short.
An access point can be limited to one VPC, so requests from the internet are refused even with valid credentials. The usual setup is to delegate access control from the bucket to its access points with one bucket policy statement that uses the condition s3:DataAccessPointAccount. Apps then use the access point ARN or alias wherever they would use a bucket name. Multi-Region Access Points go a step further: one global endpoint that routes requests to buckets in several Regions.
- finance-ap
- Read finance/*
- Finance role only
- ingest-ap
- Write raw/*
- Network origin: one VPC
- analytics-ap
- Read curated/*
- Analytics team role
- Bucket policy
- Delegates to access points
- Denies requests without TLS
Presigned URLs: limits and gotchas
A presigned URL is signed with the credentials of whoever created it, so it can never do more than that identity is allowed to do. If the signer loses the permission, the link stops working. The expiry is also capped: up to 7 days when signed with IAM user keys, and never longer than the session when signed with temporary role credentials. A URL signed inside a Lambda function stops working when that role session expires, even if you asked for 7 days.
For downloads use a GET URL. For browser uploads use a presigned PUT, or a presigned POST, which can add rules such as a maximum file size and a fixed key prefix. Anyone who has the link can use it until it expires, so keep the expiry short. For many files or a whole site, CloudFront signed URLs or signed cookies scale better.
Learn it in 4 short steps
About 30m each. Track them with a timer in your plan.
- 1Write a bucket policy~30m
- 2Block public access correctly~30m
- 3Create access points for shared buckets~30m
- 4Generate presigned URLs~30m
Key points
- Block Public Access is on by default for new buckets; leave it on unless truly public.
- Bucket policies can enforce TLS, encryption or access only from a VPC endpoint.
- A presigned URL carries the signer's permissions and expires after a set time.
- Use CloudFront with origin access control for public websites instead of public buckets.
Key terms
Tap a card to flip it. 0/5 known
Examples
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
"Condition": {"Bool": {"aws:SecureTransport": "false"}}
}]
}Bucket policy that rejects any request not using HTTPS.
Lock a bucket to one VPC endpoint
An internal reports bucket must only be reachable from the company VPC. Step 1: create an S3 gateway endpoint in the VPC and note its ID. Step 2: add a bucket policy that denies every request that does not come through that endpoint. Step 3: add an exception for the Admin role, or you lock yourself out of the console. Both conditions sit in one block, so they are combined with AND: the Deny applies only when the request is not from the endpoint and not from Admin.
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "OnlyFromVpce",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::reports-bkt", "arn:aws:s3:::reports-bkt/*"],
"Condition": {
"StringNotEquals": {"aws:SourceVpce": "vpce-0a1b2c3d4e5f67890"},
"ArnNotLike": {"aws:PrincipalArn": "arn:aws:iam::111122223333:role/Admin"}
}
}]
}Give a partner account read access to one prefix
Partner account 444455556666 must read files under exports/ and nothing else. Step 1: in your bucket policy, allow that account s3:GetObject on exports/* and s3:ListBucket only for the exports/ prefix. Step 2: the partner's admin must also give their own role an IAM policy for the same actions, because cross-account access needs both sides. Step 3: if the objects use SSE-KMS with your key, add the partner to the key policy with kms:Decrypt.
{
"Version": "2012-10-17",
"Statement": [
{"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::444455556666:root"},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::exports-bkt/exports/*"},
{"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::444455556666:root"},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::exports-bkt",
"Condition": {"StringLike": {"s3:prefix": "exports/*"}}}
]
}Quick reference
- aws s3 presign s3://bkt/key --expires-in 900 makes a 15-minute link (default is 3600 s)
- Presigned URL max: 7 days with IAM user keys; never longer than the role session
- Turn on Block Public Access at account level so buckets created later are covered too
- Cross-account access needs both the bucket policy and the caller's IAM policy to allow it
- s3:ListBucket uses arn:aws:s3:::bkt; s3:GetObject uses arn:aws:s3:::bkt/*
- SSE-KMS objects also need kms:Decrypt, or reads fail with Access Denied
- Bucket policy size limit is 20 KB; split large ones with access points
- Public website: private bucket plus CloudFront with origin access control (OAC)
Common mistakes
- Making a bucket public to share one file; use a presigned URL.
- Writing the bucket ARN without /* and so missing object-level actions.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Create a presigned download link for a private object that expires in 10 minutes. Open it, then try again after it expires.
- Exercise 2medium
Write a Python script with boto3 that creates a presigned PUT URL valid for 5 minutes, then uploads a file to it with the requests library.
- Exercise 3hard
Create a VPC-only access point for your app and delegate the bucket's access control to access points, so the bucket policy stays one short statement.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Are S3 buckets public by default?
- No. New buckets have Block Public Access turned on and ACLs disabled, so they stay private until someone deliberately changes both a setting and a policy.
- What is the difference between a bucket policy and an IAM policy?
- An IAM policy is attached to a user or role and travels with that identity. A bucket policy is attached to the bucket, names who may use it, and is how you grant access to other accounts.
- Can someone reuse a presigned URL?
- Yes. Anyone who has the link can use it as many times as they like until it expires, so treat it like a short-lived password.
- Should I still use S3 ACLs?
- Almost never. AWS recommends keeping ACLs disabled and controlling access with policies; ACLs remain only for a few legacy cases.