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 9: Using Code Access <strong>Security</strong> with ASP.NET 231Developing Partial Trust <strong>Web</strong> <strong>Application</strong>sPartial trust <strong>Web</strong> applications are applications that do not have full trust <strong>and</strong> have arestricted set of code access permissions determined by code access security policy.As a result, partial-trust applications are limited in their ability to access securedresources <strong>and</strong> perform other privileged operations. Certain permissions are denied topartial-trust applications, so resources requiring those permissions cannot be directlyaccessed. Other permissions are granted in a restricted way, so resources that requirethose permissions might be accessible, but in a limited way. For example, a restrictedFileIOPermission might specify that the application can access the file system, butonly in directories beneath the application’s virtual directory root.Why Partial Trust?By configuring a <strong>Web</strong> application or <strong>Web</strong> service for partial trust, you can restrict theapplication’s ability to access crucial system resources or resources that belong toother <strong>Web</strong> applications. By granting only the permissions that the applicationrequires <strong>and</strong> no more, you can build least privileged <strong>Web</strong> applications <strong>and</strong> limitdamage potential should the <strong>Web</strong> application be compromised by a code injectionattack.Problems You Might EncounterIf you take an existing <strong>Web</strong> application <strong>and</strong> reconfigure it to run at a partial-trustlevel, you are likely to run into the following issues, unless the application isextremely limited in the resources it accesses:● Your application is unable to call strong named assemblies that are not annotatedwith AllowPartiallyTrustedCallersAttribute (APTCA). Without APTCA, strongnamed assemblies issue a dem<strong>and</strong> for full trust, which will fail when the dem<strong>and</strong>reaches your partial-trust <strong>Web</strong> application. Many system assemblies only supportfull-trust callers. The following list shows which .NET Framework assembliessupport partial-trust callers <strong>and</strong> can be called directly by partial-trust <strong>Web</strong>applications without necessitating s<strong>and</strong>boxed wrapper assemblies.Note S<strong>and</strong>boxing is discussed in detail later in this chapter.The following system assemblies have APTCA applied, which means that they canbe called by partial-trust <strong>Web</strong> applications or any partially trusted code:●●●●●System.Windows.Forms.dllSystem.Drawing.dllSystem.dllMscorlib.dllIEExecRemote.dll

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

Saved successfully!

Ooh no, something went wrong!