PHP tempname()函数绕过safe_mode安全限制漏洞
BUGTRAQ ID: 36555
CVE ID: CVE-2009-3557
PHP是广泛使用的通用目的脚本语言,特别适合于Web开发,可嵌入到HTML中。
PHP的tempnam()中的错误可能允许绕过safe_mode限制。以下是ext/standard/file.c中的有漏洞代码段:
PHP_FUNCTION(tempnam)
{
char *dir, *prefix;
int dir_len, prefix_len;
size_t p_len;
char *opened_path;
char *p;
int fd;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &dir, &dir_len,
&prefix, &prefix_len) == FAILURE) {
return;
}
if (php_check_open_basedir(dir TSRMLS_CC)) { [1]
RETURN_FALSE;
}
php_basename(prefix, prefix_len, NULL, 0, &p, &p_len TSRMLS_CC);
if (p_len > 64) {
p[63] = '\0';mud pump
}
if ((fd = php_open_temporary_fd(dir, p, &opened_path TSRMLS_CC)) >= 0) {
close(fd);
RETVAL_STRING(opened_path, 0);
}
efree(p);
}
在[1]处tempnam()函数仅检查了open_basedir值。
<*参考
http://securityreason.com/securityalert/6601
http://secunia.com/advisories/37412/
*>
SEBUG安全建议:
厂商补丁:
PHP
---
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_2/ext/standard/file.c?view=log
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/ext/standard/file.c?view=log
铸铝件 磨煤喷粉机 风机叶轮 铸铜件
相关文档:
1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)
2、echo(),print(),print_r()的区别(3分)
3、能够使HTML和PHP分离开使用的模板(1分)
4、使用哪些工具进行版本控制?(1分)
5、如何实现字符串翻转?(3分)
--------------------------------------------------------------- ......
PHP的发展
PHP 原本的简称为 Personal Home Page,是Rasmus Lerdorf 为了要维护个人网页,而用c语言开发的一些CGI工具程序集,来取代原先使用的 Perl 程序。最初这些工具程序用来显示 Rasmus Lerdorf 的个人履历,以及统计网页流量。他将这些程序和一些表单直译器整合起来,称为 PHP ......
尽量使用单引号而不是双引号。
尽量使用带条件的include而不是require。
尽量使用echo而不是print。
尽量使用内嵌的HTML而不是echo。
尽量使用str-replace()而不是ereg-replace()。
尽量sql不用联合查询。
......
服务器变量 $_SERVER 详解:
1、$_SESSION['PHP_SELF'] -- 获取当前正在执行脚本的文件名
2、$_SERVER['SERVER_PROTOCOL'] -- 请求页面时通信协议的名称和版本。例如,“HTTP/1.0”。
3、$_SERVER['REQUEST_TIME'] -- 请求开始时的时间戳。从 PHP 5.1.0 起有效。和time函数效果一样。
4、$_SERVER['argv'] - ......
OpenX adserver version 2.8.1 and lower is vulnerable to remote code
execution. To be exploited, this vulnerability requires banner / file
upload permissions, such as granted to the 'advertiser' and
'administrator' roles.
This vulnerability is caused by the (insecure) file upload mechanism of
af ......