Does an ASP.NET application protect against cross-site scripting by default? I have read that the machine.config file has an attribute that is set to on by default and this protects against cross-site scripting? Is this true?
-
by default you cannot submit a script like tag to an ASP.NET form, on MVC every output get HTML encoded before being printed to the client, so the answer is yesAMember– AMember2013-07-06 13:18:48 +00:00Commented Jul 6, 2013 at 13:18
-
Thanks :) That's what I wanted to hear :) So an ASP.NET application automatically protects against cross-site scripting by default?Matthew– Matthew2013-07-06 13:19:31 +00:00Commented Jul 6, 2013 at 13:19
-
xss is covered, csrf is not. You can try to create a simple form and test it yourselfAMember– AMember2013-07-06 13:22:01 +00:00Commented Jul 6, 2013 at 13:22
-
Yes. In fact I tested it on a web application of mine and when I entered characters like "<>", an exception was raised.Matthew– Matthew2013-07-06 13:23:15 +00:00Commented Jul 6, 2013 at 13:23
Add a comment
|
1 Answer
<system.web>
<pages buffer="true" validateRequest="true" />
</system.web>
you can use antxss library as addition
2 Comments
Matthew
Thanks :) That's the line I was talking about. That protects against cross-site scripting. Am I correct in saying that?
Erlend
That question has been asked many times before. The answer is "it depends on your app". See my answer here: stackoverflow.com/questions/9733427/…