Code Room
Vibe codingHardvc-g027
Subject Ai code reviewLevel Senior–Staff~19 minCommon in Security interviewsIndustries Software development

Question

An AI agent added an admin-only endpoint to delete any user. The product spec says only users with the `admin` role may call it. Auth middleware sets `req.user` from a verified JWT. The reviewer is checking whether the authorization is correct.

javascript
app.delete("/api/admin/users/:id", requireAuth, async (req, res) => {  // role check  const roles = req.user.roles || [];  if (roles.includes("admin") || req.query.force === "true") {    await db.user.delete({ where: { id: req.params.id } });    return res.json({ deleted: true });  }  return res.status(403).json({ error: "forbidden" });});
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.