Description: A flaw was found in code of chpass_util.c shipped with kerberos, where pwsize variable was left uninitialized. If attacker is able to control the input to the function that uses uninitialized 'pwsize' variable it can lead to crash. code: int code, code2; unsigned int pwsize; static char buffer[255]; char *new_password; kadm5_principal_ent_rec princ_ent; kadm5_policy_ent_rec policy_ent; _KADM5_CHECK_HANDLE(server_handle); if (ret_pw) *ret_pw = NULL; if (new_pw != NULL) { new_password = new_pw; } else { /* read the password */ krb5_context context; if ((code = (int) kadm5_init_krb5_context(&context)) == 0) { pwsize = sizeof(buffer); code = krb5_read_password(context, KADM5_PW_FIRST_PROMPT, KADM5_PW_SECOND_PROMPT, buffer, &pwsize); krb5_free_context(context); } if (code == 0) new_password = buffer; else { #ifdef ZEROPASSWD memset(buffer, 0, sizeof(buffer)); #endif if (code == KRB5_LIBOS_BADPWDMATCH) { strncpy(msg_ret, string_text(CHPASS_UTIL_NEW_PASSWORD_MISMATCH), msg_len - 1); msg_ret[msg_len - 1] = '\0'; return(code); } else { snprintf(msg_ret, msg_len, "%s %s\n\n%s", error_message(code), string_text(CHPASS_UTIL_WHILE_READING_PASSWORD), string_text(CHPASS_UTIL_PASSWORD_NOT_CHANGED)); msg_ret[msg_len - 1] = '\0'; return(code); } } if (pwsize == 0) { #ifdef ZEROPASSWD memset(buffer, 0, sizeof(buffer)); #endif strncpy(msg_ret, string_text(CHPASS_UTIL_NO_PASSWORD_READ), msg_len - 1); msg_ret[msg_len - 1] = '\0'; return(KRB5_LIBOS_CANTREADPWD); /* could do better */ } } if (ret_pw) *ret_pw = new_password;
Oh, what fun. Happy Thursday! In the future, when pasting code, please be aware that bugzilla will strip formatting; links to pastebins etc. work much better. (The above is essentially unreadble.) Thanks!
Nevermind, my apologies. That's neither your fault nor Bugzillas. I didn't think the link could be that awful...
(In reply to Robbie Harwood from comment #1) > Oh, what fun. Happy Thursday! > > In the future, when pasting code, please be aware that bugzilla will strip > formatting; links to pastebins etc. work much better. (The above is > essentially unreadble.) Thanks! yeah, thanks. I actually refrain from copy/pasting full code and post snippets only which is easier to format. I thought it would be useful to share code here instead of clicking links. Formatting is lost in the above link as well.
Analysis: on further analysis this is not a security bug.