Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26040 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26674 invoked by uid 1010); 12 Oct 2006 19:53:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26659 invoked from network); 12 Oct 2006 19:53:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Oct 2006 19:53:50 -0000 X-Host-Fingerprint: 207.126.230.225 nat-dip4.corp.yahoo.com Received: from [207.126.230.225] ([207.126.230.225:26815] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/05-22864-D4D9E254 for ; Thu, 12 Oct 2006 15:53:50 -0400 Message-ID: To: internals@lists.php.net Date: Thu, 12 Oct 2006 12:53:46 -0700 Lines: 133 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Original X-Posted-By: 207.126.230.225 Subject: open_basedir enhancement, runtime tightening From: pollita@php.net ("Sara Golemon") The attached patch changes open_basedir from PHP_INI_SYSTEM to PHP_INI_ALL. Wait now... let me finish. It introduces a custom INI modification handler for open_basedir which allows the option to be set during Startup and Shutdown (PHP_INI_SYSTEM contexts) normally, then for other contexts (Activate/Deactivate {PERDIR} and Runtime) it checks the inbound settings against the current value and applies some logic: If open_basedir hasn't been set yet: It allows any new setting to be applied (unrestrictive to restrictive) If open_basedir is set, then it checks to see if each component of the new setting would be allowable under the rules of the old setting, if they're all good, it allows it. If any component makes the basedir check less restrictive, it fails (diallows) the change. (less-restrictive to more-restrictive). The advantage of doing this is that package authors and/or users of shared hosting who may not have access to making their settings more restrictive can avoid most simple FS inspection attacks caused by buggy script code by adding a single ini_set(basedir(__FILE__)); to the top of their script or setting it with an .htaccess directive. Note that it doesn't do a thing to avoid code inejction attacks as such an attacker could issue ini_restore("open_basedir"); and have the same access to the FS as they would without this patch. I'll grant you it's not a panacea, and it may be more harmful than good by making people think that tightening up open_basedir is enough, but it's something. Talk amongst y'selves.... -Sara begin 666 open_basedir.txt M26YD97@Z(&UA:6XO;6%I;BYC"CT]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T] M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T*4D-3 M(&9I;&4Z("]R97!OWM[(%!(4%])3DD* M(" J+PH@4$A07TE.25]"14=)3B@I"D! ("TS.3(L-R K,SDS+#<@0$ @4$A0 M7TE.25]"14=)3B@I"B )4U1$7U!(4%])3DE?14Y44EDH(F5X=&5N%]F:6QEWM[($]N57!D871E0F%S941I<@HK M06QL;W=S(&%N>2!C:&%N9V4@=&\@;W!E;E]B87-E9&ER('-E='1I;F<@:6X@ M9'5R:6YG(%-T87)T=7 @86YD(%-H=71D;W=N(&5V96YTPHK"0DO*B!792=R92!I;B!A(%!(4%])3DE?4UE35$5-(&-O;G1E>'0L(&YO M(')EWM[('!H<%]C:&5C:U]S<&5C M:69I8U]O<&5N7V)A#H@;6%I;B]F;W!E M;E]W