On 31.08.2016 at 05:46, Davey Shafik wrote:
> Sorry, I dropped the ball on this one:
>
> ../sapi/cli/php -d "output_handler=" -d "open_basedir=." -d
> "disable_functions=" -d "output_buffering=Off" -d "error_reporting=32767"
> -d "display_errors=1" -d "display_startup_errors=1" -d "log_errors=0" -d
> "html_errors=0" -d "track_errors=1" -d "report_memleaks=1" -d
> "report_zend_debug=0" -d "docref_root=" -d "docref_ext=.html" -d
> "error_prepend_string=" -d "error_append_string=" -d "auto_prepend_file="
> -d "auto_append_file=" -d "ignore_repeated_errors=0" -d "precision=14" -d
> "memory_limit=128M" -d "log_errors_max_len=0" -d "opcache.fast_shutdown=0"
> -d "opcache.file_update_protection=0" -f
> "/php-src/ext/sqlite3/tests/sqlite3_21_security.php"
>
> I think the issue is that the test isn't run in ext/sqlite3/tests, but from
> the root of the checkout, which means that open_basedir=. would include
> everything in the repo, including the attempt "../bad" directory.
Ah, I have not thought of running in a root directory directly (or would
have expected that "../bad" would still trigger the open_basedir warning).
> Potential solutions:
>
> Change the path to be "../../../../../bad" to ensure it's outside the
> top-level of the script.
If "../bad" doesn't trigger the open_basedir restriction, "../../bad"
most likely also wouldn't. Please correct me if I'm wrong.
> Add a: chdir(__DIR__); at the top.
Indeed, using chdir() seems to be the proper way to test for
open_basedir restrictions, see
<https://github.com/php/php-src/blob/PHP-7.0.11/tests/security/open_basedir.inc#L12-L14>.
Should that be changed for PHP-5.6+?
Cheers!