If you do this to trust the code you sent to the client browser, change direction. You really don't want to trust user input, which includes calls from js that you sent to the browser. The logic on the server must be made so that nothing happens there. However, asp.net uses a signed field, you can go this way if absolutely necessary.
Bit extension: Asp.net tamper-proofs viewstate, which is sent as a html hidden field (depending on configuration). I am sure there are better links as a link, but at least it is mentioned on this: http://msdn.microsoft.com/en-us/library/ms998288.aspx
checks. This indicates a hashing algorithm used to generate HMACs to do ViewState and ticket authentication forms. This attribute is also used to indicate the encryption algorithm used for ViewState Encryption. This attribute supports the following parameters:
- SHA1-SHA1 is used to protect ViewState and, if configured, authentication forms from unauthorized access. When SHA1 is selected to test the attribute, the algorithm used is HMACSHA1.
The link for the .net class for this algorithm is http://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha1.hmacsha1.aspx .
Update 2: To protect against unauthorized access, you want to sign data (do not encrypt). Note that when using cryptography in general, you should really avoid using a custom implementation or algorithm. As for the steps, I would stick with:
- Assign a token to a JavaScript variable (server-side generated). You include information to identify the request and the exact date and time it was issued. The signature will be verified by the server-side application that issued the data.
- Identify duplicate views, if necessary.
However, the reason asp.net checks the default view state is because developers rely on the information coming in there as they only process the application when they don’t. The same probably applies to your scenario, do not rely on this mechanism. If you want to evaluate whether someone can do something, use authentication + authorization. If you want to know that the ajax call only sends valid parameters, check them out. Do not expose the API at the level of detail than the one where you can allow actions accordingly. This mechanism is only an additional measure if something slips, and not real protection.
Ps. with HMACSHA1 above, you must create an instance using a fixed key
eglasius
source share