Missing Input Validation
Request body used without validation in an API route
warningSecurity
input-validationWhy this matters
Unvalidated input is the root cause of injection attacks, type confusion, and data corruption. AI tools trust the request shape matches what they expect — attackers don't.
Example
app/api/users/route.tsexport async function POST(req: Request) {
const { email, role } = await req.json();
await db.user.create({ data: { email, role } });
return Response.json({ ok: true });
}app/api/users/route.tsimport { z } from "zod";
const schema = z.object({
email: z.string().email(),
role: z.enum(["user", "admin"]),
});
export async function POST(req: Request) {
const body = schema.parse(await req.json());
await db.user.create({ data: body });
return Response.json({ ok: true });
}How to fix
Validate every request body with Zod, Valibot, or a similar schema library before using the data. Reject invalid payloads with a 400 response.
Reference
- In the output
- Findings carry
"ruleId": "input-validation"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line input-validation- Silence a whole file
// prodlint-disable input-validationat the top of the file- How it works
- Matches text patterns. Source on GitHub