Bug 1274428 - krb5: uninitialized pwsize variable
krb5: uninitialized pwsize variable
Status: CLOSED NOTABUG
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
low Severity low
: ---
: ---
Assigned To: Red Hat Product Security
impact=low,public=20150403,reported=2...
: Security
Depends On:
Blocks: 1209571
  Show dependency treegraph
 
Reported: 2015-10-22 13:17 EDT by Siddharth Sharma
Modified: 2015-10-27 06:36 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-27 06:29:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Siddharth Sharma 2015-10-22 13:17:27 EDT
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 13:41:50 EDT
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 13:53:04 EDT
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 13:57:29 EDT
(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 06:29:26 EDT
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.