Skip to content

Fixed bug #42560: check open_basedir after the fallback to the system's temporary directory in tempnam() #6526

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

Closed
wants to merge 2 commits into from

Conversation

sj-i
Copy link
Contributor

@sj-i sj-i commented Dec 20, 2020

  • https://bugs.php.net/bug.php?id=42560
  • Currently, open_basedir checking is done against the passed directory name before any fallback is processed.
  • With this fix open_basedir checking is done against the actual directory going to be used.
  • The open_basedir checking continues to be skipped if PHP_TMP_FILE_OPEN_BASEDIR_CHECK isn't set.
  • As a side effect of this fix, file uploads become to be always affected by the open_basedir checking. The current implementation seems to bypass the open_basedir checking when upload_tmp_dir is set.
  • The open_basedir checking continues to be skipped if PHP_TMP_FILE_OPEN_BASEDIR_CHECK_* aren't set.
    • PHP_TMP_FILE_OPEN_BASEDIR_CHECK was originally added as a follow-up of Request #69489 #1246 , but was never used by the callers in php-src.
    • To keep the original behavior of bypassing the open_basedir check when upload_tmp_dir is explicitly set, I've introduced macros that can be used to specify whether the check should be performed, separately for fallback and explicitly specified directories.

@nikic
Copy link
Member

nikic commented Jan 4, 2021

Generally looks reasonable to me. @cmb69 Any thoughts on the upload_tmp_dir part? I could see an argument for just not checking open_basedir for that at all, as it's a PHP_INI_SYSTEM setting.

@cmb69
Copy link
Member

cmb69 commented Jan 4, 2021

I think that checking an explicitly set upload_tmp_dir for open_basedir should at least not be done in a revision. The docs are not super clear on that, but state:

If open_basedir is on, then the system default directory must be allowed for an upload to succeed.

So one could reasonably assume that this is not the case for explicitly set upload_tmp_dir.

@sj-i
Copy link
Contributor Author

sj-i commented Jan 5, 2021

@nikic @cmb69
Thanks for your comments.
I've fixed it so that open_basedir is not checked if an explicit upload_tmp_dir is set.

@php-pulls php-pulls closed this in 5d31ee3 Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants