Use the antixss. htmlencode method to prevent cross-site scripting attacks.

Source: Internet
Author: User

It seems necessary to explain clearlyAntixss. htmlencodeAndHttputility. htmlencodeAndServer. htmlencodeThe specific differences between them are a bit difficult, but they can basically be used to prevent the site from being attacked by malicious script injection. According to msdn, htmlencode can only be used to escape '<', '>', '&', and '"'. It also contains ASCII codes greater than 0x80, however, this depends on the server environment. Different versions of IIS Escape may vary. For example, publishing a site to IIS6 is different from publishing it to iis7. In addition, if you only debug Web applications onProgram, Htmlencode escape conditions are also different.

What is a cross-site scripting attack and why is it necessary to prevent cross-site scripting attacks? You can refer to this blogArticleHttp://www.cnblogs.com/alilang/archive/2013/01/28/2879589.html

RelatedAntixss. dllThe introduction, you can refer to the msdn http://msdn.microsoft.com/en-us/library/aa973813.aspx of this Article

Consider the following scenario:

    Br  />     IMG   id   = 'img <% = server. htmlencode (request. querystring ["userid"]) %  > 'src = '/image.gif'/>   Br  />     Br  />   an attacker cocould inject client-side script here by setting userid: 'onload = alert ('xss') alt = '    Br  />  

In some specific environments, the preceding htmlCodeThere is a risk of injection script attacks. For example, the user passes the following parameter after the URL of the Request page:? Userid = 'onload = alert (XSS) alt'

The injected script is successfully executed on the page! The reason may be thatServer. htmlencodeIt cannot effectively filter out malicious characters in user input. The same situation may also occur in httputility. htmlencode. When this happens, consider replacing itAntixss. htmlencodeMethod.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.