Missing Input Validation

Request body used without validation in an API route

warningSecurityinput-validation

Why 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

Flaggedapp/api/users/route.ts
export async function POST(req: Request) {
  const { email, role } = await req.json();
  await db.user.create({ data: { email, role } });
  return Response.json({ ok: true });
}
Fixedapp/api/users/route.ts
import { 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 --json and 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-validation at the top of the file
How it works
Matches text patterns. Source on GitHub