Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't ValidateRequest="true" enough for XSS prevention?

Tags:

c#

.net

asp.net

xss

In the notes for Step 1 in the "How To: Prevent Cross-Site Scripting in ASP.NET" it is stated that you should "not rely on ASP.NET request validation. Treat it as an extra precautionary measure in addition to your own input validation."

Why isn't it enough?

like image 218
Peter Evjan Avatar asked Apr 01 '10 09:04

Peter Evjan


2 Answers

For one thing, hackers are always coming up with new attacks and new ways of inserting XSS. ASP.NET's RequestValidation only gets updated when a new version of ASP.NET gets released, so if someone comes up with a new attack the day after an ASP.NET release RequestValidation won't catch it.

That (I believe) is one of the reasons why the AntiXSS project appeared, so it can have a faster release cycle.

like image 59
PhilPursglove Avatar answered Oct 06 '22 01:10

PhilPursglove


Just two hints:

  • Your application might output not only data that was entered using your ASP.NET forms. Think of web services, RSS feeds, other databases, informations extracted from user uploads etc.

  • Sometimes it's necessary to disable the default (effective but overly simple) request validation because you need to accept angle brackets in your forms. Think of a WYSIWYG editor.

like image 31
realMarkusSchmidt Avatar answered Oct 05 '22 23:10

realMarkusSchmidt