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.

76 Part II: Designing Secure <strong>Web</strong> <strong>Application</strong>sDo Not Rely on Client-Side ValidationServer-side code should perform its own validation. What if an attacker bypassesyour client, or shuts off your client-side script routines, for example, by disablingJavaScript? Use client-side validation to help reduce the number of round trips to theserver but do not rely on it for security. This is an example of defense in depth.Be Careful with Canonicalization IssuesData in canonical form is in its most st<strong>and</strong>ard or simplest form. Canonicalization isthe process of converting data to its canonical form. File paths <strong>and</strong> URLs areparticularly prone to canonicalization issues <strong>and</strong> many well-known exploits are adirect result of canonicalization bugs. For example, consider the following string thatcontains a file <strong>and</strong> path in its canonical form.c:\temp\somefile.datThe following strings could also represent the same file.somefile.datc:\temp\subdir\..\somefile.datc:\ temp\ somefile.dat..\somefile.datc%3A%5Ctemp%5Csubdir%5C%2E%2E%5Csomefile.datIn the last example, characters have been specified in hexadecimal form:● %3A is the colon character.● %5C is the backslash character.● %2E is the dot character.You should generally try to avoid designing applications that accept input file namesfrom the user to avoid canonicalization issues. Consider alternative designs instead.For example, let the application determine the file name for the user.If you do need to accept input file names, make sure they are strictly formed beforemaking security decisions such as granting or denying access to the specified file.For more information about how to h<strong>and</strong>le file names <strong>and</strong> to perform file I/O in asecure manner, see the “File I/O” sections in Chapter 7, “Building SecureAssemblies,” <strong>and</strong> Chapter 8, “Code Access <strong>Security</strong> in Practice.”

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

Saved successfully!

Ooh no, something went wrong!