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 10: Building Secure ASP.NET Pages <strong>and</strong> Controls 263Consider Authorization GranularityConsider the authorization granularity that you use in the authenticated parts of yoursite. If you have configured a directory to require authentication, should all usershave equal access to the pages in that directory? If necessary, you can apply differentauthorization rules for separate pages based on the identity, or more commonly, therole membership of the caller, by using multiple elements withinseparate elements.For example, two pages in the same directory can have different <strong>and</strong> elements in <strong>Web</strong>.config.Place <strong>Web</strong> Controls <strong>and</strong> User Controls in Separate AssembliesWhen <strong>Web</strong> controls <strong>and</strong> user controls are put in their own assemblies, you canconfigure security for each assembly independently by using code access securitypolicy. This provides additional flexibility for the administrator <strong>and</strong> it means that youare not forced to grant extended permissions to all controls just to satisfy therequirements of a single control.Place Resource Access Code in a Separate AssemblyUse separate assemblies <strong>and</strong> call them from your page classes rather than embeddingresource access code in your page class event h<strong>and</strong>lers. This provides greaterflexibility for code access security policy <strong>and</strong> is particularly important for buildingpartial-trust <strong>Web</strong> applications. For more information, see Chapter 9, “Using CodeAccess <strong>Security</strong> with ASP.NET.”Input ValidationIf you make unfounded assumptions about the type, length, format, or range ofinput, your application is unlikely to be robust. Input validation can become asecurity issue if an attacker discovers that you have made unfounded assumptions.The attacker can then supply carefully crafted input that compromises yourapplication. The misplaced trust of user input is one of the most common <strong>and</strong>devastating vulnerabilities in <strong>Web</strong> applications.

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

Saved successfully!

Ooh no, something went wrong!