public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH docs/pmg-api v2 0/2] Update default password hash function to yescrypt
@ 2026-10-23  9:40 Shannon Sterz
  2026-10-23  9:40 ` [PATCH pmg-api v2 1/2] pam/pmg realm: use yescrypt for new password hashes Shannon Sterz
  2026-10-23  9:40 ` [PATCH docs v2 2/2] pmgconfig: document that the pmg realm now uses yescrypt Shannon Sterz
  0 siblings, 2 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-10-23  9:40 UTC (permalink / raw)
  To: pmg-devel

Also updates the password hash when a user logs in.

Changelog
---------

* v1: https://lore.proxmox.com/pmg-devel/20261021113704.232095-2-s.sterz@proxmox.com/

- changes since v1 (thanks @ Maximiliano Sandoval):
    + adjusted the commit message of the first patch to clarify why yescrypt
      should be used
    + updated documentation to use the proper `{pmg}` shorthand


api:

Shannon Sterz (1):
  pam/pmg realm: use yescrypt for new password hashes

 src/PMG/API2/Users.pm    | 2 +-
 src/PMG/AccessControl.pm | 2 +-
 src/PMG/UserConfig.pm    | 9 ++++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)


docs:

Shannon Sterz (1):
  pmgconfig: document that the pmg realm now uses yescrypt

 pmgconfig.adoc | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)


Summary over all repositories:
  4 files changed, 22 insertions(+), 8 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH pmg-api v2 1/2] pam/pmg realm: use yescrypt for new password hashes
  2026-10-23  9:40 [PATCH docs/pmg-api v2 0/2] Update default password hash function to yescrypt Shannon Sterz
@ 2026-10-23  9:40 ` Shannon Sterz
  2026-10-23  9:40 ` [PATCH docs v2 2/2] pmgconfig: document that the pmg realm now uses yescrypt Shannon Sterz
  1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-10-23  9:40 UTC (permalink / raw)
  To: pmg-devel

and in the case of the pmg 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].

according to `man 5 crypt`:

> The default processing cost parameter is 5000, which is too low for
> modern hardware.

since the default of 5000 was never modified, the previous usage of
the hash function can be considered insecure.

[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/PMG/API2/Users.pm    | 2 +-
 src/PMG/AccessControl.pm | 2 +-
 src/PMG/UserConfig.pm    | 9 ++++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/PMG/API2/Users.pm b/src/PMG/API2/Users.pm
index e638ae8..a973653 100644
--- a/src/PMG/API2/Users.pm
+++ b/src/PMG/API2/Users.pm
@@ -118,7 +118,7 @@ __PACKAGE__->register_method({
             foreach my $k (keys %$param) {
                 my $v = $param->{$k};
                 if ($k eq 'password') {
-                    $entry->{crypt_pass} = PVE::Tools::encrypt_pw($v);
+                    $entry->{crypt_pass} = PVE::Tools::encrypt_pw($v, "y");
                 } else {
                     $entry->{$k} = $v;
                 }
diff --git a/src/PMG/AccessControl.pm b/src/PMG/AccessControl.pm
index f4ac743..6fa89de 100644
--- a/src/PMG/AccessControl.pm
+++ b/src/PMG/AccessControl.pm
@@ -103,7 +103,7 @@ sub set_user_password {
 
         my $cmd = ['usermod'];
 
-        my $epw = PVE::Tools::encrypt_pw($password);
+        my $epw = PVE::Tools::encrypt_pw($password, "y");
 
         push @$cmd, '-p', $epw, $ruid;
 
diff --git a/src/PMG/UserConfig.pm b/src/PMG/UserConfig.pm
index 5ee7333..b2ef417 100644
--- a/src/PMG/UserConfig.pm
+++ b/src/PMG/UserConfig.pm
@@ -19,6 +19,7 @@ my $config_filename = '/etc/pmg/user.conf';
 
 my $tfa_inotify_file_id = 'pmg-tfa.json';
 my $tfa_config_filename = '/etc/pmg/tfa.json';
+my $hash_prefix = "y";
 
 sub new {
     my ($type) = @_;
@@ -351,6 +352,12 @@ sub authenticate_user {
     if ($data->{crypt_pass}) {
         my $encpw = crypt($password, $data->{crypt_pass});
         die "invalid credentials\n" if ($encpw ne $data->{crypt_pass});
+
+        # If the password was stored with a different hash function than the currently configured
+        # one, update it here.
+        if ($data->{crypt_pass} !~ m/^\$${hash_prefix}\$/) {
+            store_password($class, $config, $realm, $username, $password);
+        }
     } else {
         die "no password set\n";
     }
@@ -364,7 +371,7 @@ sub set_user_password {
     lock_config(sub {
         my $cfg = $class->new();
         my $data = $cfg->lookup_user_data($username); # user exists
-        my $epw = PVE::Tools::encrypt_pw($password);
+        my $epw = PVE::Tools::encrypt_pw($password, $hash_prefix);
         $data->{crypt_pass} = $epw;
         $cfg->write();
     });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH docs v2 2/2] pmgconfig: document that the pmg realm now uses yescrypt
  2026-10-23  9:40 [PATCH docs/pmg-api v2 0/2] Update default password hash function to yescrypt Shannon Sterz
  2026-10-23  9:40 ` [PATCH pmg-api v2 1/2] pam/pmg realm: use yescrypt for new password hashes Shannon Sterz
@ 2026-10-23  9:40 ` Shannon Sterz
  1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-10-23  9:40 UTC (permalink / raw)
  To: pmg-devel

and document that passwords will be upgraded on login.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 pmgconfig.adoc | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/pmgconfig.adoc b/pmgconfig.adoc
index 00a988e..0eab138 100644
--- a/pmgconfig.adoc
+++ b/pmgconfig.adoc
@@ -1271,11 +1271,18 @@ created on the host system with commands such as `adduser`.
 {pmg} Authentication Server::
 
 This is a Unix-like password store, which stores hashed passwords directly in
-`/etc/pmg/user.conf`. Passwords are hashed using the SHA-256 hashing
-algorithm. This is the most convenient realm for small-scale (or even
-mid-scale) installations, where users do not need access to anything outside of
-{pmg}. In this case, users are fully managed by {pmg} and are able to change
-their own passwords via the GUI.
+`/etc/pmg/user.conf`. Passwords are hashed and salted using the yescrypt
+algorithm footnote:[yescrypt https://www.openwall.com/yescrypt/]. It provides
+strong protections against offline password cracking attempts. This is the most
+convenient realm for small-scale (or even mid-scale) installations, where users
+do not need access to anything outside of {pmg}. In this case, users are fully
+managed by {pmg} and are able to change their own passwords via the GUI.
+
+NOTE: Passwords created with older versions of {pmg} used a hashing scheme based
+on SHA-256 that is now considered insecure. If the file `/etc/pmg/user.cfg`
+shows a password hash starting with `$5$` for an account, that account still
+uses such a password. The hash will be updated on the next login of that user or
+when a new password is set.
 
 OpenID Connect::
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-23  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23  9:40 [PATCH docs/pmg-api v2 0/2] Update default password hash function to yescrypt Shannon Sterz
2026-10-23  9:40 ` [PATCH pmg-api v2 1/2] pam/pmg realm: use yescrypt for new password hashes Shannon Sterz
2026-10-23  9:40 ` [PATCH docs v2 2/2] pmgconfig: document that the pmg realm now uses yescrypt Shannon Sterz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal