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.

282 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sKeep Authentication <strong>and</strong> Personalization Cookies SeparateKeep personalization cookies that contain user-specific preferences <strong>and</strong> non-sensitivedata separate from authentication cookies. A stolen personalization cookie might notrepresent a security threat, whereas an attacker can use a stolen authentication cookieto gain access to your application.Use Distinct Cookie Names <strong>and</strong> PathsUse unique name <strong>and</strong> path attribute values on the element. By ensuringunique names, you prevent possible problems that can occur when hosting multipleapplications on the same server. For example, if you don’t use distinct names, it ispossible for a user who is authenticated in one application to make a request toanother application without being redirected to that application’s logon page.For more information, see Microsoft Knowledge Base articles 313116, “PRB: FormsAuthentication Requests Are Not Directed to loginUrl Page,” <strong>and</strong> 310415, “PRB:Mobile Forms Authentication <strong>and</strong> Different <strong>Web</strong> <strong>Application</strong>s.”Use Absolute URLs for NavigationNavigating between the public <strong>and</strong> restricted areas of your site (that is, betweenHTTP <strong>and</strong> HTTPS pages) is an issue because a redirect always uses the protocol(HTTPS or HTTP) of the current page, not the target page.Once a user logs on <strong>and</strong> browses pages in a directory that is secured with SSL,relative links such as “..\publicpage.aspx” or redirects to HTTP pages result inthe pages being served using the https protocol, which incurs an unnecessaryperformance overhead. To avoid this, use absolute links such as “http://servername/appname/publicpage.aspx” when redirecting from an HTTPS page to an HTTPpage.Similarly, when you redirect to a secure page (for example, the login page) froma public area of your site, you must use an absolute HTTPS path, such as“https://servername/appname/secure/login.aspx”, rather than a relative path,such as restricted/login.aspx. For example, if your <strong>Web</strong> page provides a logonbutton, use the following code to redirect to the secure login page.private void btnLogon_Click( object sender, System.EventArgs e ){// Form an absolute path using the server name <strong>and</strong> v-dir namestring serverName =HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);string vdirName = Request.<strong>Application</strong>Path;Response.Redirect("https://" + serverName + vdirName +"/Restricted/Login.aspx");}

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

Saved successfully!

Ooh no, something went wrong!