Sanitization is the process of removing, escaping, or neutralizing unsafe input before an application renders or processes it. In security-sensitive software, this usually means treating all external data as untrusted until it has been checked and transformed into a safe form.
It matters because many attacks begin with malicious input: script injection in a web page, command fragments sent to a backend, or crafted markup that confuses a parser. Good sanitization helps prevent cross-site scripting, injection flaws, and content-based abuse in systems such as webmail, where messages may include HTML, links, attachments, and remote content. Defenders use context-aware sanitization rules for each sink, such as HTML rendering, URL handling, or database queries, and combine them with validation and output encoding. Weak or inconsistent sanitization often turns a harmless-looking message into a browser-side exploit or a backend trust problem.


