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.

Chapter 9: Using Code Access <strong>Security</strong> with ASP.NET 239This illustrates that an unrestricted permission set (full trust) is used in a link dem<strong>and</strong>that protects the System.Data.OleDb.OleDbComm<strong>and</strong> class. In scenarios such asthis, it is not sufficient to configure policy to grant specific unrestricted permissions,such as OleDbPermission, to your partial-trust code. Instead, you must s<strong>and</strong>boxyour resource access code <strong>and</strong> grant it full trust, <strong>and</strong> the easiest way to do this is toinstall it in the GAC. Use Permview.exe to find out about the permissionrequirements of other classes, although this only shows declarative securityattributes. If a class imperatively dem<strong>and</strong>s full trust, you cannot see this throughPermview.exe. In this event, test the security requirements of the class by calling itfrom partial-trust code <strong>and</strong> diagnosing any security exceptions.Note Just because an assembly is marked with APTCA, it does not mean all of the containedclasses support partial-trust callers. Some classes may include explicit dem<strong>and</strong>s for full trust.Medium TrustIf you host <strong>Web</strong> applications, you may choose to implement a medium trust securitypolicy to restrict privileged operations. This section focuses on running medium trustapplications, <strong>and</strong> shows you how to overcome the problems you are likely toencounter.Running at medium trust has the following two main benefits:● Reduced attack surface● <strong>Application</strong> isolationReduced Attack SurfaceSince medium trust does not grant the application unrestricted access to allpermissions, your attack surface is reduced by granting the application a subset ofthe full permission set. Many of the permissions granted by medium trust policy arealso in a restricted state. If an attacker is somehow able to take control of yourapplication, the attacker is limited in what he or she can do.<strong>Application</strong> Isolation<strong>Application</strong> isolation with code access security restricts access to system resources<strong>and</strong> resources owned by other applications. For example, even though the processidentity might be allowed to read <strong>and</strong> write files outside of the <strong>Web</strong> applicationdirectory, the FileIOPermission in medium trust applications is restricted. It onlypermits the application to read or write to its own application directory hierarchy.

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

Saved successfully!

Ooh no, something went wrong!