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.

272 Part III: Building Secure <strong>Web</strong> <strong>Application</strong>sTable 10.2 Useful Regular Expression Fields (continued)FormatField ExpressionSamplesE-mail \w+([-+.]\w+)*@\w+ someone@([-.]\w+)*\.\w+([-.]\w+)* example.comDescriptionValidates an e-mail address.URLZip CodePasswordNonnegativeintegersCurrency(nonnegative)Currency(positive ornegative)^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d)$^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$\d+ 0"\d+(\.\d\d)?""(-)?\d+(\.\d\d)?"986Validates a URL.Validates a U.S. ZIP code allowing 5or 9 digits.Validates a strong password. Mustbe between 8 <strong>and</strong> 10 characters.Must contain a combination ofuppercase, lowercase, <strong>and</strong> numericdigits, with no special characters.Validates for integers greater thanzero.Validates for a positive currencyamount. Requires two digits afterthe decimal point.Validates for a positive or negativecurrency amount. Requires two digitsafter the decimal point.Cross-Site ScriptingXSS attacks exploit vulnerabilities in <strong>Web</strong> page validation by injecting client-sidescript code. This code is subsequently sent back to an unsuspecting user <strong>and</strong>executed by the browser. Because the browser downloads the script code from atrusted site, the browser has no way of identifying that the code is not legitimate, <strong>and</strong>Internet Explorer security zones provide no defense. XSS attacks also work overHTTP or HTTPS (SSL) connections. One of the most serious exploits occurs when anattacker writes script to retrieve the authentication cookie that provides access to thetrusted site <strong>and</strong> posts it to a <strong>Web</strong> address known to the attacker. This allows theattacker to spoof the legitimate user’s identity <strong>and</strong> gain illicit access to the <strong>Web</strong> site.

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

Saved successfully!

Ooh no, something went wrong!