2

Request.QueryString is not very safe. Incase someone is logged in. Just by typing in the URL

myaccount.aspx?custId=10

One can get the information of another Customer.

So its not safe at all. The reason for posting this was because, I wanted an alternative way of passing customerId between pages. Perhaps encrypt it?

user478636
  • 3,304
  • 15
  • 49
  • 76
  • I hope for a lengthy answer, as else wise you are not up to creating a site with confidential data. Security in web is pretty complex and error prone. – Dykam Apr 13 '11 at 19:24

7 Answers7

2

Query strings are safe and are not flawed.

What is flawed and unsafe is trusting user input data. It is your responsibility to verify the data being sent to the server is not malicious and that the requested action is allowed for the logged in user.

You should take that query stirng value, make sure it is the valid type (your example appears to be an integer) and then before fetching the customer's data, make sure the user is allowed to access that customers data.

Bob
  • 97,670
  • 29
  • 122
  • 130
2

Really for myaccount.aspx you shouldn't need to a user to pass their ID in as a parameter.

As others have said, use Membership. Or create a hash (an encypted value) of a user's ID and password and save that as a cookie or in the session object. You can read that instead of an input parameter.

Gavin Ward
  • 1,022
  • 8
  • 12
1

That's not the responsibility of the QueryString. You should implement an authenication and authorization system, preferably with a MembershipProvider and RolesProvider.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
1

It does what it's supposed to do. It is up to you to secure your site. No one said everything in the querystring is used for sensitive access related functionality.

Joe
  • 734
  • 1
  • 8
  • 14
1

There is no safe way to pass it. Once the user has logged in, store the ID in Session or something equivalent, then always take it from there.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
1

You can check asp.net membership

zer0w1dthspace
  • 1,042
  • 2
  • 17
  • 34
0

You should be using ASP.NET security to authenticate and authorize customers so that the logged in user is checked to see if they have access to the customer ID specified in the query string.

Mark Cidade
  • 98,437
  • 31
  • 224
  • 236