WEBA-1Lesson 1 of 39 min

Never trust input: check on the server

Websites and web apps take input from people they cannot see or control. Almost every web security bug comes from trusting that input too much. This lesson sets out the first rule.

The browser belongs to the user

Anything that happens in the browser is under the user’s control. Hidden fields, greyed-out buttons, price boxes and checks written into the page can all be changed or skipped. Requests can be sent to the server without the page at all.

Figure WEBA-1.1A check in the browser, and a check on the server

marks form, in the browser

Maths mark for 21CS047: 780–100 OK
Maths mark: 450BLOCKED BY PAGE
1/4

A teacher enters marks in a web form. The page has a check built into it: the box accepts only numbers from 0 to 100, and shows an error otherwise. This check runs in the teacher's browser.

Step 1 of 4

Check on the server

Allow what is valid

There are two ways to check input. A blocklist rejects inputs that look bad, such as certain characters. An allowlist accepts only inputs that look exactly as expected, such as “a whole number from 0 to 100” or “a roll number in the form 21CS047”. Blocklists always miss something nobody thought of. OWASP, the leading web security project, recommends allowlists. One of this course’s books relies on filtering out bad characters; that advice is out of date.

WEBA-1 counts as completed once you step through the figure to its last step.