Securing a vibe-coded project
The agent from the “Vibe coding: websites” and “Vibe coding: interfaces” topics takes a prototype to a real product faster than ever. But building fast doesn’t make the result secure automatically. By default, the agent optimizes for “works and looks right”, not for “holds up against a bad actor”. If you’ve never thought about security at all (it was the developers’ territory), that’s fine. You don’t need a security engineer’s skills here. You need to know which questions to ask the agent before you show the project to real people or a client. Below is a short checklist for exactly that.
How people usually lose a vibe-coded project overnight
The three most common scenarios. They aren’t hypothetical; they’re the typical set of mistakes almost everyone goes through at first:
- A secret API key leaked into public code. A key for a paid model, a payment system or a database ends up right in the frontend code or committed to a public GitHub repository. Keys like this are found automatically, by bots that scan GitHub specifically for them. Anyone who finds the key can burn through the owner’s entire paid limit in a matter of hours. The API bill arrives after the damage is done.
- The database is open to any request. User data (emails, order history, private messages) technically sits in a cloud database, but its access rules were never set up. Anyone who knows just the project’s address can read or change other people’s data directly, without even opening the app.
- The admin section is reachable without checking who got in. A page for managing orders, users or content lives at a predictable address (
/admin). But it doesn’t check whether the visitor is really an administrator and not a random person who typed the address by hand.
All three scenarios have one thing in common. None of them is a sophisticated hacker attack. The agent built a working prototype, but nobody asked it directly: “what happens if a bad actor shows up here?” The agent doesn’t ask itself that question unless you ask it to.
Checklist before you show the project to anyone beyond your own computer
- Secrets aren’t in the code — or in the browser. API keys, passwords and access tokens are stored in an environment variables file (usually
.env) that’s excluded from git through.gitignore. But for a frontend project that’s not enough. Variables with theVITE_,NEXT_PUBLIC_orREACT_APP_prefixes end up in the built site code, and any key the browser sends on its own is visible in the Network tab. So split keys into two kinds. Secret ones — OpenAI and Anthropic, Stripe secret, Supabase secret (formerlyservice_role) — live only on the server. Publishable ones — Supabase anon/publishable, Stripe publishable — can go to the browser; that’s what they’re made for. - The built bundle contains no secret keys at all. Check this after the build, not in the source files: the bundle is what goes to every visitor’s browser.
- The provider’s console has a spending limit, and each project has its own key. It’s the cheapest protection against the “they’ll burn the whole limit” scenario: even if a key leaks, the damage hits a ceiling, and an alert tells you about the leak before the bill does. A separate key per project can be revoked without breaking the others.
- The endpoint to the paid model is protected. An endpoint that calls a paid model on the server’s behalf requires a login itself, or at least limits the number of requests per user/IP. Otherwise nobody needs the key: they’ll spend your budget through your own button. If the product has an AI feature that reads other people’s text, see the part about prompt injection in “CLI and terminal AI agents”.
- Database access rules are set explicitly, not left “however it turned out”. Postgres databases like Supabase have row-level security, Firebase has security rules: in both cases you have to turn the access rules on explicitly. Row-level security means per-row rules for who can read and change what. If you don’t turn it on explicitly, under some settings the database may end up readable by anyone.
- Every sensitive page and action checks authorization. Not just the login page. Every endpoint and every admin function checks that the request came from someone who’s allowed to make it. You can’t rely on “a regular user just doesn’t know this address”.
- User input is never run as code. Whatever a user types into a form must not go straight into a database query or a server command without being checked. It’s a classic attack vector (SQL injection and the like). Modern libraries protect against it by default, but only if the agent uses them correctly instead of building the query by hand by gluing strings together.
- The project’s dependencies have no known vulnerabilities. The libraries the agent pulled into the project may contain already known and documented security holes. One command checks this (
npm auditfor JavaScript projects, and equivalents for other languages). Ask the agent to run it and show you the result. - HTTPS is on, not just HTTP. Modern deploy services (the “Vibe coding: websites” topic, section “Deploy”) usually turn it on automatically. Still, check the address bar after publishing instead of taking it for granted.
How to brief the agent
The good news: you don’t have to check almost any of this checklist by hand. Give it to the agent as an explicit task before deploying:
Run a pre-launch security audit on this project: check whether there are secret keys right in the code, whether explicit database access rules are set up, whether admin pages are protected by an authorization check, and whether there are known vulnerabilities in the dependencies. Show me a list of what you found and suggest what to fix first
Repeat this check not just once at the end but every time the project gets something new that works with user data or money: a form, a payment, a user account area. That way it’s easier to spot the specific cause of a problem than to sort through a month’s pile of changes all at once.
A separate safety net — for your own machine rather than production: you can protect yourself not only by hand before each deploy but automatically too. A PreToolUse hook (the “Terminal agents: making them yours” topic) can block clearly dangerous commands before the agent runs them, even if you forgot about the manual checklist in the moment. It doesn’t replace the manual audit above; it’s an extra barrier on top of it.
What to do if a key leaks anyway
If you find out that a secret key ended up somewhere public, don’t panic, but act fast and in the right order. First revoke the leaked key in the dashboard of the service that issued it, and issue a new one. Only then figure out how it got there and how to remove it from the git history. Until the key is revoked, no code change helps: the old key keeps working for whoever already found it. Once the new key is issued, you can hand the cleanup itself to the agent:
Check this whole project and the git history for mentions of this leaked key: [the first and last few characters of the key, not the whole key] — show me every file and commit where it appears, so I know what else needs cleaning up
Command examples for practice
Run a pre-launch security audit.
1) Secrets: find keys in the code and in variables with the VITE_/NEXT_PUBLIC_/REACT_APP_ prefixes. Supabase anon/publishable and Stripe publishable are fine; Supabase secret keys (sb_secret_…, formerly service_role), sk-… and other secret keys in the frontend are critical.
2) Database: if there are RLS policies in the migrations, check them; if not, say so and give me an SQL query I can run myself in Supabase to check that RLS is enabled on all tables.
3) Authorization on admin pages and API routes.
4) npm audit — list critical issues separately.
Don't fix anything, just a list with file paths.
RLS policies set up in the Supabase dashboard are invisible to an agent working from the project folder. And it often wrongly flags the public anon key as a leak. So the prompt spells out in advance what’s fine and what’s critical, and asks for SQL to check the database.
Explain in plain words what row-level security in Supabase is and why it’s needed, as if I’ve never done any backend work
Check this feedback form: can a user type something into it that breaks or tricks the server, rather than just leaving a message
Run a check of the project’s dependencies for known vulnerabilities and explain which of the issues found are really critical and which can waitTake any of your vibe-coded projects that is already connected to a database or contains at least one API key. Ask the agent to run the security audit from this topic on it. Read the list of findings in full, even if nothing critical turned up: that way you’ll see once what a report like this looks like in practice. Fix the critical findings or write down when you’ll fix them.
Sources
- API keys — Supabase Docssupabase.com
publishable and secret keys, and what is safe to expose in the browser
- Row Level Security — Supabase Docssupabase.com
without RLS a table is open for reading and writing
- Env Variables and Modes — Vitevite.dev
VITE_ variables end up in the client bundle
- How to use environment variables in Next.jsnextjs.org
NEXT_PUBLIC_ variables are inlined into the browser JS
- npm-audit — npm Docsdocs.npmjs.com
checking dependencies for known vulnerabilities
- Hooks reference — Claude Code Docscode.claude.com
PreToolUse can block a tool call
Found a mistake or an outdated fact? Write to hey@iskra.guide