php常常因為它可能允許urls被導入和執行語句被人們指責。事實上,這件事情并不是很讓人感到驚奇,因為這是導致稱為remote url include vulnerabilities的php應用程序漏洞的最重要的原因之一。
因為這個原因,許多安全研究人員建議在php.ini配置中禁用指向allow_url_fopen。不幸的是,許多推薦這種方法的人,并沒有意識到,這樣會破壞很多的應用并且并不能保證100%的解決remote url includes以及他帶來的不安全性。
通常,用戶要求在他們使用其他的文件系統函數的時候,php允許禁止url包含和請求聲明支持。
因為這個原因,計劃在php6中提供allow_url_include。在這些討論之后,這些特性在php5.2.0 中被backported?,F在大多數的安全研究人員已經改變了他們的建議,只建議人們禁止allow_url_include。
不幸的是,allow_url_fopen和allow_url_include并不是導致問題的原因。一方面來說在應用中包含本地文件仍然是一件足夠危險的事情,因為攻擊者經常通過sessiondata, fileupload, logfiles,...等方法獲取php代碼………
另一方面allow_url_fopen和allow_url_include只是保護了against url handles標記為url.這影響了http(s) and ftp(s)但是并沒有影響php或date(new in php5.2.0) urls.這些url形式,都可以非常簡單的進行php代碼注入。
example 1: use php://input to read the post data
<?php
// insecure include
// the following include statement will
// include and execute everything posted
// to the server
include "php://input";
?>
example 2: use data: to include arbitrary code
<?php
// insecure include
// the following include statement will
// include and execute the base64 encoded
// payload. here this is just phpinfo()
include "data:;base64,pd9wahagcghwaw5mbygpoz8+";
?>
把這些放到我們的運算里面將會非常明顯的發現既不是url_allow_fopen也不是url_allor_include 被保障。這些只是因為過濾器很少對矢量進行過濾。能夠100%解決這個url include vulnerabilities的方法是我們的suhosin擴展.
原文地址:http://blog.php-security.org/archives/45-php-5.2.0-and-allow_url_include.html
新聞熱點
疑難解答