Input validation — checking that user input meets expected criteria before processing it — is a foundational security practice. Since attacks often come through malicious input, validating (and sanitizing) input helps prevent many vulnerabilities. A core principle: never trust user input.
Never trust user input
ALL input from outside (users, APIs, files, requests) is UNTRUSTED — it can be malicious:
→ attackers send crafted input to exploit vulnerabilities (injection, XSS, etc.)
→ "never trust the client" — input can be anything, including attacks
→ Validate and handle ALL external input as potentially hostile.
