Slide 56
Slide 56 text
Sanitize on input, escape on output
• Take a whitelist approach (rather than a blacklist one):
- parsing HTML is more complicated than what seems.
- HtmlPurifier is a great (the best?) HTML parser library for PHP
Just make sure to cache it. Sadly it is a little bit complicated and not good with internationalized URIs.
- don’t build your own parser (unless the parser itself is your goal)
• i.e., phone number
- first character may be “+”, others are digits (and no more than ~20)
• escape at each step: SQL, HTML, JSON, BASH, Regex, XML, etc.
- escaping isn’t magic, each step requires different types of escaping
56
Tuesday, July 31, 12