-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/pcntl: pcntl_exec add open_basedir restriction check. #14772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Might be worth considering the semantics of access restriction error handling specific to PHP For example:
outputs
Notice how granular the error handling in the Unix API is Although it could tell the user "you passed in a bad value", it goes the extra mile to introduce specific error numbers that give the user more insight into what happened ("file does not exist", or "you don't have acccess"), and empowers the user to easily introduce different code paths for different types of errors. In that vein, we should have more specific errors associated with |
The aim is not for cases as your examples but more case where the path is usually allowed. Let's say the admin does not want the php user access to |
Okay, lets examine this example. We would be wrong, or in the least unclear, to claim that |
Yes your AccessError proposal makes sense ; sure. |
Yeah, that's the point, let's be very specific about what kind of error occurred, to empower the user to easily handle different situations. With |
if the admin wants to disallow relative path or other unauthorized accesses.
316d7de
to
dcea9e1
Compare
dcea9e1
to
43e2e3d
Compare
open_basedir=${HOME}/bin | ||
--SKIPIF-- | ||
<?php | ||
if (!getenv("TEST_PHP_EXECUTABLE") || !is_executable(getenv("TEST_PHP_EXECUTABLE"))) die("skip TEST_PHP_EXECUTABLE not set"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although not likely, $TEST_PHP_EXECUTABLE
might be under $HOME/bin
.
Perhaps ensure that test will always be correct regardless of environment it runs in.
43e2e3d
to
1475494
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a discussion on the internals mailing list.
Normally we issue warnings for this case, so promoting it might make sense for new functions but I don't know what other people think about this.
Ok will do |
On one hand, it does break the API contract in a subtle way, and thus could break existing code paths for some users. On the other hand, in some of these cases, their existing code + config combination might also pose a security issue. |
it won't go any further, the idea got enough downvotes :) |
@devnexen I do think you are onto a legit security issue, the question is how to address it most elegantly. Perhaps we should open a GitHub issue ticket for discussion. |
Yes I meant it s over in the manner I envisioned but sure we should find another way. |
We are on the same page. What you envision could be the way it's handled in the next API-breaking version of PHP (e.g. PHP 9). But 8.x users should be offered some opt-in fix instead. |
Perhaps if we introduce an ephemeral (PHP 8.x only) php.ini feature flag, like In PHP 9.x we could remove the flag and make the secure behavior default. |
And at the end of the day, open_basedir is known to be unreliable, and I'm of the opinion that this feature, at least as originally designed, is not necessary in the language at all (I don't see a case where I would use it myself), so not sure if it's worth spending much time on improving it, unless the design approach is changed fundamentally. Users are better off relying on external sandboxing (e.g. FreeBSD jails). |
Note that already 5y ago there was talk about removing and deprecating the setting: https://externals.io/message/105606 Maybe something to try and push for again. |
if the admin wants to disallow relative path or other unauthorized accesses.