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.

620 Part V: Assessing Your <strong>Security</strong>●●Do you log exception details?Check that exception details are logged at the source of the exception to assistproblem diagnosis.Do you use exception filters?If so, be aware that the code in a filter higher in the call stack can run before codein a finally block. Check that you do not rely on state changes in the finally block,because the state change will not occur before the exception filter executes.For an example of an exception filter vulnerability, see “Exception Management”in Chapter 7, “Building Secure Assemblies.”Do You Use Cryptography?If so, check that your code does not implement its own cryptographic routines.Instead, code should use the System.<strong>Security</strong>.Cryptography namespace or use Win32encryption such as Data Protection <strong>Application</strong> Programming Interface (DPAPI).Review the following questions to help identify potential cryptography relatedvulnerabilities:● Do you use symmetric encryption?If so, check that you use Rijndael (now referred to as Advanced EncryptionSt<strong>and</strong>ard [AES]) or Triple Data Encryption St<strong>and</strong>ard (3DES) when encrypted dataneeds to be persisted for long periods of time. Use the weaker (but quicker) RC2<strong>and</strong> DES algorithms only to encrypt data that has a short lifespan, such as sessiondata.● Do you use the largest key sizes possible?Use the largest key size possible for the algorithm you are using. Larger key sizesmake attacks against the key much more difficult, but can degrade performance.●●Do you use hashing?If so, check that you use MD5 <strong>and</strong> SHA1 when you need a principal to prove itknows a secret that it shares with you. For example, challenge-responseauthentication systems use a hash to prove that the client knows a passwordwithout having the client pass the password to the server. Use HMACSHA1 withMessage Authentication Codes (MAC), which require you <strong>and</strong> the client to share akey. This can provide integrity checking <strong>and</strong> a degree of authentication.Do you generate r<strong>and</strong>om numbers for cryptographic purposes?If so, check that your code uses theSystem.<strong>Security</strong>.Cryptography.RNGCryptoServiceProvider class to generater<strong>and</strong>om numbers, <strong>and</strong> not the R<strong>and</strong>om class. The R<strong>and</strong>om class does not generatetruly r<strong>and</strong>om numbers that are not repeatable or predictable.

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

Saved successfully!

Ooh no, something went wrong!