Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 69643 - dev-php/php cURL Open_Basedir Restriction Bypass Vulnerability
Summary: dev-php/php cURL Open_Basedir Restriction Bypass Vulnerability
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Default Configs (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL: http://secunia.com/advisories/13023/
Whiteboard: A4 [ebuild+] jaervosz
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-31 10:47 UTC by Robert Muchacki (RETIRED)
Modified: 2005-04-05 10:22 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Muchacki (RETIRED) gentoo-dev 2004-10-31 10:47:52 UTC
Reported by SecurityFocus:

http://www.securityfocus.com/bid/11557/

Each version is vulnerable.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-10-31 12:15:39 UTC
php-bugs please verify and provide a patched ebuild if needed.
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-10-31 17:38:55 UTC
yup, it's a problem for anybody with USE='curl'.

Here is the PHP tracking bug:
http://bugs.php.net/bug.php?id=30609

No patch from upstream yet.
Comment 3 Thierry Carrez (RETIRED) gentoo-dev 2004-11-03 02:54:10 UTC
PHP Bug has been closed as WONTFIX :

"you need to configure/install curl not to allow access to the local
filesystem. It has a nice configure option for that when you are
installing it."

Not sure what we can do to solve this.
Comment 4 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-11-04 12:20:32 UTC
Inform about it when installing php?
Comment 5 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-11-20 02:19:44 UTC
php-bugs please advise.
Comment 6 Jose Avila III 2004-11-22 22:10:01 UTC
One thing that could be done is php could be patched to check for "file://" and if so throw an error.  This would be a simple 2-5 line patch if anyone thinks its worthwile.
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-22 22:40:10 UTC
Blocking file:// entirely is not an acceptable solution.
I've seen a lot of code that uses file://, in a number of main-stream webapps.

Given that open_basedir isn't infalliable anyway, I'm inclined to just acknowledge that it is a possible threat, but no more than many other potential security problems that cannot be fixed by software.

If you wanted a programmic solutio, basically somebody needs to write a code that does parsing of the path in curl calls, and checks that they are under the open_basedir only if it is set. As I noted, open_basedir doesn't always work anyway, so the gain is very minimal.
Comment 8 Thierry Carrez (RETIRED) gentoo-dev 2004-11-29 07:53:43 UTC
OK so I propose that a warning is added (to ebuild or openbasedir conf option) when php is compiled with USE=curl that warns user that open_basedir can easily be bypassed in that case... Would that be acceptable ?
Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-11-29 11:15:46 UTC
fine by me if that satisfies your definition of security.
Comment 10 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-12-01 01:13:27 UTC
Robin if you have no better proposal please provide a fixed ebuild.
Comment 11 Kurt Lieber (RETIRED) gentoo-dev 2004-12-08 05:24:08 UTC
Is the response from upstream that they aren't planning to fix this issue?  If so, then I'd say Koon's suggestion is the best we can hope for.  (unless anyone wants to suggest pulling php from the tree...)

Even if they do plan to patch it, but not for a while, I think Koon's suggestion is a valid one.  Our job is primarily to inform our users about security vulnerabilities.  Patching is also important, but it comes after informing.
Comment 12 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-12-08 14:08:02 UTC
kurt: yup upstream is calling it not their problem, basically their route is to pass a configure-time option to curl to limit it to working on only a specific part of your local filesystem (which makes it useless for anything else).

Proposal patch:
Index: php5-sapi.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/php5-sapi.eclass,v
retrieving revision 1.33
diff -u -3 -p -w -b -B -r1.33 php5-sapi.eclass
--- php5-sapi.eclass    28 Nov 2004 22:51:03 -0000      1.33
+++ php5-sapi.eclass    8 Dec 2004 22:06:38 -0000
@@ -500,5 +500,9 @@ php5-sapi_pkg_postinst() {

        ewarn "If you have additional third party PHP extensions (such as"
        ewarn "dev-php/turck-mmcache) you may need to recompile them now."
+
+       if use curl;
+               ewarn "Please be aware that CURL can allow the bypass of open_basedir restrictions."
+       fi
 }

and a very similar one for PHP4.
Comment 13 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-12-14 01:06:35 UTC
Robin this is fine, please commit.
Comment 14 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-12-14 01:15:10 UTC
In cvs now.
Comment 15 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-12-28 05:08:35 UTC
Thx Robin.
Comment 16 Jakub Moc (RETIRED) gentoo-dev 2005-04-05 10:07:18 UTC
This is now fixed upstream in 4.3.11 and 5.0.4 - see http://bugs.php.net/bug.php?id=30609

Patch: http://www.php.net/~jani/patches/bug30609.patch
Advisory: http://secunia.com/advisories/13023/

This bug should probably be reopened. ;-)
Comment 17 Thierry Carrez (RETIRED) gentoo-dev 2005-04-05 10:22:15 UTC
The 4.3.11 security enhancements are treated in bug 87517, so we'll leave this one closed.