the websites”[1] (Top 10 million websites in Alexa) – Many Fortune 500 users • Disney [https://thewaltdisneycompany.com/] • Sony [http://blog.us.playstation.com/] • Microsoft [http://news.microsoft.com/] – Many not so Fortune 500 users • Oh She Glows [http://ohsheglows.com/] • Carolina Roller Girls [http://www.carolinarollergirls.com/] • Kiss My Spatula [http://kissmyspatula.com/] 07/01/2016
CMS framework (not just for blogging about your cat) built on PHP and MySQL ▪ Open Source maintained by WordPress Foundation and Automattic. – In development since 2003 as a fork of b2/cafelog – GPLv2+ licensed 07/01/2016
plugins which run with the same permissions and privileges as the WordPress core(!) ▪ Wordpress.org boasts “41,983 plugins with 1,124,700,998 total downloads” [2] – Everything from “WooCommerce” to “Internet Defense League Cat Signal” – Plugins hosted on Wordpress.org (the primary plugin repository) are all open source ▪ I asked myself a question – “How many of these plugins contain critical security vulnerabilities?” 07/01/2016
-la" . $_GET["directory"]); The Poor Man’s Solution 07/01/2016 function run_command($command) { system($command); } run_command("ls -la " . $_GET["directory"]); * For certain SERVER variables
of lazy) – Why do something once quickly when you can spend weeks automating it in case you ever have to do it again? ▪ Let’s write a PHP Code Analyser – How hard can it be? • (It turns out quite hard!) 07/01/2016 * Man With Far Too Much Time On His Hands
of analysing a string of symbols, either in natural language or in computer languages, conforming to the rules of a formal grammar.” [2] 07/01/2016 [2] https://en.wikipedia.org/wiki/Parsing
syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language.” [3] 07/01/2016 [3] https://en.wikipedia.org/wiki/Abstract_syntax_tree Simplified abstract syntax tree
– I’m not actually going to implement any of that myself – PHP-Parser by Nikita Popov • https://github.com/nikic/PHP-Parser ▪ Also, did I mention I hate PHP? – So let’s write the analyser in Python! 07/01/2016
– require, require_once, include, include_once ▪ Not uncommon to see code such as: 07/01/2016 require_once dirname(__ FILE__) . "../" . basename(__ FILE__); ▪ Dynamic analysis is required to evaluate these expressions in order to identify the correct include path ▪ Minimal set of functions to correctly interpret includes: – strtolower, define, defined, dirname, basename, realpath
unauth exploitable* vulnerabilities in the following plugins: – BestWebSoft Captcha – Gwolle Guestbook – Landing Pages – Multi Plugin Installer – Simple Ads Manager – WooCommerce PDF Invoices & Packing Slips – … and some others I can’t quite remember • ▪ Total active count for blogs running vulnerable plugins at time of writing was 470,000. 07/01/2016 *SQLi, Code Exec, Script Exec, File Download, File Upload
a while ago, I can barely remember how it works – Doesn’t work well with non-ascii characters – Seems to find much fewer issues than before • I think I broke something in a recent change – Is available if anyone wants it! 07/01/2016
to write in PHP? – Definitely not 2. Should WordPress be doing more to secure plugins? – Almost certainly – Basic automated scanning of plugins • Automated vulnerability discovery • Disallowed functions / APIs – Sandboxing? • I’m not sure this is technically feasible with PHP 3. What about ‘wp_magic_quotes’? – Don’t get me started 07/01/2016