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].