Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
ini_set() security question
Old
  (#1)
Samuel Vogel
Guest
 
Posts: n/a
Default ini_set() security question - 06-02-2007, 08:55 PM

I would be very interested in knowing which options, that are accessible
with PHP_INI_ALL or PHP_INI_PERDIR, could be risky to allow on a shared
hosting server.
I would like to allow the users to ini_set(), while disabling the risky
options with php_admin_flag/value!

Stuff like 'memory_limit' and so on come to my mind!

Does anybody have more infos on this?

Regards,
Samy
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: [PHP] ini_set() security question
Old
  (#2)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

On Tue, May 29, 2007 10:19 am, Samuel Vogel wrote:
> I would be very interested in knowing which options, that are
> accessible
> with PHP_INI_ALL or PHP_INI_PERDIR, could be risky to allow on a
> shared
> hosting server.


php.ini_recommended is a good starting point, I think...

> I would like to allow the users to ini_set(), while disabling the
> risky
> options with php_admin_flag/value!


I don't think php_admin_* can be over-ridden -- that's kinda the whole
point of that.

> Stuff like 'memory_limit' and so on come to my mind!


If you're going to use memory_limit on shared hosting, PLEASE make it
a reasonable value!

The default php.ini setting doesn't even run some of the larger common
packages out there.

And something like a simple photo album trying to generate thumbnails...

You may want to have a very different default php.ini for the CLI php
and give (some) users SSH access, on request, so they can do
reasonable things like make thumbnails in a background task.

> Does anybody have more infos on this?


I would guess that there are mailing lists and forums dedicated to
webhosting, and that many many many of them would have much better
info the PHP-General, since many hosts are running PHP.

You could also try contacting reputable webhosts you think "do it
right" directly and ask them what they do.

And, finally, you could work backwards by asking your potential
customers what they need.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#3)
Samuel Vogel
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

Hello,

>> I would like to allow the users to ini_set(), while disabling the
>> risky
>> options with php_admin_flag/value!
>>

>
> I don't think php_admin_* can be over-ridden -- that's kinda the whole
> point of that.


The Problem is, that i can be overwritten using ini_set()...
I just found that out by testing it and now I don't even have to worry
about what options to disable, because I can't disable any of them

Any thoughts on that?

Regards,
Samy
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#4)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

On Wed, May 30, 2007 2:44 pm, Samuel Vogel wrote:
>>> I would like to allow the users to ini_set(), while disabling the
>>> risky
>>> options with php_admin_flag/value!
>>>

>>
>> I don't think php_admin_* can be over-ridden -- that's kinda the
>> whole
>> point of that.

>
> The Problem is, that i can be overwritten using ini_set()...
> I just found that out by testing it and now I don't even have to worry
> about what options to disable, because I can't disable any of them
>
> Any thoughts on that?


Show us your test code?

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#5)
Samuel Vogel
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

Hi!
> Show us your test code?
>

/etc/apache2/httpd.conf :
php_admin_value memory_limit 3145728

iniset_test.php :
<?php

$old = ini_set("memory_limit", 20971520);

echo "old: ".$old;

$new = ini_get("memory_limit");

echo "<br>new: ".$new;

?>

The result is the following:
old: 3145728
new: 20971520
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#6)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

On Wed, May 30, 2007 2:59 pm, Samuel Vogel wrote:
> Hi!
>> Show us your test code?
>>

> /etc/apache2/httpd.conf :
> php_admin_value memory_limit 3145728
>
> iniset_test.php :
> <?php
>
> $old = ini_set("memory_limit", 20971520);
>
> echo "old: ".$old;
>
> $new = ini_get("memory_limit");
>
> echo "<br>new: ".$new;
>
> ?>
>
> The result is the following:
> old: 3145728
> new: 20971520


And what happens if you try to allocate 3M of data?

$foo = str_repeat('.', 3145728);

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#7)
Samuel Vogel
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM


> And what happens if you try to allocate 3M of data?
>
> $foo = str_repeat('.', 3145728);
>

Nothing. It does it without any errors. I can allocate up to 20MB (well
a little bit less of course).

Regards,
Samy
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#8)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

On Wed, May 30, 2007 3:34 pm, Samuel Vogel wrote:
>> And what happens if you try to allocate 3M of data?
>>
>> $foo = str_repeat('.', 3145728);
>>

> Nothing. It does it without any errors. I can allocate up to 20MB
> (well
> a little bit less of course).


Check http://bugs.php.net and see if it's a known issue or an
exception to the php_admin_* rule or...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#9)
Samuel Vogel
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

There is no bug filed for this. There is only one older bug (
http://bugs.php.net/bug.php?id=38804 ) which makes me think overwriting
with ini_set() shouldn't be possible!

Richard Lynch schrieb:
> On Wed, May 30, 2007 3:34 pm, Samuel Vogel wrote:
>
>>> And what happens if you try to allocate 3M of data?
>>>
>>> $foo = str_repeat('.', 3145728);
>>>
>>>

>> Nothing. It does it without any errors. I can allocate up to 20MB
>> (well
>> a little bit less of course).
>>

>
> Check http://bugs.php.net and see if it's a known issue or an
> exception to the php_admin_* rule or...
>
>

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] ini_set() security question
Old
  (#10)
Richard Lynch
Guest
 
Posts: n/a
Default Re: [PHP] ini_set() security question - 06-02-2007, 08:56 PM

File a bug report then, and see what happens...

But you may want to test with most recent versions if you are not
already on current PHP versions.

On Thu, May 31, 2007 2:46 pm, Samuel Vogel wrote:
> There is no bug filed for this. There is only one older bug (
> http://bugs.php.net/bug.php?id=38804 ) which makes me think
> overwriting
> with ini_set() shouldn't be possible!
>
> Richard Lynch schrieb:
>> On Wed, May 30, 2007 3:34 pm, Samuel Vogel wrote:
>>
>>>> And what happens if you try to allocate 3M of data?
>>>>
>>>> $foo = str_repeat('.', 3145728);
>>>>
>>>>
>>> Nothing. It does it without any errors. I can allocate up to 20MB
>>> (well
>>> a little bit less of course).
>>>

>>
>> Check http://bugs.php.net and see if it's a known issue or an
>> exception to the php_admin_* rule or...
>>
>>

>



--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




Contact Us - Forum Care Forums - Archive - Top