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.

Chapter 4: Design Guidelines for Secure <strong>Web</strong> <strong>Application</strong>s 75Assume All Input Is MaliciousInput validation starts with a fundamental supposition that all input is maliciousuntil proven otherwise. Whether input comes from a service, a file share, a user, or adatabase, validate your input if the source is outside your trust boundary. Forexample, if you call an external <strong>Web</strong> service that returns strings, how do you knowthat malicious comm<strong>and</strong>s are not present? Also, if several applications write to ashared database, when you read data, how do you know whether it is safe?Centralize Your ApproachMake your input validation strategy a core element of your application design.Consider a centralized approach to validation, for example, by using commonvalidation <strong>and</strong> filtering code in shared libraries. This ensures that validation rules areapplied consistently. It also reduces development effort <strong>and</strong> helps with futuremaintenance.In many cases, individual fields require specific validation, for example, withspecifically developed regular expressions. However, you can frequently factor outcommon routines to validate regularly used fields such as e-mail addresses, titles,names, postal addresses including ZIP or postal codes, <strong>and</strong> so on. This approach isshown in Figure 4.3.PagesSpecificValidationBrowseror ServiceControlsSpecificValidationSharedValidationRoutinesServicesSpecificValidationFigure 4.3A centralized approach to input validation

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

Saved successfully!

Ooh no, something went wrong!