When allow_url_include was introduced, it was good enough protection against “remote script inclusion”. However, it causes problem for “local script inclusion” protections. This RFC addresses the issue and make "local script inclusion" protection more effective.
allow_url_include is INI_SYSTEM, therefore include/require simply ignore the setting for certain stream wrappers always. allow_url_include does not actually disallow URL form includes. It allows “phar://” regardless of allow_url_include setting and helps attackers obfuscate attack scripts. e.g. include(“phar://evil_phar_file/evil_script.php”) is allowed at anytime. Current behavior may allow to bypass certain types of security filters and allow attacker's script to be executed.
Current allow_url_include behavior is wrong for 3 reasons.
allow_url_include being INI_SYSTEM is false sense of security. It also violates simple API principle that
or
Current allow_url_include and related API does not satisfy none of them.
We need more precise URL include control.
include('phar://phar_file/script.php', 'phar://');
Pros:
Cons:
include 'script.php' [, $include_type=0 ];
where $include_type (bitwise) is
Add getType() method to stream wrapper class returns PHP_STREAM_LOCAL, PHP_STREAM_REMOTE or PHP_STREAM_ALL.
Pros:
Cons:
PHP 7.0
CLI - loading phar as main script is allowed by default.
php://input and php://stdin must be handled differently. These are “remote” input under Web SAPI while these are “local” input under CLI. Therefore, these “php” wrappers are handled according to SAPI type.
Modules have stream wrappers.
Wrappers defined by PHP source distribution. (There may be others)
$ php -r "var_dump(stream_get_wrappers());" array(12) { [0]=> string(5) "https" [1]=> string(4) "ftps" [2]=> string(13) "compress.zlib" [3]=> string(3) "php" [4]=> string(4) "file" [5]=> string(4) "glob" [6]=> string(4) "data" [7]=> string(4) "http" [8]=> string(3) "ftp" [9]=> string(14) "compress.bzip2" [10]=> string(4) "phar" [11]=> string(3) "zip" }
None
There will be constants for stream wrapper. TBD
allow_url_include ini is removed.
allow_url_fopen
allow_url_fopen has same issues. However, allow_url_fopen has less issue because it does not parse and execute script.
Requires 2/3 majority
TBD
After the project is implemented, this section should contain
Links to external references, discussions or RFCs
Keep this updated with features that were discussed on the mail lists.