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 21: Code Review 623The following questions help you to identify potentially vulnerable areas:● Is your assembly strong named?If it is, then default security policy ensures that it cannot be called by partiallytrusted callers. The Common Language Runtime (CLR) issues an implicit linkdem<strong>and</strong> for full trust. If your assembly is not strong named, it can be called by anycode unless you take explicit steps to limit the callers, for example by explicitlydem<strong>and</strong>ing full trust.Note Strong named assemblies called by ASP.NET applications must be installed in the GlobalAssembly Cache.●●Do you use APTCA?If your strong named assembly contains AllowPartiallyTrustedCallersAttribute,partially trusted callers can call your code. In this situation, check that anyresource access or other privileged operation performed by your assembly isauthorized <strong>and</strong> protected with other code access security dem<strong>and</strong>s. If you use the.NET Framework class library to access resources, full stack walking dem<strong>and</strong>s areautomatically issued <strong>and</strong> will authorize calling code unless your code has used anAssert call to prevent the stack walk.Do you h<strong>and</strong> out object references?Check method returns <strong>and</strong> ref parameters to see where your code returns objectreferences. Check that your partial-trust code does not h<strong>and</strong> out references toobjects obtained from assemblies that require full-trust callers.Do You Restrict Access to Public Types <strong>and</strong> Members?You can use code access security identity dem<strong>and</strong>s to limit access to public types <strong>and</strong>members. This is a useful way of reducing the attack surface of your assembly.●●Do you restrict callers by using identity dem<strong>and</strong>s?If you have classes or structures that you only intend to be used within a specificapplication by specific assemblies, you can use an identity dem<strong>and</strong> to limit therange of callers. For example, you can use a dem<strong>and</strong> with aStrongNameIdentityPermission to restrict the caller to a specific set of assembliesthat have a have been signed with a private key that corresponds to the public keyin the dem<strong>and</strong>.Do you use inheritance dem<strong>and</strong>s to restrict subclasses?If you know that only specific code should inherit from a base class, check that theclass uses an inheritance dem<strong>and</strong> with a StrongNameIdentityPermission.

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

Saved successfully!

Ooh no, something went wrong!