Input validation

Checking that data entering an application matches what is expected, such as its type, syntax, size and permitted values, before it is used, preferably on the server against an allowlist.

Input validation checks that data arriving at an application matches what the application expects before the data is processed. Checks commonly cover data type, syntax or format, length, numeric range and, for some fields, a fixed set of permitted values. Validation against an allowlist, which accepts only known good input, is generally stronger than a denylist that tries to reject known bad input, because attackers can find encodings and variations a denylist misses. NIST SP 800-218 gives validating all inputs as an example of following secure coding practices.

Browser-side checks add little security, since an attacker can send requests directly; the validation that counts runs on the server. Input validation also has limits. Data that is well formed can still be dangerous in a particular context, so it is a supporting control rather than the whole fix for injection flaws. SQL injection is addressed mainly with parameterised queries, and cross-site scripting mainly with output encoding, with validation adding a layer to each. It also helps against directory traversal.

Exam relevance: a scenario asking for the best defence against malformed or malicious input is likely to favour server-side validation against an allowlist. Candidates are expected to recognise that client-side validation alone is not enough, and that validation complements parameterised queries and output encoding rather than replacing them.