BUGTRAQ ID: 27943
Lighttpd是一款轻型的开放源码Web Server软件包。
Lighttpd在分配全局文件描述符数组时存在计算错误,远程攻击者可能利用此漏洞导致服务不可用。
创建文件描述符数组的方式如下:
fdevent.c:
15 fdevents *fdevent_init(size_t maxfds, fdevent_handler_t type) {
19 ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray));
server.c:
1076 if (NULL == (srv->ev = fdevent_init(srv->max_fds + 1, srv->event_handler))) {
在同一文件中的之前部分:
679 if (0 != getrlimit(RLIMIT_NOFILE, &rlim)) {
680 log_error_write(srv, __FILE__, __LINE__,
681 "ss", "couldn't get 'max filedescriptors'",
682 strerror(errno));
683 return -1;
684 }
685
686 if (use_rlimit && srv->srvconf.max_fds) {
687 /* set rlimits */
688
689 rlim.rlim_cur = srv->srvconf.max_fds;
690 rlim.rlim_max = srv->srvconf.max_fds;
691
692 if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) {
693 log_error_write(srv, __FILE__, __LINE__,
694 "ss", "couldn't set 'max filedescriptors'",
695 strerror(errno));
696 return -1;
697 }
698 }
700 /* #372: solaris need some fds extra for devpoll */
701 if (rlim.rlim_cur > 10) rlim.rlim_cur -= 10;
827 srv->max_fds = rlim.rlim_cur;
进程获取当前所配置的rlimit并保存到rlim中。如果配置设置了max_fds,就会覆盖当前任务所配置的。然后,max_fds以10递减,使用max_fds大小分配文件描述符数组。最终,系统可能给出多于max_fds个文件描述符,出现分段错误,导致崩溃。
LightTPD 1.4.18
临时解决方法:
* 如果没有运行solaris的话,标注server.c的701行
* 在fdevent.c文件的19行用maxfds + 10替换maxfds
厂商补丁:
LightTPD
--------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
<a href=http://trac.lighttpd.net/trac/attachment/ticket/1562/Fix-372-and-1562.patch target=_blank>http://trac.lighttpd.net/trac/attachment/ticket/1562/Fix-372-and-1562.patch</a>
暂无评论