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.

238 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sDeciding Which Approach to TakeThe right approach depends upon the problem you are trying to solve <strong>and</strong> whetheror not you have the option of modifying security policy on the <strong>Web</strong> server.Customizing PolicyThis approach is the easier of the two <strong>and</strong> does not require any developer effort.However, you might not be permitted to modify policy on the <strong>Web</strong> server <strong>and</strong>, incertain scenarios, your code that calls the .NET Framework class library mightrequire full trust. In these situations, you must use s<strong>and</strong>boxing. For example, thefollowing resources dem<strong>and</strong> full trust, <strong>and</strong> you must s<strong>and</strong>box your resource accesscode when it accesses them:● Event log (through the EventLog class)● OLE DB data sources (through the ADO.NET OLE DB data provider)●●ODBC data sources (through the ADO.NET ODBC .NET data provider)Oracle databases (through the ADO.NET Oracle .NET data provider)Note This list is not exhaustive but it includes commonly used resource types that currently requirefull trust.S<strong>and</strong>boxingIf you s<strong>and</strong>box your privileged application code in a separate assembly, you cangrant additional permissions to the assembly. Alternatively, you can grant it full trustwithout requiring your entire application to run with extended permissions.For example, consider code that uses the ADO.NET OLE DB data provider <strong>and</strong>interacts with the System.Data.OleDb.OleDbComm<strong>and</strong> class. This code requires fulltrust. Although the System.Data.dll assembly is marked withAllowPartiallyTrustedCallersAttribute, the System.Data.OleDb.OleDbComm<strong>and</strong>class, among others, cannot be called by partial-trust callers because it is protectedwith a link dem<strong>and</strong> for full trust. To see this, run the following comm<strong>and</strong> using thepermview utility from the %windir%\Microsoft.NET\Framework\{version}directory:permview /DECL /OUTPUT System.Data.Perms.txt System.Data.dllThe output in System.Data.Perms.txt includes the following output:class System.Data.OleDb.OleDbComm<strong>and</strong> LinktimeDem<strong>and</strong> permission set:

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

Saved successfully!

Ooh no, something went wrong!