Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

Say a ASP.NET page, or any html page for that matter, has a drop down list with a bunch of prices. On posting the page, the code looks at the selection of the drop down list for a computation. Is it possible for someone to alter the values and post the page without the server knowing the page has been tampered with?

Update

I have been told ASP.NET does offer some protection from this with Page.EnableEventValidation Property. With this enabled (enabled by default), trying to change the value of an ASP control will result in an error:

Invalid postback or callback argument.  Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

share|improve this question
2  
A Grease Monkey script has been developed that does exactly this. –  Sean Cheshire Sep 11 '13 at 19:24
    
Or use firebug. –  Johannes Kuhn Sep 12 '13 at 2:40
add comment

5 Answers

up vote 31 down vote accepted

Dropdown lists are an HTML/UI construct. There isn't any such concept in HTTP, which is how the client and the server ultimately talk to one another.

So, while yes, a client could alter the page, that isn't absolutely required, because there doesn't actually need to be a page. In the end a client simply sends an HTTP request back to the server and it contains some data, and that data could be the values entered into the HTML form, or it could be arbitrary values chosen at the user's whim.

The bottom line is, you can't trust input. Anything sent by the client should be suspect, there's no guarantee that it's what you expect, and it must be validated on the server before acceptance.

share|improve this answer
add comment

Simply, yes it can be done. User downloads the HTML, modifies the content, and sends the from with modified content.

Make absolutely sure that you are validating all form data before it hits your DB. Depending on your web framework, there is usually a way to limit options to exactly what you specify.

share|improve this answer
    
"there is usually a way to limit options to exactly what you specify.": JSF for example automatically discards any data from a submit that was not in the drop-down list rendered by JSF. –  sleske Sep 12 '13 at 9:37
add comment

If you install a proxy on your client, such as Paros, you could very easily trap the response from your browser before it goes to the server and edit any value - including the option chosen from the drop down form element. Once you have seen how easy this is, you can easily imagine how you could do this in a variety of programmatic ways - including add-ons in the browser if your browser was compromised.

The absolutely only way to guard against this is to check that the value once it arrives at the server i.e. that the value is a valid one.

This is true of all data sent to the server, form data, URL GET path data, even headers.

Browser/client based security is no security at all.

share|improve this answer
add comment

If you are using Google Chrome, Simply Right click and Inspect Element.... Then goto that particular select tag, Right click and "Edit as html" to add a new option.

share|improve this answer
add comment

they could inject the data into the response, but if the Server Side code isn't looking for what they are giving, then that is where there injection is halted. Validation in server side code is best.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.