After reading this article by Eric Lawrence ,I saw this test page http://www.enhanceie.com/test/xss/ which simulates the usage of Reflective XSS Protection
.
Now , According to google chromium :
XSS filter checks whether a script that's about to run on a web page is also present in the request that fetched that web page. If the script is present in the request, that's a strong indication that the web server might have been tricked into reflecting the script.
So , If I post to the server :
<script>alert("bang! script injection\n"+document.cookie);</script>
And the browser also sees it at the request via url:
http://webdbg.com/test/xss/Hello.asp?txtName=%3Cscript%3Ealert%28%22bang%21+script+injection%5Cn%22%2Bdocument.cookie%29%3B%3C%2Fscript%3E
then it shows this error ( console):
The XSS Auditor refused to execute a script in 'http://webdbg.com/test/xss/Hello.asp?txtName=%3Cscript%3Ealert%28%22bang%21+script+injection%5Cn%22%2Bdocument.cookie%29%3B%3C%2Fscript%3E' because its source code was found within the request. The auditor was enabled as the server sent neither an 'X-XSS-Protection' nor 'Content-Security-Policy' header.
But fiddler does show me that the page did get the script to run :
Question :
As the solution to deal with xss is html Encode/decode ,
How/when should I combine between those 2 solutions ?
I mean I could use html encode and scripts would never run in my page , or , I could use this header... ?
Im confused.