sanitization
Cleaning untrusted input by removing or neutralising anything dangerous, such as script tags and event attributes in HTML.
In more detail
It differs from escaping, which keeps all the text but makes it harmless for its context. Use a well-tested library or the platform's built-in sanitizer rather than writing your own regular expressions, which attackers routinely bypass.
Related terms
- Trusted Types — A browser security feature that makes dangerous DOM sinks such as innerHTML reject plain strings and accept only values produced by a policy you define.
- cross-site scripting — An attack in which someone gets their own script to run inside your page, where it can read data, act as the user or steal tokens.
Taught in
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform