Guide · AWS access keys · Updated
Is My AWS Access Key Safe in My Frontend? Upload to S3 Without Exposing AKIA Keys in Lovable, Bolt and v0 Apps
You asked your AI builder for photo or file uploads. It picked Amazon S3, asked for your AWS keys, and made it work. The catch: to work in the browser, the keys often end up in your public JavaScript. Then anyone can copy them and use your AWS account. Here is how to tell, the safe way to do uploads, and what to do if your key is already out.
1. Why an AWS key in the browser is a big deal
An AWS access key has two parts: an access key ID that starts with AKIA and a secret access key. Together they let a program act as you on AWS.
- AWS says: do not put access keys or credential information in your application files.
- AWS also says: IAM users with access keys are an account security risk, and giving your keys away can give someone permanent access to your account.
- There is no browser-safe AWS secret. Unlike a Stripe
pk_key or a Supabase anon key, an AWS secret key is never meant to be public.
What a stranger can do depends on what the key is allowed to do. A key made for "just uploads" is often given full S3 access, or even admin access, because that was quickest to get working.
2. How vibe-coded apps leak it
- The S3 client runs in the browser. The AI writes
new S3Client({ credentials: { accessKeyId, secretAccessKey } })inside a React component, so the upload works with no server. - The keys sit in a public env var.
VITE_AWS_SECRET_ACCESS_KEYorNEXT_PUBLIC_AWS_SECRETlook private, but those prefixes mean "put this in the browser bundle". More in Is NEXT_PUBLIC_ safe for API keys? - You pasted the key into the chat. The builder then wrote it straight into a file.
3. The safe way: presigned upload URLs
A presigned URL is a link that allows one action on one file for a short time. AWS says it lets someone upload to your bucket without having AWS credentials of their own.
- The browser asks your server function: "I want to upload a photo."
- The server function checks the user is signed in, picks the file name, and uses the AWS key (stored as a server secret) to make a presigned
PUTURL that expires in a few minutes. - The browser uploads the file straight to S3 with that URL. Your key never leaves the server.
- Keep the time short. AWS lets SDK-made URLs last up to 7 days. For uploads, minutes is enough.
- Pick the file name on the server. AWS says an upload to a name that already exists replaces that file. Do not let the browser choose the path.
- Add a CORS rule on the bucket that allows
PUTfrom your domain, or the browser will block the upload. - Give the key only what it needs, like
s3:PutObjecton one folder of one bucket. AWS also suggests short-lived credentials (roles) over long-term keys where you can.
Need AWS calls right in the browser? AWS recommends Amazon Cognito identity pools, which give each visitor short-lived credentials. Then the role's permissions are what matter, so keep them small.
Sources: AWS S3: Download and upload objects with presigned URLs · AWS S3: Uploading objects with presigned URLs · AWS S3: CORS · AWS SDK for JavaScript: Use Amazon Cognito Identity
4. Where the key goes in Lovable, Bolt and v0
- Lovable: store
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYas backend secrets and make the presigned URL in an Edge Function. Never in aVITE_variable. - Bolt and other Supabase apps: same idea, as Supabase Edge Function secrets.
- v0, Cursor and other Next.js apps: a Route Handler or Server Action that reads
process.env.AWS_SECRET_ACCESS_KEY(noNEXT_PUBLIC_). - Only need simple file storage? If your app already uses Supabase, Supabase Storage may do the job without AWS keys. Check its bucket settings: Is my Supabase bucket public?
Sources: Lovable: Secrets · Supabase: Edge Function secrets
5. Check your live app in 60 seconds
Only check apps you own or have permission to test.
- Fastest: paste your live link at the top of this page. VibeCheck reads your homepage and the JavaScript files it loads and flags AWS key IDs (
AKIAorASIA), masked. - By hand in Chrome: open your live site, right-click → Inspect, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search for
AKIA,secretAccessKeyandaccessKeyId. - Go to your upload page and upload a test file, then search again. Some code only loads there.
- Read what you found. An
AKIAID inside a link that also hasX-Amz-Signatureis a presigned URL and is fine. AnAKIAID next to a long secret key is a leak.
What VibeCheck can and cannot see: it finds key IDs (and often the secret next to them) in your public code. It never uses the key, cannot see your AWS account or what the key is allowed to do, and only reads the JavaScript your homepage loads, not every page.
6. Key already public? Do this now
- Deactivate the key. IAM console → Users → your user → Security credentials → Make inactive. AWS says to do this first if you think a key is compromised.
- See what it did. Look in CloudTrail for calls made with that key. Check for IAM users, roles and policies you did not make, new EC2 servers, and S3 bucket policy changes.
- Check your bill for cost spikes.
- See a policy called AWSCompromisedKeyQuarantineV3 (or V2)? AWS adds it when it finds a key in public. Leave it on until you are done. AWS says removing it early can affect help you get for the incident.
- Fix the app, then make a new key. Move the AWS calls to the server (prompt 1 below), store the new key as a secret, redeploy, then delete the old key.
More for every key type: I leaked my API key. What do I do now?
Sources: AWS re:Post: Manage IAM access keys securely · AWS: AWSCompromisedKeyQuarantineV3
7. Copy-paste fix prompts
Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. Your builder cannot change your AWS account, so deactivate and replace leaked keys yourself.
Find every place in this project that imports @aws-sdk or aws-sdk, creates an S3Client, or uses accessKeyId / secretAccessKey, including VITE_ and NEXT_PUBLIC_ variables. Remove all AWS credentials from frontend code. Create one server function (Supabase Edge Function, or a Next.js Route Handler) that reads AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from server-only secrets, checks the user is signed in, picks the file name on the server (for example uploads/<user id>/<random id>), allows only the file types and size my app needs, and returns a presigned PUT URL that expires in 5 minutes. Update the upload form to ask this function for the URL and then PUT the file to S3 with it. Show me every file you changed and tell me which old keys I need to deactivate in AWS.
My app only needs to upload files to one S3 bucket. Write me an IAM policy for a new IAM user (or role) that allows only s3:PutObject (and s3:GetObject if my app shows the files) on arn:aws:s3:::MY-BUCKET/uploads/* and nothing else. Explain where to attach it in the IAM console. Do not use AdministratorAccess or s3:*.
My browser uploads to S3 with presigned PUT URLs. Write the CORS configuration JSON for my bucket that allows PUT and GET only from https://MY-DOMAIN.com (and my preview domain), allows the Content-Type header, and nothing else. Tell me where to paste it in the S3 console (bucket, Permissions, Cross-origin resource sharing).
8. Check it for me
Paste your link into VibeCheck. In about 10 seconds it checks the JavaScript your live site sends to visitors for leaked keys (AWS AKIA, OpenAI, Stripe sk_live_, Supabase service_role and more), checks if your public Supabase key can read open tables, and checks security headers, SEO basics and broken links.
It is a public, read-only check from the outside. It never asks for your code, your login or your AWS account.
Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.
No tool can promise your app is 100% secure. VibeCheck catches common, costly mistakes before a stranger does.
9. FAQ
Is it safe to put my AWS access key in my React or Vite app?
No. AWS access keys are long-term passwords for your AWS account. Anything in your frontend code, including VITE_ and NEXT_PUBLIC_ variables, is sent to every visitor. Anyone can open DevTools, copy the key and secret, and use AWS as you, up to whatever that key is allowed to do. AWS says not to put access keys in your application files. Keep them in a server function and send the browser a short-lived presigned URL instead.
How do I upload files to S3 from the browser without exposing my keys?
Use a presigned URL. Your server function, which holds the AWS key as a secret, creates a URL that allows one upload (PUT) to one file name for a short time. The browser uploads straight to S3 with that URL and never sees your key. AWS says a presigned URL lets someone upload without having AWS credentials of their own. Add a CORS rule on the bucket so your domain can send the PUT.
Is the AKIA key ID alone a problem?
The access key ID (AKIA...) needs its secret access key to sign requests. The ID alone cannot do much, and it is even part of every presigned URL. But if your code has the ID, the secret is often right next to it, under a name like secretAccessKey. Treat it as leaked until you have checked.
What happens if AWS finds my key in public?
AWS may attach a managed policy called AWSCompromisedKeyQuarantineV3 (or V2) to the user. It blocks many risky actions to limit fraud. AWS says not to remove it until you have finished cleaning up. You may also get an email or support case from AWS. Do not wait for that: if your key was ever in your frontend, deactivate it now.
My key leaked. What do I do first?
In the IAM console, open the user, go to Security credentials and make the key inactive. Then check CloudTrail for what the key did, look for users, roles, servers and bucket changes you did not make, and check your bill. Move the AWS calls to a server function with a new key, test, then delete the old key.
How do I check if my live app shows an AWS key?
Paste your live link into VibeCheck for a free scan. It reads your homepage and the JavaScript files it loads and flags AWS access key IDs (AKIA or ASIA), masked. It may also flag the secret key next to it as a possible secret. It never uses the key and cannot see your AWS account. By hand: open DevTools, press Ctrl+Shift+F (Cmd+Option+F on Mac) and search for AKIA and secretAccessKey.
More questions? See the VibeCheck FAQ. Related guides: How to check if your API key is exposed · I leaked my API key. What do I do now? · Is NEXT_PUBLIC_ safe for API keys? · Is my OpenAI key safe? · Is my Supabase bucket public? · Is my Lovable app safe? · Is my Bolt app secure? · Is my v0 app secure? · Vibe coding security checklist.