Breaking News

Editors Picks

Wednesday, April 3, 2013

Securing and encrypt View State and Cookies values

Securing View State
If your ASP.NET Web applications use view state:
§  Ensure the integrity of view state (to ensure it is not altered in any way while in transit) by setting the enableViewStateMac to true as shown below. This causes ASP.NET to generate a Message Authentication Code (MAC) on the page’s view state when the page is posted back from the client.
§  <% @ Page enableViewStateMac=true >
§  Configure the validation attribute on the <machineKey> element in Machine.config, to specify the type of encryption to use for data validation. Consider the following:
o    Secure Hash Algorithm 1 (SHA1) produces a larger hash size than Message Digest 5 (MD5) so it is considered more secure. However, view state protected with SHA1 or MD5 can be decoded in transit or on the client side and can potentially be viewed in plain text.
o    Use 3 Data Encryption Standard (3DES) to detect changes in the view state and to also encrypt it while in transit. When in this state, even if view state is decoded, it cannot be viewed in plain text.

<trace enabled="false"/>
<machineKey  validation="3DES"/>
Securing Cookies
Cookies that contain authentication or authorization data or other sensitive data should be secured in transit by using SSL. For Forms authentication, the FormsAuthentication.Encrypt method can be used to encrypt the authentication ticket, passed between client and server in a cookie.

<trace enabled="false"/>
<machineKey  validation="3DES"/>

No comments :

Post a Comment

Contact Us

Name

Email *

Message *