Bitzu

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

Single choice

Which validation approach is generally preferred?

  1. A denylist of known malicious strings
  2. An allowlist of what is known to be acceptable
  3. Trusting the browser to filter input
  4. 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.

Select all that apply

Which statements about sound input validation are correct?

  1. It must be enforced on the server
  2. A JavaScript check in the browser is sufficient
  3. Prefer allowlists to denylists
  4. A denylist is the most robust option
  5. 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

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.

Download on the App StoreGet it on Google Play

More CPSA topics in this module