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.

94 Part II: Designing Secure <strong>Web</strong> <strong>Application</strong>sValidate All Values Sent from the ClientRestrict the fields that the user can enter <strong>and</strong> modify <strong>and</strong> validate all values comingfrom the client. If you have predefined values in your form fields, users can changethem <strong>and</strong> post them back to receive different results. Permit only known good valueswherever possible. For example, if the input field is for a state, only inputs matchinga state postal code should be permitted.Do Not Trust HTTP Header InformationHTTP headers are sent at the start of HTTP requests <strong>and</strong> HTTP responses. Your <strong>Web</strong>application should make sure it does not base any security decision on information inthe HTTP headers because it is easy for an attacker to manipulate the header. Forexample, the referer field in the header contains the URL of the <strong>Web</strong> page from wherethe request originated. Do not make any security decisions based on the value of thereferer field, for example, to check whether the request originated from a pagegenerated by the <strong>Web</strong> application, because the field is easily falsified.Exception ManagementSecure exception h<strong>and</strong>ling can help prevent certain application-level denial of serviceattacks <strong>and</strong> it can also be used to prevent valuable system-level information useful toattackers from being returned to the client. For example, without proper exceptionh<strong>and</strong>ling, information such as database schema details, operating system versions,stack traces, file names <strong>and</strong> path information, SQL query strings <strong>and</strong> otherinformation of value to an attacker can be returned to the client.A good approach is to design a centralized exception management <strong>and</strong> loggingsolution <strong>and</strong> consider providing hooks into your exception management system tosupport instrumentation <strong>and</strong> centralized monitoring to help system administrators.The following practices help secure your <strong>Web</strong> application’s exception management:● Do not leak information to the client.●●Log detailed error messages.Catch exceptions.Do Not Leak Information to the ClientIn the event of a failure, do not expose information that could lead to informationdisclosure. For example, do not expose stack trace details that include function names<strong>and</strong> line numbers in the case of debug builds (which should not be used onproduction servers). Instead, return generic error messages to the client.

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

Saved successfully!

Ooh no, something went wrong!