11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 21: Code Review 633Do You Secure View State?If your application uses view state, is it tamperproof? Review the followingquestions:● Is view state protection enabled at the application level?Check the enableViewState attribute of the element in the applicationMachine.config or <strong>Web</strong>.config file to see if view state is enabled at the applicationlevel. Then check that enableViewStateMac is set to “true” to ensure it istamperproof.●●Do you override view state protection on a per page basis?Check the page-level directive at the top of your <strong>Web</strong> pages to verify that viewstate is enabled for the page. Look for the enableViewStateMac setting <strong>and</strong> ifpresent check that it is set to “true”. If enableViewStateMac is not present <strong>and</strong> setto true, the page assumes the application-level default setting specified in the<strong>Web</strong>.config file. If you have disabled view state for the page by settingenableViewState to “false” the protection setting is irrelevant.Do you override view state protection in code?Check that your code does not disable view state protection by settingPage.EnableViewStateMac property to false. This is a safe setting only if the pagedoes not use view state.Are Your Global.asax Event H<strong>and</strong>lers Secure?The global.asax file contains event h<strong>and</strong>ling code for application-level eventsgenerated by ASP.NET <strong>and</strong> by HTTP modules. Review the following event h<strong>and</strong>lersto ensure that the code does not contain vulnerabilities:● <strong>Application</strong>_Start. Code placed here runs under the security context of theASP.NET process account, not the impersonated user.● <strong>Application</strong>_BeginRequest. Code placed here runs under the security context ofthe ASP.NET process account, or the impersonated user.● <strong>Application</strong>_EndRequest. If you need to modify the properties of outgoingcookies, for example to set the “Secure” bit or the domain,<strong>Application</strong>_EndRequest is the right place to do it.●●●<strong>Application</strong>_AuthenticateRequest. This performs user authentication.<strong>Application</strong>_Error. The security context when this event h<strong>and</strong>ler is called canhave an impact on writing the Windows event log. The security context might bethe process account or the impersonated account.protected void Session_End. This event is fired non-deterministically <strong>and</strong> only forin-process session state modes.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!