CPSA ยท Web application assessment: recon, access control and input
Input validation strategies
Whitelisting vs blacklisting vs sanitisation and where validation must be enforced.
Key points
- Allowlist: accept only known good; preferred over a denylist (block known bad), which attackers routinely get around.
- Syntax: type, format, length. Semantics: does the value make sense for the operation.
- Enforce on the server; client-side checks only help usability.
- Sanitisation: rewrites data, suits user-authored HTML via a maintained library; does not replace validation, parameterised queries or output encoding.
Source: https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html
Practice questions
Which validation approach is generally preferred?
- A denylist of known malicious strings
- An allowlist of what is known to be acceptable
- Trusting the browser to filter input
- Accepting everything and logging it
Show answer
Answer: B. An allowlist of what is known to be acceptable
An allowlist defines exactly what is acceptable and rejects the rest. Denylists miss variants, and trusting the client or accepting anything are not validation at all.
Which statements about sound input validation are correct?
- It must be enforced on the server
- A JavaScript check in the browser is sufficient
- Prefer allowlists to denylists
- A denylist is the most robust option
- Check both syntax (type, format) and semantics (sense for the operation)
Show answer
Answer: A. It must be enforced on the server, C. Prefer allowlists to denylists, E. Check both syntax (type, format) and semantics (sense for the operation)
Validation must run on the server, should use an allowlist, and should check both syntax and meaning. A JavaScript check is a usability feature, and a denylist is the weaker approach, not the most robust.
True or false: client-side validation is enough because ordinary users cannot get around the JavaScript.
Show answer
Answer: False
False. Attackers do not use your form: they send requests directly, so every check must be repeated on the server. Client-side checks only improve user experience.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
