Allow Lists

In computer science, an allow list (formerly "whitelist") is a list of valid inputs to a system. Anything not on the list is refused.

Allow lists are one of the most reliable ways to validate input, because they fail safe. If you forget to add a value, a legitimate user gets an error message. Compare this with a block list, where forgetting a value lets an attacker in. Some examples:

  • A file upload that accepts only .png, .jpg and .gif files.
  • A sort parameter that must be one of name, date or price, rather than any column name the user cares to type.
  • An API that copies only named fields from a request into a database record, which prevents mass assignment.
  • A CORS policy that names the domains allowed to call your API.

When an allow list is impractical (for free-text fields, say), validate the format of the input instead, and escape it wherever it is used.

Further Reading

Learn it hands-on

Automatically unpacking data from the HTTP request can sometimes be too easy.