My website was recently attacked by, what seemed to me as, an innocent code:
<?php if ( isset( $ _GET['page'] ) ) { include( $ _GET['page'] . '.php' ); } else { include('home.php'); } ?>
There where no SQL calls, so I wasn’t afraid for SQL Injection. But, apparently, SQL isn’t the only kind of injection.
This website has an explanation and a few examples of avoiding code injection: http://www.theserverpages.com/articles/webmasters/php/security/Code_Injection_Vulnerabilities_Explained.html
How would you protect this code from code injection?
Use a whitelist and make sure the page is in the whitelist: