From 4e300e071b97e1e3a6ba4d856cc65e5386366f6f Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 10 Mar 2023 19:25:45 +0100 Subject: [PATCH] libxcrypt: Build only with strong hashes Effectively removes support for the following hashing algorithms as announced in the NixOS 22.11 release notes: - bcrypt_x ($2x$) - sha256crypt ($5$) - sha1crypt ($sha1$) - sunmd5 ($md5$) - md5crypt ($1$) - nt ($3$) - bdiscrypt (_) - bigcrypt (:) - descrypt (:) And exposes the crypt scheme ids for enabled algorithms, so they can be reused for validation in the users-groups module. --- .../manual/release-notes/rl-2305.section.md | 2 ++ .../libraries/libxcrypt/default.nix | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 1bd8906cf64f..affa11f3b9a7 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -18,6 +18,8 @@ In addition to numerous new and upgraded packages, this release has the followin - `nixos-rebuild` now supports an extra `--specialisation` option that can be used to change specialisation for `switch` and `test` commands. +- `libxcrypt`, the library providing the `crypt(3)` password hashing function, is now built without support for algorithms not flagged [`strong`](https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf#L48). This affects the availability of password hashing algorithms used for system login (`login(1)`, `passwd(1)`), but also Apache2 Basic-Auth, Samba, OpenLDAP, and [many other packages](https://github.com/search?q=repo%3ANixOS%2Fnixpkgs%20libxcrypt&type=code). + ## New Services {#sec-release-23.05-new-services} diff --git a/pkgs/development/libraries/libxcrypt/default.nix b/pkgs/development/libraries/libxcrypt/default.nix index 86bb12ee3d1f..769994a5cdfd 100644 --- a/pkgs/development/libraries/libxcrypt/default.nix +++ b/pkgs/development/libraries/libxcrypt/default.nix @@ -15,7 +15,8 @@ stdenv.mkDerivation rec { ]; configureFlags = [ - "--enable-hashes=all" + # Update the enabled crypt scheme ids in passthru when the enabled hashes change + "--enable-hashes=strong" "--enable-obsolete-api=glibc" "--disable-failure-tokens" ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [ @@ -30,8 +31,20 @@ stdenv.mkDerivation rec { doCheck = true; - passthru.tests = { - inherit (nixosTests) login shadow; + passthru = { + tests = { + inherit (nixosTests) login shadow; + }; + enabledCryptSchemeIds = [ + # https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf + "y" # yescrypt + "gy" # gost_yescrypt + "7" # scrypt + "2b" # bcrypt + "2y" # bcrypt_y + "2a" # bcrypt_a + "6" # sha512crypt + ]; }; meta = with lib; {