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
铸铝件 磨煤喷粉机 风机叶轮 铸铜件
相关文档:
PHP解疑
1. 代码重用方法include()和require()函数差异?
1) Require()函数
使用requier()包含外部php文件时,只要自身php文件被执行,外部文件的内容就将被包含进该自身php文件,当包含的外部文件发生错误时,系统将给出错误提示,并且停止php文件的执行。
示例:
调用文件config.inc的程序代码:
<?php ec ......
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite tabl ......
解决的办法有好几个:
第一个是:str_split(),这个方法是PHP5加入的。
<?php
$str = "Hello Friend";
$arr1 = str_split($str);
$arr2 = str_split($str, 3);
print_r($arr1);
print_r($arr2);
?>
输出就是:
Array
(
[0] => H
[1] => e
[2] => l
[3] => l
......
1.如果一个方法可静态化,就对它做静态声明。速率可提升至4倍。
2.echo 比 print 快。
3.使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接。
4.在执行for循环之前确定最大循环数,不要每循环一次都计算最大值。
5.注销那些不用的变量尤其是大数组,以便释放内存。
6.尽量避免使用__get,__se ......
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 ......