答案:Bug1:
void set_proc_title(char *fmt,...) in src/main.c
memset(statbuf, 0, sizeof(statbuf));
vsnprintf(statbuf, sizeof(statbuf), fmt, msg);#ifdef HAVE_SETPROCTITLE
setproctitle(statbuf);
#endif /* HAVE_SETPROCTITLE */
setproctitle, defined setproctitle(char *fmt,...);, calls vsnprintf().
这存在格式化攻击的漏洞。通过攻击缓冲区可能获得 root 权限。Bug2:
MODRET pam_auth(cmd_rec *cmd) in modules/mod_pam.c
/* Allocate our entries...we don't free this because PAM does this for
us.
*/
pam_user = malloc(strlen(cmd->argv[0]) + 1);
if(pam_user == (char *)0)
return pam_return_type ? ERROR(cmd) : DECLINED(cmd);
sstrncpy(pam_user, cmd->argv[0], strlen(cmd->argv[0]) + 1);pam_pass = malloc(strlen(cmd->argv[1]) + 1);
if(pam_pass == (char *)0)
return pam_return_type ? ERROR(cmd) : DECLINED(cmd);
sstrncpy(pam_pass, cmd->argv[1], strlen(cmd->argv[1]) + 1);
这不能造成拒绝服务攻击,除非管理员设置了更高的界限。Bug3:
void logformat(char *nickname, char *fmts) 没有在本地变量 'format' 进行边界检查。结果登录格式将溢出缓冲区。Bug3:
int dolist(cmd_rec *cmd, const char *opt, int clearflags) in
modules/mod_ls.c
char pbuffer[MAXPATHLEN];
if(*arg == '~') {
struct passwd *pw;
int i;
const char *p;
i = 0;
p = arg;
p++;
while(*p && *p != '/')
pbuffer[i++] = *p++;
pbuffer[i] = '\0';
这个函数通过 cmd_stat 调用与 'arg'存在于静态堆栈,看上去是有问题但不能只通过输入 1024 字节造成溢出,不过仍然是不安全的设计。
解决方法:
1。使用 setproctitle("%s",statbuf);
2。pstrdup() 或只使用 cmd->argv[0] and cmd->argv[1].