From: Shannon Sterz <s.sterz@proxmox.com>
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 [thread overview]
Message-ID: <20261021113808.233146-2-s.sterz@proxmox.com> (raw)
In-Reply-To: <20261021113808.233146-1-s.sterz@proxmox.com>
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 <s.sterz@proxmox.com>
---
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
next prev parent reply other threads:[~2026-10-21 11:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 11:38 [PATCH access-control/docs v2 0/2] Update default password hash function to yescrypt Shannon Sterz
2026-10-21 11:38 ` Shannon Sterz [this message]
2026-10-21 11:38 ` [PATCH docs v2 2/2] pveum: document that the pve realm now uses yescrypt Shannon Sterz
2026-10-21 13:57 ` Maximiliano Sandoval
2026-10-21 14:04 ` [PATCH access-control/docs v2 0/2] Update default password hash function to yescrypt Maximiliano Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021113808.233146-2-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox