|
|
aad6db4 |
From af0faf666c5008e54dfe43684f210e3581ff1bca Mon Sep 17 00:00:00 2001
|
|
|
aad6db4 |
From: ikerexxe <ipedrosa@redhat.com>
|
|
|
aad6db4 |
Date: Tue, 16 Jun 2020 14:32:36 +0200
|
|
|
aad6db4 |
Subject: [PATCH 1/2] pam_unix: avoid determining if user exists
|
|
|
aad6db4 |
|
|
|
aad6db4 |
Taking a look at the time for the password prompt to appear it was
|
|
|
aad6db4 |
possible to determine if a user existed in a system. Solved it by
|
|
|
aad6db4 |
matching the runtime until the password prompt was shown by always
|
|
|
aad6db4 |
checking the password hash for an existing and a non-existing user.
|
|
|
aad6db4 |
|
|
|
aad6db4 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1629598
|
|
|
aad6db4 |
---
|
|
|
aad6db4 |
modules/pam_unix/passverify.c | 6 ++++++
|
|
|
aad6db4 |
modules/pam_unix/support.c | 33 ++++++++++++++++++++++++++-------
|
|
|
aad6db4 |
2 files changed, 32 insertions(+), 7 deletions(-)
|
|
|
aad6db4 |
|
|
|
aad6db4 |
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
|
|
|
aad6db4 |
index a571b4f7..7455eae6 100644
|
|
|
aad6db4 |
--- a/modules/pam_unix/passverify.c
|
|
|
aad6db4 |
+++ b/modules/pam_unix/passverify.c
|
|
|
aad6db4 |
@@ -1096,6 +1096,12 @@ helper_verify_password(const char *name, const char *p, int nullok)
|
|
|
aad6db4 |
if (pwd == NULL || hash == NULL) {
|
|
|
7d1e156 |
helper_log_err(LOG_NOTICE, "check pass; user unknown");
|
|
|
7d1e156 |
retval = PAM_USER_UNKNOWN;
|
|
|
7d1e156 |
+ } else if (p[0] == '\0' && nullok) {
|
|
|
aad6db4 |
+ if (hash[0] == '\0') {
|
|
|
7d1e156 |
+ retval = PAM_SUCCESS;
|
|
|
7d1e156 |
+ } else {
|
|
|
7d1e156 |
+ retval = PAM_AUTH_ERR;
|
|
|
7d1e156 |
+ }
|
|
|
7d1e156 |
} else {
|
|
|
aad6db4 |
retval = verify_pwd_hash(p, hash, nullok);
|
|
|
7d1e156 |
}
|
|
|
aad6db4 |
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
|
|
|
aad6db4 |
index 41db1f04..dc67238c 100644
|
|
|
aad6db4 |
--- a/modules/pam_unix/support.c
|
|
|
aad6db4 |
+++ b/modules/pam_unix/support.c
|
|
|
aad6db4 |
@@ -601,6 +601,8 @@ _unix_blankpasswd (pam_handle_t *pamh, unsigned long long ctrl, const char *name
|
|
|
7d1e156 |
char *salt = NULL;
|
|
|
aad6db4 |
int daysleft;
|
|
|
7d1e156 |
int retval;
|
|
|
7d1e156 |
+ int execloop = 1;
|
|
|
7d1e156 |
+ int nonexistent = 1;
|
|
|
7d1e156 |
|
|
|
7d1e156 |
D(("called"));
|
|
|
7d1e156 |
|
|
|
aad6db4 |
@@ -624,14 +626,31 @@ _unix_blankpasswd (pam_handle_t *pamh, unsigned long long ctrl, const char *name
|
|
|
7d1e156 |
|
|
|
7d1e156 |
/* UNIX passwords area */
|
|
|
7d1e156 |
|
|
|
7d1e156 |
- retval = get_pwd_hash(pamh, name, &pwd, &salt);
|
|
|
7d1e156 |
+ /*
|
|
|
7d1e156 |
+ * Execute this loop twice: one checking the password hash of an existing
|
|
|
7d1e156 |
+ * user and another one for a non-existing user. This way the runtimes
|
|
|
7d1e156 |
+ * are equal, making it more difficult to differentiate existing from
|
|
|
7d1e156 |
+ * non-existing users.
|
|
|
7d1e156 |
+ */
|
|
|
7d1e156 |
+ while (execloop) {
|
|
|
7d1e156 |
+ retval = get_pwd_hash(pamh, name, &pwd, &salt);
|
|
|
7d1e156 |
|
|
|
7d1e156 |
- if (retval == PAM_UNIX_RUN_HELPER) {
|
|
|
7d1e156 |
- /* salt will not be set here so we can return immediately */
|
|
|
7d1e156 |
- if (_unix_run_helper_binary(pamh, NULL, ctrl, name) == PAM_SUCCESS)
|
|
|
7d1e156 |
- return 1;
|
|
|
7d1e156 |
- else
|
|
|
7d1e156 |
- return 0;
|
|
|
7d1e156 |
+ if (retval == PAM_UNIX_RUN_HELPER) {
|
|
|
7d1e156 |
+ execloop = 0;
|
|
|
7d1e156 |
+ if(nonexistent) {
|
|
|
7d1e156 |
+ get_pwd_hash(pamh, "pam_unix_non_existent:", &pwd, &salt);
|
|
|
7d1e156 |
+ }
|
|
|
7d1e156 |
+ /* salt will not be set here so we can return immediately */
|
|
|
7d1e156 |
+ if (_unix_run_helper_binary(pamh, NULL, ctrl, name) == PAM_SUCCESS)
|
|
|
7d1e156 |
+ return 1;
|
|
|
7d1e156 |
+ else
|
|
|
7d1e156 |
+ return 0;
|
|
|
7d1e156 |
+ } else if (retval == PAM_USER_UNKNOWN) {
|
|
|
7d1e156 |
+ name = "root";
|
|
|
7d1e156 |
+ nonexistent = 0;
|
|
|
7d1e156 |
+ } else {
|
|
|
7d1e156 |
+ execloop = 0;
|
|
|
7d1e156 |
+ }
|
|
|
7d1e156 |
}
|
|
|
7d1e156 |
|
|
|
7d1e156 |
/* Does this user have a password? */
|
|
|
aad6db4 |
--
|
|
|
aad6db4 |
2.26.2
|
|
|
aad6db4 |
|
|
|
aad6db4 |
|
|
|
aad6db4 |
From 0e9b286afe1224b91ff00936058b084ad4b776e4 Mon Sep 17 00:00:00 2001
|
|
|
aad6db4 |
From: ikerexxe <ipedrosa@redhat.com>
|
|
|
aad6db4 |
Date: Tue, 16 Jun 2020 14:44:04 +0200
|
|
|
aad6db4 |
Subject: [PATCH 2/2] pam_usertype: avoid determining if user exists
|
|
|
aad6db4 |
|
|
|
aad6db4 |
Taking a look at the time for the password prompt to appear it was
|
|
|
aad6db4 |
possible to determine if a user existed in a system. Solved it by
|
|
|
aad6db4 |
matching the runtime until the password prompt was shown by always
|
|
|
aad6db4 |
checking the password hash for an existing and a non-existing user.
|
|
|
aad6db4 |
|
|
|
aad6db4 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1629598
|
|
|
aad6db4 |
---
|
|
|
aad6db4 |
modules/pam_usertype/pam_usertype.c | 3 +++
|
|
|
aad6db4 |
1 file changed, 3 insertions(+)
|
|
|
aad6db4 |
|
|
|
aad6db4 |
diff --git a/modules/pam_usertype/pam_usertype.c b/modules/pam_usertype/pam_usertype.c
|
|
|
aad6db4 |
index 2807c306..d03b73b5 100644
|
|
|
aad6db4 |
--- a/modules/pam_usertype/pam_usertype.c
|
|
|
aad6db4 |
+++ b/modules/pam_usertype/pam_usertype.c
|
|
|
aad6db4 |
@@ -139,8 +139,11 @@ pam_usertype_get_uid(struct pam_usertype_opts *opts,
|
|
|
7d1e156 |
"error retrieving information about user %s", username);
|
|
|
7d1e156 |
}
|
|
|
7d1e156 |
|
|
|
7d1e156 |
+ pam_modutil_getpwnam(pamh, "root");
|
|
|
7d1e156 |
+
|
|
|
7d1e156 |
return PAM_USER_UNKNOWN;
|
|
|
7d1e156 |
}
|
|
|
7d1e156 |
+ pam_modutil_getpwnam(pamh, "pam_usertype_non_existent:");
|
|
|
7d1e156 |
|
|
|
7d1e156 |
*_uid = pwd->pw_uid;
|
|
|
7d1e156 |
|
|
|
aad6db4 |
--
|
|
|
aad6db4 |
2.26.2
|
|
|
aad6db4 |
|