首页 > Other > allow_url_fopen & all_url_include的安全设置

allow_url_fopen & all_url_include的安全设置

all_url_include在php 5.2以后添加,安全方便的设置(php的默认设置)为:allow_url_fopen=on;all_url_include=off;
allow_url_fopen = On (允许打开URL文件,预设启用)
allow_url_fopen = Off (禁止打开URL文件)
allow_url_include = Off (禁止引用URL文件,新版增加功能,预设关闭)
allow_url_include = On (允许引用URL文件,新版增加功能)

禁止allow_url_include解决了远端引用(Include)的问题, 同时又让我们还可以在
一般的情形下使用fopen去打开远端的档案, 而不必再牵连上打开include函数所带来的风险.
因此在新版PHP中allow_url_fopen选项预设是打开的,而allow_url_include则预设是关闭的.

然而事实上若从系统角度来看,即使禁止了PHP的allow_url_fopen和allow_url_include功能,
其实也不能完全阻止远端调用及其所带来的安全隐忧,而且它们只是保护了标记为URL的句柄,
也就是说只能影响http(s)和ftp(s)的调用, 但对包含其他标记的远端调用,例如对PHP5.2.0
新版所提供的php和data则无能为力,而这些调用一样会导致注入风险,请参考如下代码:

<?php // Insecure Include
// The following Include statement will
// include and execute everything POSTed
// to the server
include “php://input”;
?>

<?php // Insecure Include
// The following Include statement will

分类:Other
  1. 还没有评论。
  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: