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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

262 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sConsider the Identity That Is Used for Resource AccessBy default, ASP.NET applications do not impersonate, <strong>and</strong> the least privilegedASPNET process account is used to run ASP.NET <strong>Web</strong> applications <strong>and</strong> for resourceaccess. The default is the recommended configuration. There are several situations inwhich you may want to use a different Windows security context for resource access.These include:● Hosting multiple applications on the same serverYou can use IIS to configure each application to use a separate anonymousInternet user account <strong>and</strong> then enable impersonation. Each application then hasa distinct identity for resource access. For more information about this approach,see Chapter 20, “Hosting Multiple <strong>Web</strong> <strong>Application</strong>s.”●Accessing a remote resource with specific authentication requirementsIf you need to access a specific remote resource (for example, a file share) <strong>and</strong> havebeen given a particular Windows account to use, you can use configure thisaccount as the anonymous <strong>Web</strong> user account for your application. Then you canuse programmatic impersonation prior to accessing the specific remote resource.For more information, see “Impersonation” later in this chapter.Protect Credentials <strong>and</strong> Authentication TicketsYour design should factor in how to protect credentials <strong>and</strong> authentication tickets.Credentials need to be secured if they are passed across the network <strong>and</strong> while theyare in persistent stores such as configuration files. Authentication tickets must besecured over the network because they are vulnerable to hijacking. Encryptionprovides a solution. SSL or IPSec can be used to protect credentials <strong>and</strong> tickets overthe network <strong>and</strong> DPAPI provides a good solution for encrypting credentials inconfiguration files.Fail SecurelyIf your application fails with an unrecoverable exception condition, make sure that itfails securely <strong>and</strong> does not leave the system wide open. Make sure the exceptiondetails that are valuable to a malicious user are not allowed to propagate to the client<strong>and</strong> that generic error pages are returned instead. Plan to h<strong>and</strong>le errors usingstructured exception h<strong>and</strong>ling, rather than relying on method error codes.

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

Saved successfully!

Ooh no, something went wrong!