From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CAD9E1FF0C0 for ; Wed, 21 Oct 2026 13:38:28 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 731B62166E; Wed, 21 Oct 2026 13:38:15 +0200 (CEST) From: Shannon Sterz To: pve-devel@lists.proxmox.com Subject: [PATCH access-control v2 1/2] pam/pve: use yescrypt for new password hashes Date: Wed, 21 Oct 2026 13:38:07 +0200 Message-ID: <20261021113808.233146-2-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261021113808.233146-1-s.sterz@proxmox.com> References: <20261021113808.233146-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792582689675 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.734 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YQ2FFOUJ6M47CGLPSVWUP27TC4DN3BVX X-Message-ID-Hash: YQ2FFOUJ6M47CGLPSVWUP27TC4DN3BVX X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: and in the case of the pve realm, update old stored hashes on authentication. this should improve the security of passwords. yescrypt is the default in Debian since the Bullseye release [1]. [1]: Section 5.1.4, https://www.debian.org/releases/bullseye/amd64/release-notes.en.txt Signed-off-by: Shannon Sterz --- Notes: note that the change for pam also means that previously if a new password for a pam user was set via the PVE API, the hash function used for that password would effectively have been downgraded. src/PVE/Auth/PAM.pm | 2 +- src/PVE/Auth/PVE.pm | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PVE/Auth/PAM.pm b/src/PVE/Auth/PAM.pm index 8586da5..b67eb03 100755 --- a/src/PVE/Auth/PAM.pm +++ b/src/PVE/Auth/PAM.pm @@ -85,7 +85,7 @@ sub store_password { my $cmd = ['usermod']; - my $epw = PVE::Tools::encrypt_pw($password); + my $epw = PVE::Tools::encrypt_pw($password, 'y'); push @$cmd, '-p', $epw, $username; diff --git a/src/PVE/Auth/PVE.pm b/src/PVE/Auth/PVE.pm index ab439a8..cd0e5af 100755 --- a/src/PVE/Auth/PVE.pm +++ b/src/PVE/Auth/PVE.pm @@ -11,6 +11,7 @@ use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file use base qw(PVE::Auth::Plugin); my $shadowconfigfile = "priv/shadow.cfg"; +my $hash_prefix = "y"; cfs_register_file($shadowconfigfile, \&parse_shadow_passwd, \&write_shadow_config); @@ -81,6 +82,12 @@ sub authenticate_user { my $encpw = crypt(Encode::encode('utf8', $password), $shadow_cfg->{users}->{$username}->{shadow}); die "invalid credentials\n" if ($encpw ne $shadow_cfg->{users}->{$username}->{shadow}); + + # If the password was stored with a different hash function than the currently configured + # one, update it here. + if ($shadow_cfg->{users}->{$username}->{shadow} !~ m/^\$${hash_prefix}\$/) { + store_password($class, $config, $realm, $username, $password); + } } else { die "no password set\n"; } @@ -93,7 +100,7 @@ sub store_password { lock_shadow_config(sub { my $shadow_cfg = cfs_read_file($shadowconfigfile); - my $epw = PVE::Tools::encrypt_pw($password); + my $epw = PVE::Tools::encrypt_pw($password, $hash_prefix); $shadow_cfg->{users}->{$username}->{shadow} = $epw; cfs_write_file($shadowconfigfile, $shadow_cfg); }); -- 2.47.3