Now let's talk about how we can prevent XSS vulnerabilities. These vulnerabilities exist because whenever a user enters something into a textbox or a parameter, that input is displayed in the HTML, so it's treated as if it's part of the page. Therefore, if there is JavaScript in it, the code is executed. To prevent this exploit, the best thing to do is to try and minimize the usage of untrusted input. Given this exploit, we should try to minimize occasions where the user inputs something or where something is input from parameters. Also, make sure that we always escape whatever is going to be displayed or used in the HTML page, because XSS can not only be injected into places where things are displayed on the page, but it can ...
XSS protection
Get Learn Ethical Hacking from Scratch now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.