The mantra of any good security engineer is: 'Security is a not a product, but a process.' It's more than designing strong cryptography into a system; it's designing the entire system such that all security measures, including cryptography, work together. Bruce Schneier Cryptographer, Security Specialist and author of “Applied Cryptography” and “Secrets & Lies” Saturday, November 3, 2012
When filtering... One of the most difficult parts of an app PHP’s nature doesn’t help Type hinting can be useful Code defensively Fail fast, fail hard Saturday, November 3, 2012
Think about... There’s no “universal filtering” Be wary of Do-It-Alls Good design is by contract, be deliberate Whitelist, not blacklist Watch for multiple contexts (ex. in output & SQL) Saturday, November 3, 2012
Protect Yourself Know the “holes” in what you use Don’t trust it if you don’t know it Filter with impunity, don’t alter === don’t == All user data is tainted, especially superglobals Saturday, November 3, 2012
For example... $_SERVER PHP_SELF HTTP_HOST HTTP_USER_AGENT HTTP_ACCEPT HTTP_REFERER Current script filename Sent in the “Host” header Any value from the client “Accept” header “Referer” header Saturday, November 3, 2012
Validation + Filter == Data type Whitelisted characters Formatting (phone #, email, etc) Range (character or number) Required data Complex logic checking on... Saturday, November 3, 2012
When escaping... “Encoding” vs “Escaping” Internal functions htmlspecialchars (encoding!) htmlentities (encoding!) filter_var Most popular prevention for XSS Beware the Passive XSS Saturday, November 3, 2012
Contexts General output (usually text) HTML attributes Javascript code URL parameters SQL statements Inside XML or JSON Headers Saturday, November 3, 2012
Javascript Don’t trust it. Period. Same-Origin vs Access-Control-Allow-Origin XSS can allow for JS injection Global nature, overrides are easy Saturday, November 3, 2012
Server Security Strong system passwords Lock it down Favor SSL (“HTTPS Everywhere”) Update, update and - oh yeah - update Shared resources/sessions https://github.com/enygma/shieldframework/blob/master/Shield/Session.php Saturday, November 3, 2012
Consider... Never trust the user Implement security checks during development, not after Create a security policy all devs should follow Remember your attack surface Think like an attacker Saturday, November 3, 2012
Tools WebScarab - Capturing Proxy Burp Suite - Security Testing App Skipfish - Google’s Scanner WebGoat/DVWA To learn and test Saturday, November 3, 2012