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: 31 Tips to Keep Your AI-Coded Apps Safe

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

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!