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.

274 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sDefense in Depth CountermeasuresIn addition to the techniques discussed earlier, use the following countermeasures fordefense in depth to prevent XSS:● Set the correct character encoding.●●●●●Use the ASP.NET version 1.1 validateRequest option.Install URLScan on your <strong>Web</strong> server.Use the HttpOnly cookie option.Use the security attribute.Use the innerText property.Set the Correct Character EncodingTo successfully restrict what data is valid for your <strong>Web</strong> pages, it is important to limitthe ways in which the input data can be represented. This prevents malicious usersfrom using canonicalization <strong>and</strong> multi-byte escape sequences to trick your inputvalidation routines.ASP.NET allows you to specify the character set at the page level or at the applicationlevel by using the element in <strong>Web</strong>.config. Both approaches areshown below using the ISO-8859-1 character encoding, which is the default in earlyversions of HTML <strong>and</strong> HTTP.To set the character encoding at the page level, use the element or theResponseEncoding page-level attribute as follows:ORTo set the character encoding in <strong>Web</strong>.config, use the following configuration:

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

Saved successfully!

Ooh no, something went wrong!