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.

250 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sUsing Default CredentialsYou might need to call a <strong>Web</strong> service that uses Windows authentication <strong>and</strong> specifyauthentication credentials through the proxy credential cache. For example:proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;In this case, the ASP.NET application requires the EnvironmentPermission with readaccess to the USERNAME environment variable. Default medium-trust policy grantsthis permission to <strong>Web</strong> applications.In an ASP.NET server-side scenario, the credentials are obtained from the ASP.NETapplication’s thread or process-level token. If DefaultCredentials are used from adesktop application, the current interactive user’s token is used. The dem<strong>and</strong> forEnvironmentPermission is a risk mitigation strategy designed to ensure that codecannot use the local user’s credentials at will <strong>and</strong> expose them to the network.RegistryBy default, medium-trust <strong>Web</strong> applications are not granted the RegistryPermission.To configure your application to access the registry, you must either modify ASP.NETpolicy to grant this permission to your application or develop a s<strong>and</strong>boxed wrapperassembly that has the necessary permission.The s<strong>and</strong>boxing approach is the same as described earlier for OLE DB data sources<strong>and</strong> the event log.Customizing PolicyThe easiest way to customize policy is to create a custom policy file based on themedium-trust policy file <strong>and</strong> configure your application to use the custom policy.The custom policy grants RegistryPermission to the application.

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

Saved successfully!

Ooh no, something went wrong!