Input validation is a check on incoming data. Before your site uses a value, it confirms the value meets the application's own requirements. The value might come from a contact form, a booking widget, a checkout field or an API call. OWASP's Input Validation Cheat Sheet says this reduces three risks: malformed data, invalid business operations and excessive resource consumption. For a business owner, that means fewer broken records, fewer orders that make no sense, and less chance that one oversized request slows the site for everyone.
What input validation does, and the three jobs it does not do
Owners often think validation is a cure-all. It is not. The same OWASP page separates validation from the defenses you still need when the data is used. Database queries still need parameterized queries to prevent SQL injection. Anything shown back to visitors still needs context-aware output encoding to prevent cross-site scripting. Authorization is a third job that also stays separate. A properly formatted customer or account number proves only that the number is well formed. It does not prove the person sending it may see that account.
This is the most useful framing to take into a conversation with your developer or agency. Validation is one layer with a clear job. If a team says form checks protect the site against injection or unauthorized access, ask where the parameterized queries, output encoding and separate authorization checks are.
Sources: cheatsheetseries.owasp.org [1]
Check both the shape of a value and whether it makes sense
OWASP asks for two kinds of checks. Syntax is the expected type and format, for example whether a value is a date. Semantics is whether the value makes sense for the operation being performed. The cheat sheet's example is a booking. Both dates must be valid dates, and the end date must come after the start date. A form that accepts a check-out date earlier than the check-in date has passed the syntax test and failed the semantic one. CWE-20 covers these checks, including consistency between related fields.
The cheat sheet then sets out a rule for each kind of field:
Fixed choices need exact membership in the allowed set. This includes values submitted from drop-down menus. The browser shows only your options, but the server must still confirm that the submitted value is one of them.
Numbers and dates need the expected type, an accepted format, and minimum and maximum values. A quantity field with no maximum, or a date with no sensible range, is incomplete.
Strings need length limits and the characters or structure the field requires.
Objects, meaning grouped data such as an address sent as one unit, need rules for allowed fields, required fields, and missing or null values.
Arrays, or lists, need minimum and maximum item counts. Every item in the list must be validated, including nested objects.
You can use this as a review sheet with your developer. For each form or API endpoint that matters to your business, ask which of these rules applies to each field and where on the server it is enforced.
Sources: cheatsheetseries.owasp.org [1]
Allowlists beat denylists, and why blocking apostrophes is a warning sign
OWASP's direction is to define what the application accepts and reject values outside those rules. It does not ask you to try to recognize every malicious string. This is the allowlist approach, as opposed to a denylist that tries to spot and block bad input.
The cheat sheet gives a concrete example that owners may recognise. Blocking apostrophes rejects legitimate names without making a database query safe. A customer whose surname contains an apostrophe is turned away, and the query is still not protected. If your site rejects real names, the protection you are relying on may be a denylist rather than proper query handling.
An allowlist does not have to be harsh. For free-form comments, OWASP notes that an allowlist can permit broad Unicode text while limiting its length. It need not restrict users to letters and digits. A good rule fits the field: strict for a postcode or quantity, permissive but length-limited for a message box.
Sources: cheatsheetseries.owasp.org [1]
Size limits come first: parse safely, then validate
The order of operations matters. OWASP says to apply request size limits before buffering or parsing input, and to configure parser limits such as maximum nesting depth. The reason is direct: a schema check after parsing cannot protect a parser that has already exhausted resources. A rule that rejects a huge request after the server has spent its memory reading it has already failed at the availability problem.
The cheat sheet also says to use a maintained parser for the expected format and to handle parsing failures. The resulting values must then be validated before business processing or storage. Parsers that handle untrusted input need configuring for it, and the page points to its XML External Entity Prevention and Deserialization guidance for that.
Type conversion is not validation. OWASP notes that converting text to an integer only establishes a type, not an acceptable quantity. A field that turns "999999" into a number has confirmed it is a number. It has not confirmed that anyone should be able to order that many items.
Decoding is a quieter trap. The guidance is to decode according to the protocol before checking field rules, and to validate the representation that will actually be used. It also warns against decoding again downstream, because CWE-20 explains how inconsistent decoding can invalidate earlier checks. In plain terms, check the value in the exact form your application will use, and do not transform it again afterwards.
Sources: cheatsheetseries.owasp.org [1]
Structured data and free-form text
Many sites accept structured data, especially through APIs that use JSON. OWASP recommends using your framework's validators or a schema validator to enforce field rules. It flags one common misunderstanding. For JSON, required and additional properties must be configured explicitly, because merely listing a property neither requires it nor rejects unknown fields. A schema that looks thorough can still let missing or unexpected fields through.
The cheat sheet adds that business checks, such as date ordering, belong alongside these structural checks. Invalid requests should be rejected with a clear error, and the application should not continue with partially validated data. It also says to bind only intended input fields to application objects, pointing to its Mass Assignment guidance.
Names and comments need care in the other direction: they must not reject real people. OWASP says to agree on a character encoding across components, reject malformed input, and preserve legitimate punctuation and scripts in names and comments. Some fields need Unicode normalization so that comparisons are consistent. Where they do, the same policy should be defined and applied before validation, storage and comparison. The page is explicit that normalization is not sanitization and does not replace output encoding.
Sources: cheatsheetseries.owasp.org [1]
Regular expressions: useful for simple fields, risky when careless
Regular expressions are patterns that developers use to check text. OWASP limits them to simple, structured fields. It requires a match of the entire value, using an API such as Python's fullmatch where available. A pattern that matches only part of the input can let extra text slip through after a valid-looking beginning.
Patterns do not behave identically across languages. The cheat sheet advises checking the engine's character classes and newline behavior rather than assuming. It also lists protections against slow patterns. Input length should be bounded before matching, patterns with excessive backtracking avoided, and a non-backtracking engine or a match timeout used where supported.
Testing should cover valid, invalid and near-matching values. OWASP cites Microsoft's regex guidance on why near-matches can cause denial of service, and says a timeout must be treated as validation failure. For an owner, the practical question is whether the team tests patterns with almost-valid input and caps input length first.
Sources: cheatsheetseries.owasp.org [1]
Rich content, file uploads and email addresses need their own controls
Some inputs are beyond what field rules can handle. If your site lets users submit HTML, for example formatted reviews or forum posts, OWASP says to use a maintained HTML sanitization library. It states plainly that input validation and regular expressions cannot replace that control.
File uploads are a similar case. The submitted filename and content type are untrusted metadata. Filenames should be validated after protocol decoding. An allowed extension alone does not establish safe content. A file named like a photo is not proven to be a photo. OWASP refers readers to its File Upload Cheat Sheet for content checks, size limits, storage and safe serving. If a filename or any other input becomes part of a file system path, it points to its Path Traversal Prevention Cheat Sheet.
For email addresses, the cheat sheet recommends a maintained email validation library compatible with the addresses your mail system supports. It notes that format validation does not prove mailbox access. A correctly formatted address shows nothing about whether the person controls that inbox.
Sources: cheatsheetseries.owasp.org [1]
The input owners forget: Host and forwarded headers
Not every input is a form field. OWASP points out that the Host header is chosen by the client. So are the Forwarded and X-Forwarded-* headers, unless a proxy you control sets them. If an application uses these headers to build links, pick a tenant or route a request, it can be made to put an attacker's domain in the password reset links it sends. The same weakness can be used to poison a cache or reach an internal virtual host.
The cheat sheet's guidance is to build absolute URLs, such as password reset and email links, from configuration instead of from the request. Only the hostnames the application serves should be accepted, and other requests rejected. Many frameworks have a setting for this. OWASP names Django's ALLOWED_HOSTS, ASP.NET Core's AllowedHosts and Rails' config.hosts. It warns that the setting must be set explicitly. Rails does no Host checks outside development until config.hosts is set, and ASP.NET Core's host filtering is disabled by default. The catch-all * should not be used, because it allows any host.
Forwarded and X-Forwarded-* values should be used only when they come from your own proxies, and the proxy at the edge should remove any that arrive from clients. If your site runs on Django, ASP.NET Core or Rails, ask your developer whether the host setting is explicitly configured without a wildcard, and whether reset emails take their domain from configuration.
Sources: cheatsheetseries.owasp.org [1]
Questions and answers
What does input validation protect a website against, and what does it not replace?
OWASP's Input Validation Cheat Sheet says this reduces three risks: malformed data, invalid business operations and excessive resource consumption.
Does input validation stop SQL injection and cross-site scripting?
Database queries still need parameterized queries to prevent SQL injection. Anything shown back to visitors still needs context-aware output encoding to prevent cross-site scripting.
Should a website use an allowlist or a denylist for input?
OWASP's direction is to define what the application accepts and reject values outside those rules.
Why should request size limits come before parsing?
a schema check after parsing cannot protect a parser that has already exhausted resources
Is an allowed file extension enough to make an upload safe?
An allowed extension alone does not establish safe content.
Why does the Host header need validation?
it can be made to put an attacker's domain in the password reset links it sends
Pick your three most important forms and walk through these field rules with your developer this week.

