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.

lxvi<strong>Improving</strong> <strong>Web</strong> <strong>Application</strong> <strong>Security</strong>: <strong>Threats</strong> <strong>and</strong> CountermeasuresDevelopment SolutionsFor developers, this guide provides the following solutions:● What is .NET Framework security?The .NET Framework provides user <strong>and</strong> code security models that allow you torestrict what users can do <strong>and</strong> what code can do. To program role-based security<strong>and</strong> code access security, use types from the System.<strong>Security</strong> namespace. The.NET Framework also provides the System.<strong>Security</strong>.Cryptography namespace,which exposes symmetric <strong>and</strong> asymmetric encryption <strong>and</strong> decryption, hashing,r<strong>and</strong>om number generation, support for digital signatures, <strong>and</strong> more.To underst<strong>and</strong> the .NET Framework security l<strong>and</strong>scape, see Chapter 6, “.NET<strong>Security</strong> Overview.”● How to write secure managed codeUse strong names to digitally sign your assemblies <strong>and</strong> to make themtamperproof. At the same time you need to be aware of strong name issues whenyou use strong name assemblies with ASP.NET. Reduce your assembly attackprofile by adhering to solid object oriented design principles, <strong>and</strong> then use codeaccess security to further restrict which code can call your code. Use structuredexception h<strong>and</strong>ling to prevent sensitive information from propagating beyondyour current trust boundary <strong>and</strong> to develop more robust code. Avoidcanonicalization issues, particularly with input file names <strong>and</strong> URLs.For information about how to improve the security of your managed code, seeChapter 7, “Building Secure Assemblies.” For more information about how touse code access security effectively to further improve security, see Chapter 8,“Code Access <strong>Security</strong> in Practice.” For information about performing managedcode reviews, see Chapter 21, “Code Review.”● How to h<strong>and</strong>le exceptions securelyDo not reveal internal system or application details, such as stack traces,SQL statement fragments, <strong>and</strong> so on. Ensure that this type of information is notallowed to propagate to the end user or beyond your current trust boundary.Fail securely in the event of an exception, <strong>and</strong> make sure your application deniesaccess <strong>and</strong> is not left in an insecure state. Do not log sensitive or private data suchas passwords, which could be compromised. When you log or report exceptions,if user input is included in exception messages, validate it or sanitize it. Forexample, if you return an HTML error message, you should encode the outputto avoid script injection.For more information, see the “Exception Management” sections in Chapter 7,“Building Secure Assemblies,” <strong>and</strong> in Chapter 10, “Building Secure ASP.NETPages <strong>and</strong> Controls.”

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

Saved successfully!

Ooh no, something went wrong!