AWS for developers · mid
Safe S3 access: presigned URLs, public buckets and leaked keys
A presigned URL is a bearer token, a public bucket is a data leak, and a key in an app is public. Check ownership on the server, keep Block Public Access on and use roles.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Never take a storage key from the query string. Look up the file by id with a user filter and build the key on the server. Otherwise any logged-in user can fetch anyone's file by changing the name.
- A presigned URL is a bearer token: whoever has it can use it until it expires, with the signer's permissions. Keep the expiry short (minutes) and make a new link on each click.
- With role credentials the URL stops working when the role session ends, even if you asked for seven days. Seven days is the maximum only with an IAM user's long-term key under SigV4.
- Do not log full presigned URLs, because the signature is in them.
- A bucket made public to fix broken images: contain first. Turn Block Public Access back on (bucket and account) and remove the public policy. Keep everything else as evidence.
- A policy with Principal * and s3:GetObject plus s3:ListBucket on the whole bucket lets anyone list and read every prefix. Investigate with CloudTrail management events (PutPublicAccessBlock, PutBucketPolicy) and IAM Access Analyzer. Without data events or access logs you cannot prove what was not downloaded, so treat every sensitive file as exposed.
- For images, serve through CloudFront with Origin Access Control, so the bucket stays private.
- AWS keys inside an Android app or a public repository are public. First read the key's permissions and look for misuse, then cut its power at once (a policy that allows only s3:PutObject on one prefix), and ship an update that uses a safe upload flow, such as a presigned URL from your backend.
- Installed apps keep the old key forever, so raise the minimum supported version, then deactivate the key on an announced date.
The red pen
Common traps: mistake → fix
Mistake: A presigned URL is private because it is long and random
Fix: Anyone who has the URL can use it until it expires.
Mistake: Making the bucket public is the fastest safe fix for images
Fix: It exposes everything in it. Use CloudFront with OAC.
Mistake: I can hide the AWS key in the app code
Fix: An APK is easy to unpack. Never ship keys.
Easy to hard
Questions interviewers ask, easy to hard
- How do you let a user download only their own invoice from S3?
- How long does a presigned URL stay valid, and what limits it?
- A bucket was made public to fix images. What do you do first?
- AWS keys were found in an Android app. What do you do now and later?
- How would you design uploads from a mobile app without keys in the app?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.