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 8: Code Access <strong>Security</strong> in Practice 185For more information about how to use link dem<strong>and</strong>s correctly, see the “LinkDem<strong>and</strong>s” section later in this chapter.Assert, Deny, <strong>and</strong> PermitOnly MethodsCode access permission classes support the Assert, Deny, <strong>and</strong> PermitOnly methods.You can use these methods to alter the behavior of a permission dem<strong>and</strong> stack walk.They are referred to as stack walk modifiers.A call to the Assert method causes the stack walk for a matching permission to stopat the site of the Assert call. This is most often used to s<strong>and</strong>box privileged code. Formore information, see the “Assert <strong>and</strong> RevertAssert” section later in this chapter.A call to the Deny method fails any stack walk that reaches it with a matchingpermission. If you call some non-trusted code, you can use the Deny method toconstrain the capabilities of the code that you call.A call to the PermitOnly method fails any unmatching stack walk. Like the Denymethod, it tends to be used infrequently but it can be used to constrain the actions ofsome non-trusted code that you may call.PolicyCode access security policy is configured by administrators <strong>and</strong> it determines thepermissions granted to assemblies. Policy can be established at four levels:● Enterprise. Used to apply Enterprise-wide policy.●●●Machine. Used to apply machine-level policy.User. Used to apply per user policy.<strong>Application</strong> Domain. Used to configure the application domain into which anassembly is loaded.ASP.NET implements application domain policy to allow you to configure codeaccess security policy for <strong>Web</strong> applications <strong>and</strong> <strong>Web</strong> services. For moreinformation about ASP.NET application domain policy, see Chapter 9, “UsingCode Access <strong>Security</strong> with ASP.NET.”Policy settings are maintained in XML configuration files. The first three levels ofpolicy (Enterprise, Machine, <strong>and</strong> User) can be configured by using the .NETFramework Configuration tool, which is located in the Administrative Tools programgroup or the Caspol.exe comm<strong>and</strong> line utility. ASP.NET application domain levelpolicy must currently be edited with a text or XML-based editor.For more information about policy files <strong>and</strong> locations, see Chapter 19, “Securing YourASP.NET <strong>Application</strong> <strong>and</strong> <strong>Web</strong> Services.”

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

Saved successfully!

Ooh no, something went wrong!