I'm working on a .NET 4.5 web application(non-MVC) which contains numerous modules. While testing, I found out that my application is vulnerable to Reflected Cross Site Scripting attacks.
For instance this is what my sample URL would look like like:
example.com/abc.aspx?id=1234
Now if someone tries to enter any script in place of id value, for e.g.
id=<somescript>
this script would get executed.
How can I block scripts which are entered in URL from being executed? Currently I'm not focusing on the UI based input elements like textboxes etc.
I need a way to block malicious scripts from being executed through the URL.
I tried to enabling the validateRequest property. Although it blocked the scripts from getting executed throughout the application but there was one problem with it. It also blocked the safe markups which are entered in the UI based input fields(like textboxes) from being executed.
For my application the users expect to enter some sample markups in textareas and textboxes.
Currently I just want to block the browser-URL based XSS scripts. How can I achieve it?
Update:
I've tried adding following custom headers in my web.config file :
X-Xss-Protection - But it's not supported by Firefox
Content-Security-Policy - It's not supported by IE.
The application which I'm working is very big and hence it would take a lot of time for me to make changes in code for validation purposes. Is there any way with which I can make changes at the Web.config level itself?