2

In order to construct an entity with quite a lot of information, I need to performe a sequence of forms submitting. Every time I return a view from a controller, I need to pass some id's about the not yet established entity. Right now I inject these pieces of info into hidden fields, and when post back to server, continuing to construct the entity. This scenario continues for a few times. I'm very not satisfied with this way of passing sensitive information, and was wonder if there're other more appropriate ways of doing it. I use authorization and authentication, but still worried of some scenarios in which one user could hack these id's, before sending it back to server, and by that, modifying the wrong entity.

Also, seems kind of hard work to pass back and forth the same data. I disqualified the use of sessions, because it reveals a different kind of data disruption threat . (in case of using more than one browser at a time).

How should I perform the mentioned operation?

Tal l
  • 265
  • 1
  • 3
  • 12
  • 1
    See @Jason's answer about signing (aka creating a hash). Hidden fields will not protect you, nor will "readonly" input fields. Encrypt/decrypt isn't really appropriate either - the client (browser) will always be sending the original data in clear text. If you're thinking about encryption libs on the client side - sure, but again, that's client side (can be seen/inspected, no matter what). Create a hash server-side and compare the hash server-side. – EdSF May 08 '12 at 19:25
  • Thanks! unfortunately I can't vote your comment... – Tal l May 08 '12 at 20:50

3 Answers3

2

You can use a secure hash of the data in another hidden field to detect tampering with the values.

Here is an example of how to generate a cryptographically secure hash http://www.bytemycode.com/snippets/snippet/379/

Jason C
  • 142
  • 3
0

You can secure your data using many approaches, I discussed some of it in this post

http://miroprocessordev.blogspot.com/2012/03/save-aspnet-mvc-application-against.html

http://miroprocessordev.blogspot.com/2012/03/safe-aspnet-mvc-application-against.html

Amir Ismail
  • 3,865
  • 3
  • 20
  • 33
  • I can't see how can a user be prevented from maliciously success to modify DB entities by changing form fields before making a post. – Tal l May 08 '12 at 13:40
  • 1
    make these fields readonly and you can encrypt/decrypt critical data and compare the decrypted data with corresponding DB entities to prevent user from update it. – Amir Ismail May 08 '12 at 14:08
0

use Cross-site request forgery with token to identify that everytime u send an info it contains same token generated at server side and returned from your html

Rizstien
  • 802
  • 1
  • 8
  • 23
  • This seems to be an answer for a different question. It inteneded to avoid 'Cross-Site Request'. Am I right? – Tal l May 08 '12 at 15:11