views:

34

answers:

2

Hi everyone,

I'm using ASP.Net but my question is a little more general than that. I'm interested in reading about strategies to prevent users from fooling with their HTML form values and links in an attempt to update records that don't belong to them.

For instance, if my application dealt with used cars and had links to add/remove inventory, which included as part of the URL the userid, what can I do to intercept attempts to munge the link and put someone else's ID in there? In this limited instance I can always run a check at the server to ensure that userid XYZ actually has rights to car ABC, but I was curious what other strategies are out there to keep the clever at bay. (Doing a checksum of the page, perhaps? Not sure.)

Thanks for your input.

+1  A: 

You want to find out how to use a session.

Sessions on tiztag.

If you keep track of the user session you don't need to keep looking at the URL to find out who is making a request/post.

runrunraygun
+1  A: 

The following that you are describing is a vulnerability called "Insecure Direct Object References" And it is recognized by A4 in the The OWASP top 10 for 2010.

what can I do to intercept attempts to munge the link and put someone else's ID in there?

There are a few ways that this vulnerability can be addressed. The first is to store the User's primary key in a session variable so you don't have to worry about it being manipulated by an attacker. For all future requests, especially ones that update user information like password, make sure to check this session variable.

Here is an example of the security system i am describing:

"update users set password='new_pass_hash' where user_id='"&Session("user_id")&"'";

Edit:

Another approach is a Hashed Message Authentication Code. This approach is much less secure than using Session as it introduces a new attack pattern of brute force instead of avoiding the problem all togather. An hmac allows you to see if a message has been modified by someone who doesn't have the secret key. The hmac value could be calculated as follows on the server side and then stored as a hidden variable.

hmac_value=hash('secret'&user_name&user_id&todays_date)

The idea is that if the user trys to change his username or userid then the hmac_value will not be valid unless the attacker can obtain the 'secret', which can be brute forced. Again you should avoid this security system at all costs. Although sometimes you don't have a choice (You do have a choice in your example vulnerability).

Rook
Thanks everyone. I know about the session variable in ASP.Net and have used it well in the past. I was wondering if there were other ways to go about this, and also: I'm sure Microsoft and anyone else who has implemented session objects has given this much thought, but how do they prevent session tampering from the browser? If I recall it's stored in ViewState in ASP.Net, which is accessible on the page. My first assumption again is there's a checksum involved to prevent that mischief?
larryq