Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The sure way to protect against XSS?

Tags:

security

xss

I've looked through the questions and I haven't seen anyone ask this yet.

What is the for sure method to remove any sort of XSS attempts in some user submitted content? I know that < and > should be converted to &lt; and &gt; respectively but I've heard mention that encoding differences can get around this too.

Supposing a whitelist, what are all the steps to completely clean some user submitted content to ensure that no XSS vulnerabilities exist?

like image 449
Spencer Ruport Avatar asked Jan 20 '26 04:01

Spencer Ruport


1 Answers

There is no absolute security concering XSS since people find new attack vectors every day. Sometimes XSS is even a browser bug you cant do anything about (excep some workarounds).

To get the idea of the complexity look at this (incomplete) xss attack cheat sheet.

http://ha.ckers.org/xss.html

Guess you should make yourself a XSS expert or hire one to reach your goal.

You can start by inspecting the attack vectors from the given link above, try to understand why it can work and make sure you prevent it.

Another great way of preventing XSS is to make sure you accept only stuff you expect instead of blocking stuff you know is bad. (i.e. whitelisting instead of blacklisting)

like image 181
Henri Avatar answered Jan 23 '26 20:01

Henri