Security Guides
65 step-by-step guides for fixing security vulnerabilities in vibe-coded apps. Each guide includes code examples, common mistakes to avoid, and verification steps.
Bolt.new
3 guidesHow to Secure Your Bolt.new App
Bolt.new ships AI-generated code with frontend API keys and unprotected endpoints. Concrete steps to audit, migrate secrets to env vars, add server-side API routes, and harden Bolt output.
How to Fix API Key Exposure in Bolt.new Apps
Bolt.new frequently places OpenAI/Stripe keys directly in frontend files. Find them, rotate immediately, and migrate to server-side routes or env vars before attackers harvest them.
How to Deploy Bolt.new Apps Securely
Bolt apps often ship with development defaults left on. Pre-deploy checklist: env var audit, remove test credentials, build config review, and header/CSP setup before first production push.
Cursor
2 guidesHow to Secure Your Cursor-Built App
Cursor-generated code often includes patterns that pass code review but fail security review. How to audit AI suggestions, scan for hallucinated dependencies, and verify auth flows.
How to Fix API Key Exposure in Cursor-Built Apps
Cursor may suggest paste-a-key-here patterns that end up in production bundles. Scan deployed JS for sk-/sk_live_/AIza patterns, rotate leaked keys, and refactor to server-side calls.
Firebase
8 guidesHow to Secure Your Firebase Studio App
Firebase Studio scaffolding often ships with permissive rules and Admin SDK usage patterns that need review. Per-scaffold hardening for Gemini-generated Firebase apps.
How to Secure Your Firebase App
Each Firebase service (Firestore, Realtime Database, Cloud Storage, Cloud Functions, Hosting) needs its own security config. Per-service rules examples and Admin SDK isolation patterns.
How to Fix API Key Exposure in Firebase Studio Apps
Firebase Studio-generated code sometimes ships Admin SDK credentials to the client. Audit Gemini-generated files, rotate exposed keys, migrate admin operations to Cloud Functions.
How to Fix Firebase API Key Exposure
Firebase client API keys are public by design (security lives in Rules), but Admin SDK credentials must never reach the browser. How to audit which kind you have and contain any leaks.
How to Add Security Rules to Firebase
Replace Firebase test-mode rules with production rules: enforce request.auth.uid == resource.data.userId, use Emulator Suite to validate, handle Storage rules, and deploy via CLI.
How to Add Security Rules to Firebase Studio Apps
Firebase Studio scaffolds with permissive rules by default. Migrate to production rules with ownership checks for Firestore and Storage, verify with firebase emulators:exec.
How to Deploy Firebase Apps Securely
Before hitting firebase deploy: replace test-mode Rules, verify Admin SDK stays server-side, run Emulator Suite checks, and enforce production-only environment variables.
How to Add Authentication to Firebase Studio Apps
Wire Firebase Authentication into Gemini-generated Firebase Studio apps: set up Email/Password or OAuth providers, update Security Rules to require auth.uid, and protect Cloud Functions.
Lovable
5 guidesHow to Secure Your Lovable App
Eight-step hardening of a Lovable + Supabase app: enable RLS on every table, move OpenAI/Stripe keys to Edge Functions, configure vercel.json headers, rate-limit via kv store.
How to Fix API Key Exposure in Lovable Apps
Lovable apps commonly leak OpenAI, Stripe, and third-party keys in the browser bundle. Rotate compromised keys and migrate sensitive calls to Supabase Edge Functions with Deno.env.
How to Add Row Level Security to Your Lovable App
Row Level Security is off by default in Lovable + Supabase projects. Enable RLS on every table, write SELECT/INSERT/UPDATE/DELETE policies scoped to auth.uid(), and verify with a client probe.
How to Deploy Lovable Apps Securely
Lovable deployments: run pg_tables check for missing RLS, audit env vars in Vercel/Netlify, confirm Supabase anon vs service role usage, and add security headers before first deploy.
How to Add Authentication to Your Lovable App
Full Supabase Auth setup for Lovable: enable email verification, pick OAuth providers, wire protected routes, and align RLS policies with (select auth.uid()) for authenticated data access.
Netlify
3 guidesHow to Secure Your Netlify App
Netlify-specific hardening via _headers, netlify.toml environment scoping, Functions secret isolation, and edge middleware for auth. Common Netlify misconfigurations and fixes.
How to Fix API Key Exposure in Netlify Apps
netlify.toml is committed to git — any secret there is exposed. Scan build logs, move secrets to Netlify UI environment variables, rotate anything that leaked, and isolate per-deploy scope.
How to Deploy to Netlify Securely
Netlify deploy hardening: configure _headers with CSP/HSTS, scope environment variables per-deploy-context, protect Functions endpoints, and enable access control on preview builds.
Replit
3 guidesHow to Secure Your Replit App
Replit's shared environment and public-repl defaults create unique risks. Migrate credentials to Replit Secrets, ensure repls are private, add headers, and prevent accidental code exposure.
How to Fix API Key Exposure in Replit Apps
Public repls with .env files or hardcoded keys are instantly indexable. Migrate to Replit Secrets, make the repl private, rotate anything that was ever visible, and remove from git history.
How to Deploy Replit Apps Securely
Replit deployment checklist: make repl private before deploy, migrate .env to Replit Secrets, authenticate all exposed endpoints, and remove accidentally-committed keys from history.
Supabase
4 guidesHow to Secure Your Supabase App
End-to-end Supabase hardening: enable RLS with ownership checks, keep service_role out of the client, authenticate RPC functions, and lock down storage bucket policies.
How to Fix Supabase API Key Exposure
The Supabase anon key is meant to be public (RLS enforces security). Service role is not. Tell them apart, rotate the service role if it ever touched a client bundle, and move to server-only.
How to Add Row Level Security to Supabase
Comprehensive Supabase RLS guide: enable RLS, write policies using (select auth.uid()) to avoid initplan warnings, handle service_role bypass, test with different auth contexts.
How to Add Authentication to Your Supabase App
Complete Supabase Auth guide: email/password with verification, Google/GitHub/OAuth providers, getServerSession for SSR, and RLS policy patterns that pair with auth.uid()/role claims.
Vercel
3 guidesHow to Secure Your Vercel App
Vercel app hardening: configure security headers in vercel.json, enable Vercel Authentication for previews, correctly scope Development/Preview/Production env vars.
How to Fix API Key Exposure in Vercel Apps
Vercel env vars have Development/Preview/Production scopes — and the wrong scope leaks secrets to previews. Audit build logs, rotate exposed keys, and use NEXT_PUBLIC_ only where intended.
How to Deploy to Vercel Securely
Vercel deployment hardening: configure security headers in vercel.json, enable Vercel Authentication for preview deployments, scope env vars correctly, and monitor build logs for leaked secrets.
Windsurf
3 guidesHow to Secure Your Windsurf App
Windsurf's Cascade suggestions and MCP integrations introduce specific risks. Enable ZDR mode, audit .windsurf config, vet MCP servers, and verify generated auth flows.
How to Fix API Key Exposure in Windsurf Apps
Windsurf's Cascade can introduce paste-a-key patterns in generated code. Scan Cascade-edited files for key patterns, rotate leaked credentials, and enable ZDR to reduce future exposure.
How to Add Authentication to Your Windsurf App
Step-by-step auth setup in Windsurf-generated apps: choose between Supabase Auth / Clerk / Auth.js, let Cascade scaffold it, then manually verify session handling on every protected route.
v0
3 guidesHow to Secure Your v0 App
v0 generates UI quickly but skips server-side validation and auth. Before production: review component props, add API routes for sensitive ops, and enforce input validation server-side.
How to Fix API Key Exposure in v0 Apps
v0 generates client-side components that often fetch directly with embedded keys. Rotate the keys, create Next.js Route Handlers for external API calls, and use env vars with proper scoping.
How to Deploy v0 Apps Securely
v0 components rarely ship production-ready. Pre-deploy: add server API routes for sensitive operations, verify every route requires auth, and add input validation on every form.
API Keys & Secrets
3 guidesHow to Fix API Key Exposure in Railway Apps
Railway apps can leak keys through shared variable groups or stale per-service variables. How to audit every service, migrate to proper variable groups, and rotate compromised credentials.
How to Secure Environment Variables
Per-environment scoping (dev/preview/prod), secret managers (AWS Secrets Manager, Doppler), avoiding NEXT_PUBLIC_ leaks, and keeping .env out of git history permanently.
How to Rotate API Keys
Generate new key → deploy with new key alongside old → verify traffic moved → revoke old. Per-provider rotation steps for OpenAI, Stripe, AWS IAM, and Supabase service role.
Authentication
3 guidesHow to Add Two-Factor Authentication
Implement 2FA that users will actually enroll in: TOTP via Speakeasy/Google Authenticator, WebAuthn for passkeys, recovery codes, and UX patterns that survive phone loss scenarios.
How to Hash Passwords Securely
Choose bcrypt (cost 12+) or argon2id (m=64MB, t=3) based on constraints. Migrate from weak hashes by rehashing on next login. Avoid MD5, SHA1, and plain SHA256 — none are password hashes.
How to Secure Your OAuth Implementation
OAuth 2.0 done right: PKCE for SPAs (code_verifier + S256), validate state parameter to prevent CSRF, enforce strict redirect_uri allowlists, and scope tokens minimally.
General Security
15 guidesHow to Secure Your Railway App
Railway's service model exposes unique hardening points: per-service env vars, private networking between services, TCP proxy auth, and image-based deployment risks.
How to Add Rate Limiting
Implement rate limiting that survives production traffic: in-memory counter for small apps, Redis-backed sliding window for distributed ones, per-user identifiers, and 429-response design.
How to Secure API Endpoints
Production API hardening: JWT or session auth on every route, rate limiting by user/IP, Zod/Joi input validation, and response shape normalization to prevent info leaks.
How to Secure File Uploads
File uploads need layered defense: extension + magic-number validation, size caps, AV scanning for user-facing files, isolated storage buckets, and never serve from the same origin.
How to Secure JWT Tokens
JWT hardening: explicitly allowlist HS256 or RS256 (reject alg:none), rotate signing keys quarterly, keep access tokens under 15 minutes, and never store refresh tokens in localStorage.
How to Fix Mixed Content Warnings
Resolve "Mixed Content" browser warnings: find HTTP assets on HTTPS pages, use upgrade-insecure-requests CSP directive, migrate CDN URLs, and verify after with browser DevTools.
How to Implement Content Security Policy
CSP done properly: pick nonce-based or hash-based script allowlisting, deploy in Report-Only mode first, collect violation reports, then enforce. Per-framework integration patterns.
How to Secure Cookies
Configure cookies that resist session hijacking: HttpOnly blocks JS access, Secure enforces HTTPS, SameSite controls cross-site sending, Partitioned isolates third-party contexts.
How to Secure Database Connections
Lock down database access: force TLS 1.2+, use connection pools to limit exposure, rotate credentials on a schedule, and verify pg_hba.conf / MongoDB Atlas rules block unauthorized ranges.
Security Audit Checklist
Complete pre-launch audit: auth flows, database access controls, secret handling, headers, CORS, CSRF, session handling, rate limiting, dependency hygiene, and monitoring — all in one list.
How to Secure Third-Party Dependencies
Supply chain hygiene: automated vulnerability scanning with npm audit / Snyk, pin versions with exact lockfiles, generate SBOMs for compliance, and watch for suspicious package renames.
How to Implement HTTPS Correctly
Beyond "add Let's Encrypt": configure HSTS with preload, disable TLS 1.0/1.1, tune cipher suites, fix mixed content, and understand when certificate pinning makes sense (rarely).
How to Prevent Clickjacking
Block iframe-based attacks: CSP frame-ancestors (modern), X-Frame-Options (legacy), sandbox attribute for legitimate embeds, and why JavaScript framebusting alone is bypassable.
How to Protect Against Brute Force Attacks
Multi-layer defense: per-IP and per-account rate limiting, progressive delays, account lockout thresholds, invisible CAPTCHAs for suspicious traffic, and credential-stuffing detection.
How to Secure WebSocket Connections
WebSockets skip CORS — validate Origin manually on upgrade. Authenticate with a JWT in the upgrade query string, rate-limit per connection, validate every incoming message with Zod/Joi.
Security Headers
3 guidesHow to Add Security Headers in Next.js
Configure security headers for Next.js App Router: headers() function in next.config.js for static headers, middleware.ts for nonce-based CSP, and per-route overrides where needed.
How to Add a Content Security Policy Header
Implement CSP without breaking your app: start with Report-Only mode, add nonces for inline scripts, tune directives per framework (Next.js, Express, Django), enforce after monitoring.
How to Fix CORS Errors
Stop CORS blocking your fetch() calls: allowlist specific origins (never `*` with credentials), handle OPTIONS preflight, tune Access-Control-Max-Age, and avoid the common reflection mistake.
Vulnerability Fixes
3 guidesHow to Prevent XSS Attacks
Defense in depth for XSS: framework auto-escaping, CSP with script-src strict, DOMPurify for rich content, and the list of escape hatches (dangerouslySetInnerHTML, v-html, |safe) to audit.
How to Prevent SQL Injection
Parameterized queries are the fix — but ORMs have unsafe escape hatches (raw(), DB::raw, find_by_sql). How to audit your stack, use the safe idioms, and lock down table/column name inputs.
How to Implement CSRF Protection
CSRF patterns that actually work: synchronizer token for server-rendered apps, double-submit cookie for SPAs, SameSite=Lax cookie defaults, and API-style apps with per-request origin check.
Find What Needs Fixing
Run an automated scan to identify which guides are relevant to your app. Get a prioritized list of issues with direct links to fix instructions.
Get Starter Scan