|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
From 86eed7ca01864b9fd17099e57f10f2b9b6b568a1 Mon Sep 17 00:00:00 2001
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
Date: Mon, 26 Nov 2018 22:33:17 +0100
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
Subject: [PATCH] pam_unix: Report unusable hashes found by checksalt to
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
syslog.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
libxcrypt can be build-time configured to support (or not support)
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
various hashing methods. Future versions will also have support for
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
runtime configuration by the system's vendor and/or administrator.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
For that reason adminstrator should be notified by pam if users cannot
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
log into their account anymore because of such a change in the system's
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
configuration of libxcrypt.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
Also check for malformed hashes, like descrypt hashes starting with
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
"$2...", which might have been generated by unsafe base64 encoding
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
functions as used in glibc <= 2.16.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
Such hashes are likely to be rejected by many recent implementations
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
of libcrypt.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
* modules/pam_unix/passverify.c (verify_pwd_hash): Report unusable
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
hashes found by checksalt to syslog.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
---
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
modules/pam_unix/passverify.c | 36 +++++++++++++++++++++++++++++++++++
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
1 file changed, 36 insertions(+)
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
index eb2444bb..2c808eb5 100644
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
--- a/modules/pam_unix/passverify.c
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+++ b/modules/pam_unix/passverify.c
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
@@ -103,6 +103,42 @@ verify_pwd_hash(const char *p, char *hash, unsigned int nullok)
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
* Ok, we don't know the crypt algorithm, but maybe
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
* libcrypt knows about it? We should try it.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
*/
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+#if defined(CRYPT_CHECKSALT_AVAILABLE) && CRYPT_CHECKSALT_AVAILABLE
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ /* Get the status of the hash from checksalt */
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ int retval_checksalt = crypt_checksalt(hash);
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ /*
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * Check for hashing methods that are disabled by
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * libcrypt configuration and/or system preset.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ */
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ if (retval_checksalt == CRYPT_SALT_METHOD_DISABLED) {
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ /*
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * pam_syslog() needs a pam handle,
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * but that's not available here.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ */
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ helper_log_err(LOG_ERR,
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "pam_unix(verify_pwd_hash): The method "
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "for computing the hash \"%.6s\" has been "
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "disabled in libcrypt by the preset from "
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "the system's vendor and/or administrator.",
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ hash);
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ /*
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * Check for malformed hashes, like descrypt hashes
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * starting with "$2...", which might have been
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * generated by unsafe base64 encoding functions
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * as used in glibc <= 2.16.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * Such hashes are likely to be rejected by many
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ * recent implementations of libcrypt.
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ */
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ if (retval_checksalt == CRYPT_SALT_INVALID) {
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ helper_log_err(LOG_ERR,
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "pam_unix(verify_pwd_hash): The hash \"%.6s\""
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "does not use a method known by the version "
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ "of libcrypt this system is supplied with.",
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ hash);
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
+#endif
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
#ifdef HAVE_CRYPT_R
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
struct crypt_data *cdata;
|
|
![](https://seccdn.libravatar.org/avatar/ca59ab3be600975ecf5ea3898e2a220c14d0d0cd3406201f156198b7f99be5a9?s=16&d=retro) |
f3b728d |
cdata = malloc(sizeof(*cdata));
|