views:

43

answers:

2

Hey,

I've got a DropDownList and I'm trying to prevent it from being used as an attack vector. Can I assume that the user is unable to actually change the values of the DDL and postback to the server? At the moment, I get this ASP.NET error message thrown if I try and change the packet after submission:

For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.

Am I right in thinking that this is due to the integrity being compromised in the viewstate hash? Can this be bypassed?

Thanks

+3  A: 

No, you can't assume that.

You should always consider that all input is untrusted, and treat it appropriately (make sure it is what it should be, and that it is of the right type, and that the current user (or whatever) has access to it, and so on).

Noon Silk
+2  A: 

Actually you should be able to assume that the dropdown list options have not been changed client side as long as the page has EnableEventValidation = true (which is default although you can disable it per page or in the web.config). If a new value is added to your dropdownlist client side, and a postback occurs an error will occur unless you register this new value for event validation (http://odetocode.com/blogs/scott/archive/2006/03/21/asp-net-event-validation-and-invalid-callback-or-postback-argument-again.aspx)

Matt Dearing
See, this is what I thought was the case. I messed around with the DDL but could only get the error message. Can anyone confirm one way or the other?Thanks
SSL
Generally I would agree that you cannot trust what is coming from the client (this is one of the reasons you set up asp.net validator controls to validate client and server side), but in this case you can be sure the ddl has not been mucked with as long as EventValidation is enabled. Even if you tried to validate your ddl and postback event server side, you would probably be doing the same thing ASP.Net is doing with EventValidation set to true.
Matt Dearing