Vibe Coding Security 101: 31 Tips to Keep Your AI-Coded Apps Safe
The complete guide to building secure AI-powered apps. 31 essential security tips every vibe coder needs to know.
Vibe Coding Security 101: The Complete Guide to Building Safe AI-Powered Apps
Vibe coding is fast. Itâs magical. You can go from idea to working app in minutes using AI tools like Claude, Cursor, and Bolt. But hereâs the truth no one talks about enough: speed without security is reckless.
Iâve built a ton of apps using AI-powered development, and Iâve made (and seen) just about every security mistake in the book. This guide compiles everything Iâve learned into 31 actionable tips that will keep your vibe-coded projects safe from hackers, costly mistakes, and business-ending disasters.
Whether youâre just getting started with vibe coding or youâre already shipping production apps, this oneâs for you. Letâs get into it.
Part 1: The Foundations
These are the foundational security mistakes that will get you hacked if you ignore them. The good news? Each one takes about 2 minutes to fix. Start here.
1. Never Paste Secrets in Chat
AI models learn from data. When you paste real API keys, passwords, or database URLs into ChatGPT or Claude, youâre potentially exposing them. Use placeholders like YOUR_API_KEY in your prompts instead, or ask the AI to write code that pulls secrets from environment variables.
Once a secret is in a chat, youâve lost control of it. Always assume it could be compromised.
2. Beware of âGhostâ Packages
AI sometimes invents libraries that donât exist. Sounds wild, right? But it happens. And hereâs the scary part â hackers create malware with these made-up names hoping youâll install them.
Always verify packages exist before installing. Ask the AI: âShow me the npm or PyPI link for this package.â Check download counts â if itâs suspiciously low, donât use it. Most vulnerabilities come from supply chain attacks like this.
3. Donât Trust Built-In Auth
AI will happily generate a custom login system for you. It will likely have security holes you canât see. Instead of asking âWrite a login page,â tell the AI: âImplement authentication using Clerkâ (or Supabase Auth, NextAuth, Firebase â pick your favorite established provider).
Authentication is where 90% of data breaches start. Donât DIY this one.
4. Always Ask for a Security Review
AI writes code to work, not to be secure. It often skips input validation and error handling entirely. But hereâs the thing â you can use AI to check its own work.
After your code is working, run this prompt: âAct as a Senior Security Engineer. Audit this code for vulnerabilities like SQL injection or XSS and rewrite it to be secure.â
You donât need to spot every vulnerability yourself. Let the AI do the heavy lifting.
5. Sanitize Every Input
AI often writes code that takes user text and puts it directly into the database. This is literally how hackers delete your data.
Explicitly ask: âEnsure all database queries use parameterized queries to prevent SQL injection.â One unsanitized input = total database compromise. Itâs that simple.
6. Master the .gitignore
Vibe coders move fast and often accidentally upload .env files with secrets to GitHub. Bots scan for exposed keys on GitHub 24/7 â Iâm not exaggerating.
Ask the AI: âGenerate a comprehensive .gitignore file for this [Next.js/Python] project that excludes all environment files and system logs.â Do this before your first commit.
7. Only Use Current Packages
AI training data has a cutoff date. It might suggest an old version of a library with known security holes. When installing packages, ask the AI: âAre there newer, more secure versions of these libraries I should use?â or run npm audit to check.
Outdated packages = known security holes that attackers already know how to exploit.
8. Add Rate Limiting Day One
If you vibe code a contact form or API endpoint and donât add rate limiting, bots will find it and spam you with thousands of requests. Itâs not a question of if â itâs when.
Always ask the AI to âAdd rate limiting to this API routeâ so one person canât hit it 1,000 times a second. Without limits, bots can shut you down or rack up your API costs.
9. Ask AI to Hack You (Seriously)
You donât know what you donât know about security. But AI does. Paste your code and ask: âIf you were a hacker, how would you break this specific function? Tell me the exploit and the fix.â
AI knows attack patterns. Use that knowledge defensively. This is one of my favorite tricks.
10. Enable RLS from Day 0
By default, databases let anyone see everything. AI often skips Row Level Security (RLS) setup entirely. Tell the AI: âSet up Row Level Security policies so users can only see their own data.â
If youâre using Supabase, enable RLS on all tables from day one. And then double-check that it actually happened. This is literally how data leaks occur â someone forgets RLS.
Quick recap: These 10 rules take about 2 minutes each and prevent the vast majority of hacks. Security isnât paranoia â itâs choosing respect for peopleâs data over convenience.
Part 2: The Common Mistakes
Youâve covered the foundations. Now letâs tackle the intermediate security issues that trip up even experienced developers.
11. Donât Leave CORS Wide Open
AI often sets CORS to * (allow all domains). This means hackers can call your API from their malicious site and steal your userâs data through their browser.
Tell the AI: âConfigure CORS to only allow requests from my production domain: myapp.comâ
12. Validate Your Redirects
If your login page has ?redirect=/dashboard, attackers can change it to ?redirect=evil.com/phishing. Open redirects are the #1 way users get phished after logging in.
Ask: âEnsure all redirect URLs are validated against an allowlist before redirecting the user.â
13. Lock Down Your Storage
When you vibe code file uploads, the AI often makes the entire storage bucket public by default. One public bucket = all user files exposed to Google search. Yikes.
In Supabase Storage, set RLS policies. Prompt: âCreate storage policies so users can only access files they uploaded.â
14. Remove Debug Statements
AI loves to add console.log(userData) to help you debug. That data shows up in production browser consoles where anyone with DevTools can see it.
Before deploying, run: âRemove all console.log statements and replace with proper error logging.â
15. Always Verify Webhooks
If you accept Stripe or payment webhooks, anyone can POST fake data to that endpoint. Unverified webhooks = fake âpayment succeededâ messages. Not great for business.
Always âVerify the webhook signature using Stripeâs SDK before processing any payment data.â
16. Check Permissions Server-Side
Hiding a âDelete Allâ button in the UI doesnât stop someone from calling the API directly. UI security = no security. Anyone can call your APIs with curl.
Every protected route needs: âCheck if user.role === âadminâ on the server before executing.â
17. Update Your Dependencies
AI might scaffold with packages from 2022. Old versions = known exploits. After building, run npm audit fix and ask the AI: âAre there breaking changes in the latest versions I should know about?â
80% of breaches exploit known vulnerabilities in old packages. Keep things updated.
18. Rate Limit Reset Requests
Attackers love spamming the âforgot passwordâ endpoint to flood someoneâs email or brute-force reset tokens.
Ask: âAdd rate limiting to the password reset route: max 3 requests per email per hour.â Unlimited resets = email bombing and token brute-forcing.
19. Never Show Raw Errors
When something breaks, AI often returns the full stack trace to the user. This tells hackers your file structure, tech stack, and internal paths.
âCatch all errors and return generic messages to users. Log detailed errors server-side only.â
20. Set Session Expiration
Default AI auth often keeps users logged in forever. Stolen cookies = permanent access. Thatâs bad.
âSet JWT expiration to 7 days and implement refresh token rotation.â Permanent sessions mean one stolen cookie = forever access.
21. Secure Your Mobile APIs
Your web app is protected, but what about the mobile API? If it has no rate limiting, attackers will use it instead. Hackers always attack the weakest entry point.
Apply the same auth, rate limits, and validation to ALL API endpoints. Donât leave any doors unlocked.
Part 3: The Production Nightmares
Parts 1 and 2 kept you safe. Part 3 keeps you in business. These are the issues that wake you up at 3am when you have real users and real money on the line.
22. Cap Your API Costs
AI doesnât set spending limits. One attacker hitting your OpenAI endpoint could rack up a $10K bill overnight. Iâve seen it happen.
Add usage limits in your OpenAI dashboard AND rate limit the endpoint: âmax 50 requests per user per day.â One viral TikTok about your free tool = bankruptcy by morning if youâre not careful.
23. Verify Email Sending
AI uses basic SMTP. If your app sends spam (or gets hijacked to send spam), your domain gets blacklisted. Email blacklist = no password resets, no notifications, dead product.
Use a verified sending service like Resend or SendGrid with SPF/DKIM records configured.
24. Implement Account Deletion
AI rarely builds proper account deletion. GDPR violations can result in fines up to 4% of global revenue. One complaint = investigation.
Create a DELETE /user endpoint that removes all user data from the database AND storage. Donât skip this.
25. Automate Database Backups
AI doesnât think about disasters. No backups = one bad migration deletes everything. Lost data = lost users = lost business. Forever.
If youâre on Supabase: Settings > Database > Enable Point-in-Time Recovery (PITR). Whatever platform you use, make sure backups are automated.
26. Rotate Your Secrets
Your API keys are in old commits, Slack messages, and screenshots. Attackers find them. That key from your tutorial video? It probably still works.
Rotate all API keys every 90 days. Use GitHubâs secret scanning to find leaked keys.
27. Add DDoS Protection
Someone hits your site with 100K requests per second. Your hosting bill spikes to $5K and the site goes down. DDoS attacks are automated and cheap â your protection needs to be too.
Use Cloudflare (free tier works!) or Vercelâs Edge Config for rate limiting at the CDN level.
28. Limit File Upload Sizes
AI doesnât validate file sizes. Users (or attackers) upload 500MB videos to your âprofile picâ field and your storage costs spiral out of control.
Set max file size to 5MB for images and validate file type server-side. Donât trust the client.
29. Log Critical Actions
Something goes wrong â fraud, a bug, a hack. You have no record of who did what. No logs = no forensics = canât prove what happened.
Create an audit_log table. Log every user deletion, role change, payment, and data export. Future you will thank present you.
30. Separate Test & Production
You test Stripe payments in production. Test webhooks delete real user data. Test data hits real credit cards. This is a nightmare scenario that actually happens.
Use Stripe test mode keys and a separate database project for staging. Keep these environments completely isolated.
31. Have a Security Checklist
Before every deploy, run through these tips as a checklist. It only takes a few minutes, and itâs the difference between a secure app and a headline-making data breach.
Bookmark this post and come back to it every time you ship something new.
Final Thoughts
You now have the complete playbook:
- Part 1: The Foundations (Tips 1-10) â The basics that prevent 99% of hacks
- Part 2: The Common Mistakes (Tips 11-21) â Intermediate issues that trip up experienced devs
- Part 3: The Production Nightmares (Tips 22-31) â Business-critical security for real users and real money
Security isnât a vibe â itâs a requirement. Vibe coding is powerful, but with great power comes great responsibility. Build fast. Build smart. Build securely.
If this guide helped you, share it with a fellow vibe coder. We all deserve to build apps that are safe for our users.
Happy (and secure) coding!
Kedasha
-
Agent Memory Engineer Is About to Be a Real Job Title
-
5 FREE AI Courses You Can Finish This Weekend
-
How I Built an AI Receptionist for a Luxury Mechanic Shop - Part 1
Related Posts:
Written by
Kedasha Kerr
Software Developer
in Chicago
I write about building with AI.
Let's stay connected! đ
Get the next post delivered to your inbox and follow me on Instagram for daily AI tips and coding content.
See you on Instagram!