Web Security (4): Over-Posting and security-related posting

Source: Internet
Author: User

Web Security (4): Over-Posting and security-related posting

Introduction

Too many posts are relatively simple. Therefore, I only want to translate some key information in the original article. The original Article link is as follows:

Http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application#overpost

Download sample code:

Https://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8

Analysis

Suppose there is a class Student, which is used to establish a ing with the database, and you do not want to modify the value of a field Secret in Student on the page.

  

Even if there is no Secret field on the interface, hacker can use some tools (such as fildder) or write js to send requests to modify the Secret value.

For example, the Secret value is changed to OverPost.

 Prevent

In ASP. NET, there are several methods to prevent too many releases:

1. Use the Include attribute in BindAttribute to add the fields to the whitelist.

  Public ActionResult Create ([Bind (Include = "LastName, FirstMidName, EnrollmentDate")] Student student)

2. Use the Exclude attribute in BindAttribute to add fields that cannot be mapped to the blacklist.

  Public ActionResult Create ([Bind (Exclude = "Secret")] Student student)

3. Use the TryUpdateModel method to specify the fields to be mapped when verifying the Model.

  If (TryUpdateModel (student, "", new string [] {"LastName", "FirstMidName", "EnrollmentDate "}))
{}

4. define a new class as the input parameter

Public class StudentForm
{
Public string LastName {get; set ;}

Public string FirstMidName {get; set ;}

Public DateTime EnrollmentDate {get; set ;}
}

 

Article Reprinted from: http://www.cnblogs.com/Erik_Xu/p/5497501.html

Related Article

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.