漏洞起因
边界条件错误
危险等级
中
影响系统
Mod_proxy from apache 1.3.xx (最新版本 – 1.3.41)
不受影响系统
危害
远程攻击者可以利用漏洞以应用程序权限执行任意指令。
攻击所需条件
攻击者必须访问Apache mod_proxy。
漏洞信息
Apache mod_proxy是一款用于提供代理服务,能够支持的包括正向代理、反向代理、透明代理。
受漏洞影响的代码如下:
"./src/modules/proxy/proxy_util.c"
long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c, off_t len, int nowrite, int chunked, size_t recv_buffer_size)
{
…
size_t buf_size;
long remaining = 0;
…
for (end_of_chunk = ok = 1; ok;) {
…
if (chunked) {
long chunk_start = 0;
n = 0;
/* start of a new chunk */
if (end_of_chunk) {
end_of_chunk = 0;
/* get the chunk size from the stream */
chunk_start = ap_getline(buf, buf_size, f, 0); <—————- [0] reading line from traffic (socket)
if ((chunk_start <= 0) || ((size_t)chunk_start + 1 >= buf_size) || !ap_isxdigit(*buf)) {
n = -1;
}
/* parse the chunk size */
else {
remaining = ap_get_chunk_size(buf); <—————- [1] convert readed data to ‘long’ size!
if (remaining == 0) { /* Last chunk indicated, get footers */
…
…
}
}
else if (remaining < 0) {
n = -1;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r,
"proxy: remote protocol error, invalid chunk size");
}
}
}
/* read the chunk */
if (remaining > 0) {
n = ap_bread(f, buf, MIN((int)buf_size, (int)remaining)); <————- [2] convert ‘long’ to ‘int’ !!!!
if (n > -1) {
remaining -= n;
end_of_chunk = (remaining == 0);
}
}
…
…
}
代码的简单流程如下:
-服务器读取头字段数据
-如果是块连接
-[0]服务器会等待然后从套接字读取数据(块的大小)
-简单检查服务器接收到的数据
-[1]把接收到的数据转换为’long’类型
-如果是正的块大小
-[2]直接转换’long’为’int’类型 <-在AMD64架构上是一个整数溢出错误
-使用转换后的类型拷贝数据。
当服务器直接转换’long’类型为’int’时64位架构受此漏洞影响。在64位架构上:
long – 8 bytes
int – 4 bytes
当在64位架构上把’long’转换为’int’时,直接删除低4字节。
调用包含此受影响函数的调用如下:
./src/modules/proxy/proxy_cache.c: ap_proxy_send_fb(c->origfp, r, c, c->len, 1, 0, IOBUFSIZE);
./src/modules/proxy/proxy_cache.c: ap_proxy_send_fb(c->origfp, r, c, c->len, 1, 0, IOBUFSIZE);
./src/modules/proxy/proxy_cache.c: ap_proxy_send_fb(c->origfp, r, c, c->len, r->header_only, 0, IOBUFSIZE);
./src/modules/proxy/proxy_cache.c: ap_proxy_send_fb(cachefp, r, NULL, c->len, 0, 0, IOBUFSIZE);
./src/modules/proxy/proxy_ftp.c: ap_proxy_send_fb(data, r, c, -1, 0, 0, conf->io_buffer_size);
./src/modules/proxy/proxy_http.c: ap_proxy_send_fb(f, r, c, c->len, 0, chunked != NULL,
测试方法
http://www.securityfocus.com/data/vulnerabilities/exploits/37966.c
厂商解决方案
目前没有解决方案提供:
http://httpd.apache.org/docs/1.3/mod/mod_proxy.html
漏洞提供者
Adam Zabrocki
0 条评论。