Skip to content

Commit bdaf65a

Browse files
committed
fix state confusion between PAM and privsep code
Commits b9a6dd4 and df2b281 introduced a potential desynchronisation between the PAM code and the sshd-session monitor that could result in authentication bypass if the unprivileged sshd-auth process had been compromised. Reported by Ben Edelman of NIST. Only git HEAD is affected, these changes have not yet been included in an OpenSSH release.
1 parent 6eb5a68 commit bdaf65a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

auth-pam.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,14 @@ sshpam_free_ctx(void *ctxtp)
10151015
*/
10161016
}
10171017

1018+
int
1019+
sshpam_priv_kbdint_authdone(void *ctxtp)
1020+
{
1021+
struct pam_ctxt *ctxt = ctxtp;
1022+
1023+
return ctxt->pam_done == SshPamAuthenticated;
1024+
}
1025+
10181026
KbdintDevice sshpam_device = {
10191027
"pam",
10201028
sshpam_init_ctx,

auth-pam.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ int sshpam_auth_passwd(Authctxt *, const char *);
4242
int sshpam_get_maxtries_reached(void);
4343
void sshpam_set_maxtries_reached(int);
4444
int is_pam_session_open(void);
45+
int sshpam_priv_kbdint_authdone(void *ctxtp);
4546

4647
#endif /* USE_PAM */

monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ mm_answer_pam_query(struct ssh *ssh, int sock, struct sshbuf *m)
12041204
fatal_f("no context");
12051205
ret = (sshpam_device.query)(sshpam_ctxt, &name, &info,
12061206
&num, &prompts, &echo_on);
1207-
if (ret == 0 && num == 0)
1207+
if (ret == 0 && num == 0 && sshpam_priv_kbdint_authdone(sshpam_ctxt))
12081208
sshpam_authok = sshpam_ctxt;
12091209
if (num > 1 || name == NULL || info == NULL)
12101210
fatal("sshpam_device.query failed");

0 commit comments

Comments
 (0)