web input

Everything from a request is untrusted That includes cookies, headers, and file names

Superglobals

$_GET , $_POST , $_FILES , $_COOKIE , $_SERVER They are arrays populated by the runtime Do not trust their shape without checking

Filtering

$port = filter_var("8443", FILTER_VALIDATE_INT);

Output:

8443

Invalid input returns false That is better than a cast, which turns nonsense into zero

Output

Escape on the way out, not on the way in HTML context needs HTML escaping A JSON response needs JSON encoding One universal sanitizer does not exist

Sessions

8.6 enables stricter session defaults: strict mode, HTTP only cookies, SameSite Lax Do not undo them for convenience Regenerate the session id after a privilege change

Next

What changed in 10 current

Posted