Input sanitization is the process of filtering, validating, normalizing, or constraining data before an application uses it in sensitive operations such as building database queries, generating HTML, or calling system commands. The goal is to make sure attacker-controlled input cannot change program behavior in unsafe ways.
It matters because many common attacks start with malformed or unexpected input. In SQL injection, for example, unsanitized request data can alter a query instead of just filling in a value. Good defenses use allowlists, type checks, escaping where appropriate, and safe APIs such as parameterized queries. Sanitization should happen as close to the trust boundary as possible, especially in framework code or backend-specific handlers where structured input can be transformed into privileged logic.


