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.

230 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sASP.NET policy also introduces a custom AspNetHostingPermission, which has anassociated Level attribute that corresponds to one of the default levels. All publictypes in the System.<strong>Web</strong> <strong>and</strong> System.<strong>Web</strong>.Mobile are protected with dem<strong>and</strong>s forthe Minimum level of this permission. This risk mitigation strategy is designed toensure that <strong>Web</strong> application code cannot be used in other partial-trust environmentswithout specific policy configuration by an administrator.Substitution ParametersIf you edit one of the ASP.NET policy files, you will notice that some of thepermission elements contain substitution parameters ($AppDirUrl$, $CodeGen$, <strong>and</strong>$Gac$). These parameters allow you to configure permissions to assemblies that arepart of your <strong>Web</strong> application, but are loaded from different locations. Eachsubstitution parameter is replaced with an actual value at security policy evaluationtime, which occurs when your <strong>Web</strong> application assembly is loaded for the first time.Your <strong>Web</strong> application might consist of the following three assembly types:● Private assemblies that are compiled at build time <strong>and</strong> deployed in theapplication’s bin directoryImportant This type of assembly cannot be strong named. Strong named assemblies used byASP.NET <strong>Web</strong> applications must be installed in the global assembly cache. This restriction isnecessary because of the internal workings of the multi-application domain worker process.●●Dynamically compiled assemblies that are generated in response to a page requestShared assemblies that are loaded from the computer’s global assembly cacheEach of these assembly types has an associated substitution parameter, whichTable 9.2 summarizes.Table 9.2 ASP.NET Code Access <strong>Security</strong> Policy Substitution ParametersParameter$AppDirUrl$RepresentsThe application’s virtual root directory. This allows permissions to be applied tocode that is located in the application’s bin directory.For example, if a virtual directory is mapped to C:\Your<strong>Web</strong>App, then$AppDirUrl$ would equate to C:\Your<strong>Web</strong>App.$CodeGen$The directory that contains dynamically generated assemblies (for example, theresult of .aspx page compiles). This can be configured on a per application basis<strong>and</strong> defaults to %windir%\Microsoft.NET\Framework\{version}\TemporaryASP.NET Files.$CodeGen$ allows permissions to be applied to dynamically generatedassemblies.$Gac$Any assembly that is installed in the computer’s global assembly cache (GAC)(%windir%\assembly). This allows permissions to be granted to strong namedassemblies loaded from the GAC by the <strong>Web</strong> application.

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

Saved successfully!

Ooh no, something went wrong!