Demo app we built on purpose · reviewed by Anton Palmer
Code review: HabitBoard
We built a small habit tracker the way one big prompt builds it: sign up, notes, an AI coach, payments. Then we reviewed it exactly like we review a member’s app. The app is a demo; the review is real.
It works on the happy path, and that's the problem. Ten findings: five would let a stranger read private data, become another user, or spend your money. None of them needs a hacker; each one is an ordinary request the app forgot to question.
- P0 · fix todayF1 · public/app.js:2
The AI key ships to every visitor
What can happen: The AI coach calls the model straight from the browser, so the key is inside the page. Anyone who opens the page can copy it and spend on your account.
Fix: Move the call to the server (POST /api/coach), read the key from an environment variable, and set a hard spend limit with the provider. Rotate the old key.
app.post("/api/coach", requireUser, rateLimit, async (req, res) => { const r = await ai.chat({ key: process.env.AI_KEY, messages: req.body.messages }); res.json(r); }); - P0 · fix todayF2 · server.js · GET /api/notes
Anyone can read anyone's notes
What can happen: The server returns notes for whatever userId the request names, with no login check. Change the number and you read another person's private notes.
Fix: Never trust an id from the request. Take the user from the session and filter by it.
app.get("/api/notes", requireUser, (req, res) => { res.json(db.prepare("SELECT * FROM notes WHERE user_id = ?").all(req.user.id)); }); - P0 · fix todayF3 · server.js · GET /api/admin/users
The "hidden" admin page is open, and it returns passwords
What can happen: Not linking to a page doesn't protect it. The endpoint checks nothing and sends every user's email, plan and password.
Fix: Check the role on the server for every admin action, and never send password fields to any client.
app.get("/api/admin/users", requireRole("admin"), (req, res) => { res.json(db.prepare("SELECT id, email, plan FROM users").all()); }); - P0 · fix todayF4 · server.js · /api/signup, /api/login
Passwords are stored as plain text
What can happen: Anyone who sees the database (or the admin endpoint above) sees every password, and people reuse passwords everywhere.
Fix: Hash with a slow password hash (argon2 or bcrypt) on signup, compare the hash on login.
const hash = await argon2.hash(password); // login: await argon2.verify(user.password_hash, password)
- P0 · fix todayF5 · server.js · tokenFor / userFrom
The login token is just your user id
What can happen: The token is the user id in base64. It can be made up for any account, it never expires, and logout or a password change doesn't end it.
Fix: Issue random session ids stored on the server with an expiry. Delete them on logout, and delete all of a user's sessions on password change.
const sid = crypto.randomBytes(32).toString("hex"); sessions.insert({ sid, userId, expiresAt: Date.now() + 7 * DAY }); // change-password: sessions.deleteWhere({ userId }) - P1 · fix this weekF6 · server.js · POST /api/webhooks/payments
Anyone can mark themselves as paid
What can happen: The webhook accepts any request without checking the provider's signature, so a stranger can upgrade any account. Real retries also create duplicate orders.
Fix: Verify the signature with the webhook secret, and store the event id with a unique constraint so a retried event is ignored.
const event = provider.webhooks.verify(rawBody, req.headers["signature"], process.env.WEBHOOK_SECRET); if (seenEvent(event.id)) return res.json({ received: true }); - P1 · fix this weekF7 · server.js · GET /api/habits/search
Search builds SQL from user input
What can happen: The search text is pasted into the SQL string. A single quote already crashes it; a crafted one can read other tables.
Fix: Always use parameters for anything that comes from a user.
db.prepare("SELECT * FROM habits WHERE user_id = ? AND name LIKE ?").all(req.user.id, `%${q}%`); - P1 · fix this weekF8 · public/app.js · loadNotes
Notes are rendered as HTML
What can happen: Notes go into the page with innerHTML, so a note containing markup runs in whoever views it.
Fix: Render user text as text.
li.textContent = note.text;
- P2 · fix before launchF9 · server.js
No limits on signup, login or the AI coach
What can happen: A script can create thousands of accounts, guess passwords, or run up the AI bill overnight. In our check, 30 signups in a row all went through.
Fix: Rate-limit per IP and per user, add a captcha to public forms, and set billing alerts and caps on anything paid per request.
app.use("/api/", rateLimit({ windowMs: 60_000, max: 30 })); - P2 · fix before launchF10 · config.js
Secrets are committed in config.js
What can happen: Keys in the repo end up in every clone, fork and backup.
Fix: Move them to environment variables, add .env to .gitignore, rotate anything that was committed.
export const config = { aiKey: process.env.AI_KEY, webhookSecret: process.env.WEBHOOK_SECRET };
Want this for your app?
Members bring their own apps, Lovable, Bolt, Replit or hand-written, and get this kind of review.
Join the waitlist