【发布时间】:2011-12-02 13:17:47
【问题描述】:
我有两个网络服务器,都在 Lighttpd + php 上(通过 fastCGI)。
[user@box ~]$ lighttpd -v
lighttpd/1.4.29 (ssl) - a light and fast webserver
Build-Date: Aug 7 2011 10:52:01
[user@box ~]$ php -v
PHP 5.3.8 with Suhosin-Patch (cli) (built: Sep 30 2011 05:34:36)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
[user@box ~]$ php-cgi -v
PHP 5.3.8 with Suhosin-Patch (cgi-fcgi) (built: Sep 30 2011 05:35:14)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
Lighttpd 和 php-cgi 在用户 'http' 下使用 /bin/false(伪造的)shell 运行:
[user@box ~]$ cat /etc/passwd | grep http
http:x:33:33:http:/srv/http:/bin/false
[user@box ~]$ ps aux | grep "lighttpd\_php-cgi"
http 1291 0.0 1.1 5152 2816 tty1 S Oct06 0:00 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
http 1292 0.0 1.5 14476 3904 ? Ss Oct06 0:00 /usr/bin/php-cgi
但是我仍然可以通过php的system()函数执行shell命令(例如)!
我的 php.ini 中没有 disable_functions。 如果我通过 php 执行 system("whoami") 或 system("id") ,我会得到以下信息:
http
uid=33(http) gid=33(http) groups=33(http)
(必须如此)。
为什么我可以使用 /bin/false 作为 shell 执行用户的命令?
【问题讨论】: