Bug 1274428

Summary: krb5: uninitialized pwsize variable
Product: [Other] Security Response Reporter: Siddharth Sharma <sisharma>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: abokovoy, carnil, dpal, jplans, jrusnack, nalin, nathaniel, pkis, rharwood
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-10-27 10:29:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1209571    

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.