No Input Validation
User-supplied data sent directly to databases or external APIs without any type, format, or content validation.
How It Works
When you pass req.body straight to a database query or API call, an attacker controls the shape and content of that data. This enables SQL injection, NoSQL injection, type confusion bugs, and unexpected behavior. AI-generated code is especially prone to this — it often skips validation for brevity.
// BAD: raw body straight to the database
export async function POST(req: Request) {
const body = await req.json();
const user = await db.users.create({ data: body });
return Response.json(user);
}// GOOD: validate with Zod before touching the DB
const schema = z.object({
name: z.string().min(1).max(100),
email: z.string().email(),
});
export async function POST(req: Request) {
const body = schema.parse(await req.json());
const user = await db.users.create({ data: body });
return Response.json(user);
}Real-World Example
A common vibecoder mistake: AI generates an API route that destructures req.body and passes it to Prisma's create(). If the users table has a role field, an attacker can set role: 'admin' and escalate privileges instantly.
How to Prevent It
- Use Zod, Joi, or Yup to validate every API request body and query param
- Whitelist allowed fields explicitly — never pass the entire request body to an ORM
- Validate types, lengths, formats, and ranges — not just presence
- Return 400 with a clear error message on validation failure, not 500
Affected Technologies
Data Hogo detects this vulnerability automatically.
Scan Your Repo FreeRelated Vulnerabilities
Hardcoded API Keys
criticalAPI keys, tokens, or secrets written directly in source code, making them visible to anyone with repo access — including public GitHub repositories.
Passwords Stored in Plaintext
criticalUser passwords stored as raw strings in the database instead of being hashed with a proper algorithm like bcrypt or Argon2.
JWT Without Expiration
highJWTs signed without an `exp` claim that never expire, meaning a stolen token grants permanent access with no way to revoke it.
Auth Logic in Frontend Only
highShowing or hiding UI elements based on user role in React, without any server-side enforcement — easily bypassed by anyone who opens DevTools.