Bug 1274428 - krb5: uninitialized pwsize variable
Summary: krb5: uninitialized pwsize variable
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 1209571
TreeView+ depends on / blocked
 
Reported: 2015-10-22 17:17 UTC by Siddharth Sharma
Modified: 2019-09-29 13:38 UTC (History)
9 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-10-27 10:29:26 UTC
Embargoed:


Attachments (Terms of Use)

Description Siddharth Sharma 2015-10-22 17:17:27 UTC
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;

Comment 1 Robbie Harwood 2015-10-22 17:41:50 UTC
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!

Comment 2 Robbie Harwood 2015-10-22 17:53:04 UTC
Nevermind, my apologies.  That's neither your fault nor Bugzillas.  I didn't think the link could be that awful...

Comment 3 Siddharth Sharma 2015-10-22 17:57:29 UTC
(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.

Comment 5 Siddharth Sharma 2015-10-27 10:29:26 UTC
Analysis:

on further analysis this is not a security bug.


Note You need to log in before you can comment on or make changes to this bug.