Do not trust the several items in program development

Source: Internet
Author: User

The examples in the link are some content related to script attacks. If you have time, click here.

1. Do not trust request. querystring:

I believe that in the ASP era, this problem is serious. If you don't believe it, you can find several ASP enterprise sites on the network and find the URL "view. asp? Id = xxx ", changed to" view. asp? Id = xxx or 1 = 1 ", I believe you will see something different. net, it should be very rare, but the last time someone saw that csdn had exploded, the simple solution was to perform data type verification or conversion when obtaining data. For example:
Int viewid = 0;
If (Int. tryparse (request. querystring ["ID"], out viewid )){
//...
}
2. Do not trust maxlength:
Sometimes we want the client to enter a value of no more than a certain length. In this case, the maxlength of input may be used. But can maxlength be 100% to ensure that the length of this value cannot exceed maxlength?Xmlns = "http://www.w3.org/1999/xhtml">

Under normal circumstances, you can only enter four characters in the input box above, but is it true that the data post to us by the user?
Javascript: Alert (window. c = function () {document. getelementsbytagname ("input") [0]. value = "Do you think I have four characters in length? "}())

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.