How do you avoid XSS vulnerabilities in ASP.Net (MVC)?

后端 未结 5 1940
庸人自扰
庸人自扰 2020-11-28 11:25

I recently noticed that I had a big hole in my application because I had done something like:

\" />
         


        
5条回答
  •  死守一世寂寞
    2020-11-28 11:57

    In ASP.Net 4.0 or later, always use <%: ... %> instead of <%= ... %> ... it does the HTML encoding for you.

    Scott Gu's explanation.

    Having done that, it's fairly straightforward to grep your code for <%= regularly as a security precaution.

    Also, are you using the Microsoft Anti-XSS library?

提交回复
热议问题