Topic 5 of 5 · 6 min read
Hardening a vibe-coded prototype
Goal: Apply a hardening checklist to a vibe-coded app and order the fixes by risk.
Before real users arrive, work through a fixed checklist and fix problems in order of how much harm they can do. The goal is not perfect code. It is to remove the failures that hurt people or lose data, and to make sure a human understands what is running.
Check yourself · 1 of 3
You are hardening a vibe-coded app with real users coming next week. What should you fix first?
Why it matters
A prototype was built for speed. Real users bring real data, mistakes and attackers. Every gap you leave is now someone else's risk. A checklist beats a vague feeling that "it should be fine", because the flaws are the ones you cannot see from the screen.
The checklist, in risk order
- Secrets. Search the code, the repository history and the browser bundle for keys and passwords. Move them to environment variables on the server. Revoke any key that was ever exposed.
- Authentication. Check that sign-in, sign-out, password reset and session expiry work. Prefer a well-known provider over code the AI invented.
- Authorization. For every endpoint and every table, ask: who may read this, who may change it? Enforce that on the server and in database rules. Test as a signed-out visitor and as a second user.
- Input handling. Treat everything from the browser as untrusted: validate it, and never build database queries by joining text.
- Data safety. Automatic backups, a tested restore, and no personal data you do not need.
- Tests. Add tests for the paths that matter most: sign-in, payment, access to another user's data. Ask the AI to write them, then read them.
- A human reader. Someone reads the code that handles login, money and personal data. If you cannot, hire or ask someone who can.
- Monitoring. Error logs and an alert, so you hear about failures before your users tell you.
- Dependencies. Remove unused packages and update the ones you keep.
Do the top items first. A missing backup is bad. An open database is worse.
Before and after
Weak plan: "Ask the AI to make the app secure, then launch." The answer may be a confident paragraph and a few changes. Nobody checks them.
Better plan: "Monday: rotate keys and scan the repository. Tuesday: write access tests for two users and fix every failure. Wednesday: set up backups and restore one. Thursday: a developer reviews login and payment code. Friday: limited beta."
What goes wrong
- Fixing the easy items first. Style cleanups feel productive while the database is still open.
- Using the AI as the only auditor. It can help find issues, but it can also miss them or claim fixes it did not make. Check with a test.
- Launching to everyone at once. Start with a small group and watch the logs.
A hardened app is one where each risk has an owner and a test, not one where nothing could ever go wrong.
Examples
A one-week hardening plan
- Scan code and history for keys; revoke and replace any found.
- Turn on database access rules; test as two different users.
- Move payment and admin actions behind server-side checks.
- Schedule backups; restore one to prove it works.
- Add tests for sign-in, payment and cross-user access.
- A developer reviews the auth and payment code.
- Release to 20 beta users with error alerts on.
A test the AI should not skip
test("user B cannot read user A's invoice", async () => {
const res = await request(app)
.get(`/api/invoices/${invoiceOfA.id}`)
.set("Authorization", tokenOfB);
expect(res.status).toBe(403);
});
If this test fails, the app leaks data. Passing it once is not enough, so keep it in the test suite.
Key points
- Harden in risk order: secrets, authentication, authorization and database rules first, then backups, tests and monitoring.
- Every endpoint and table needs a clear answer to who may read it and who may change it, enforced on the server and in the database.
- Use the AI to help write tests and find issues, but verify with real checks, because it can miss flaws or claim fixes it did not make.
- A person must read the code that handles login, money and personal data.
- Launch to a small group first and watch error logs before opening to everyone.
Common mistakes
- Asking the AI to "make it secure" and accepting its report as proof.
- Polishing the interface while the database is still open to anyone.
- Launching to all users on day one with no monitoring.
- Leaving the code unread because "the AI wrote it".
Check yourself · 2 of 3
The AI says it fixed all security problems. What is the best next step?
Check yourself · 3 of 3
Why should a person read the login and payment code of a vibe-coded app before launch?
Practice items, not counted towards your mastery.
Start here
- Not all AI-assisted programming is vibe coding (Simon Willison) (opens in a new tab)ArticleFree
Draws the line between vibe coding and AI-assisted programming where you review and understand the code.
- Vibe coding (Wikipedia) (opens in a new tab)ArticleFree
Origin of the term in early 2025, how it spread, and the criticism of it.
- OWASP Top Ten (opens in a new tab)StandardFree
The standard list of web app risks, including broken access control and insecure design.
More for this topic
- Secrets Management Cheat Sheet (OWASP) (opens in a new tab)ArticleFree
Practical rules for storing, rotating and revoking keys and tokens.
- Supabase docs: Row Level Security (opens in a new tab)DocsFree
How database rules decide which rows each user may read or write, the most common gap in generated apps.