Missing Input Validation on API Endpoints
Your API endpoints generated by Claude Code accept any input without validation, allowing malformed data, oversized payloads, or malicious content to reach your business logic and database. There are no checks on field types, lengths, formats, or required fields.
Without input validation, attackers can submit negative prices, inject SQL through string fields, send payloads that crash your server, or store garbage data that breaks your application later. Even non-malicious users can accidentally submit invalid data that causes downstream errors.
This often becomes apparent when your database contains impossible values, when your app crashes on unexpected input, or when a security audit flags every endpoint as vulnerable.
Error Messages You Might See
Common Causes
- No validation library configured — The generated project doesn't include Joi, Zod, class-validator, or equivalent validation middleware
- Trust in client-side validation only — Form validation exists in the frontend but the API accepts anything directly
- Missing type coercion — String values like '0' or 'null' are not converted or rejected, causing type confusion
- No payload size limits — The server accepts arbitrarily large JSON bodies or file uploads
- Incomplete schema definitions — Some fields are validated but others (especially nested objects and arrays) are passed through unchecked
How to Fix It
- Add a validation library — Install Zod (TypeScript), Joi (Node.js), or Pydantic (Python) and define schemas for every API endpoint
- Validate at the controller layer — Parse and validate request bodies before they reach your service or database layer
- Define strict schemas — Specify types, min/max lengths, regex patterns, enums, and required fields for every input
- Set payload size limits — Configure body-parser or equivalent to reject oversized requests (e.g., 1MB max)
- Return clear validation errors — Send 400 Bad Request with specific field-level error messages so the client can correct the input
- Test with fuzzing — Submit random, empty, oversized, and malicious inputs to verify your validation catches them
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Why is client-side validation not enough?
Anyone can bypass frontend validation by sending requests directly to your API using curl or Postman. Server-side validation is the only reliable way to ensure data integrity and security.
What validation library should I use?
For TypeScript projects, Zod is the most popular choice. For plain Node.js, use Joi. For Python, Pydantic is standard. All three provide schema definition, type coercion, and clear error messages.