all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH access-control v2 0/1] tickets: sign with the hash from datacenter.cfg
@ 2026-11-13  3:06 Mark Atwood
  2026-11-13  3:06 ` [PATCH access-control v2 1/1] tickets: sign with the hash from the datacenter configuration Mark Atwood
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Atwood @ 2026-11-13  3:06 UTC (permalink / raw)
  To: pve-devel

Create login, TFA, VNC and tunnel tickets with the hash that the new
'ticket-signature-hash' option of datacenter.cfg selects. Without the option
tickets are signed with SHA-1 as before.

This is the pve-access-control part of the v2 of "ticket: sign RSA tickets
with SHA-256". The pve-common part also affects Proxmox Mail Gateway, which
uses PVE::Ticket; this patch is PVE only.

Apply order across the repositories, all three are part of this series:
1. pve-common (2 patches)
2. pve-cluster (adds the datacenter.cfg option)
3. pve-access-control (reads the option and signs with it)
pve-common and pve-cluster are independent of each other. pve-access-control
needs both, but is harmless without them: it then keeps signing with SHA-1.

d/control: I did not bump the versioned dependencies, as the version numbers
depend on the release that contains the pve-common and pve-cluster changes.
They need to be bumped when applying.

Mixed clusters: nodes without pve-common 1/2 reject SHA-256 tickets, so the
option must only be set to 'sha256' once every node has that patch. The option
description says so. I did not add an automatic check against the node
versions (the new helpers in pve-cluster, 679cf2c, would allow one), as it
needs the release number that will contain 1/2. Happy to add one in
pve-manager's datacenter options update once that number is known.

Changes since v1: the pve-access-control part is new in v2. The separate CSRF
patch from v1 was applied already (07bb3b1) and is not part of this series.
Shannon asked for opt-in, so tickets are signed with the hash from the
datacenter configuration, which defaults to SHA-1. All other v1 review points
are in the pve-common cover letter.

v1: <CALkZksWBSdQa5AsvhmANGAJigcZ7FHPtgRgdu3JsRt9NX6vwSg@mail.gmail.com>
This is sent as a new thread, as is usual for a new version of a series.

Thanks to Shannon Sterz for the review of v1.

Mark Atwood (1):
  tickets: sign with the hash from the datacenter configuration

 src/PVE/AccessControl.pm               |  23 +++++-
 src/test/Makefile                      |   1 +
 src/test/ticket-signature-hash-test.pl | 100 +++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 2 deletions(-)
 create mode 100644 src/test/ticket-signature-hash-test.pl


base-commit: bbc4ed63427249f98c86efd64054dabcca77bd9d



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

* [PATCH access-control v2 1/1] tickets: sign with the hash from the datacenter configuration
  2026-11-13  3:06 [PATCH access-control v2 0/1] tickets: sign with the hash from datacenter.cfg Mark Atwood
@ 2026-11-13  3:06 ` Mark Atwood
  2026-11-17 16:05   ` Shannon Sterz
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Atwood @ 2026-11-13  3:06 UTC (permalink / raw)
  To: pve-devel

Read the new 'ticket-signature-hash' option of datacenter.cfg and pass
it to PVE::Ticket::assemble_rsa_ticket() for all tickets that are
signed here: login and TFA tickets, as well as the short-lived VNC and
tunnel tickets. Without the option, tickets are signed with SHA-1 as
before.

This lets setups where SHA-1 signatures are not acceptable, like
running in FIPS mode, create tickets. It depends on the option in
pve-cluster and on the changes to PVE::Ticket in pve-common, which
should be applied first. With older versions of those, the option is
not set and the parameter is ignored, so tickets are still signed with
SHA-1.

Tickets that nodes verify are accepted with either hash, as long as
those nodes have the PVE::Ticket changes. Tunnel tickets are verified
on the target node, so the option must only be set to 'sha256' once all
nodes of the cluster have them. The datacenter configuration is the
same on all nodes, so the same hash is used on all of them.

The tests check the hash of the signature for each kind of ticket and
that tickets of both hashes verify with either setting.

Signed-off-by: Mark Atwood <mark@wolfssl.com>
---
 src/PVE/AccessControl.pm               |  23 +++++-
 src/test/Makefile                      |   1 +
 src/test/ticket-signature-hash-test.pl | 100 +++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 2 deletions(-)
 create mode 100644 src/test/ticket-signature-hash-test.pl

diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index a4e1c36..fceea56 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -377,12 +377,25 @@ my $get_ticket_age_range = sub {
     return ($min, $max);
 };
 
+# The hash algorithm for the signature of newly created tickets, as configured cluster-wide.
+my sub get_ticket_signature_hash {
+    my $dc_conf = cfs_read_file('datacenter.cfg');
+
+    return $dc_conf->{'ticket-signature-hash'} // 'sha1';
+}
+
 sub assemble_ticket : prototype($;$) {
     my ($data, $aad) = @_;
 
     my $rsa_priv = get_privkey();
 
-    return PVE::Ticket::assemble_rsa_ticket($rsa_priv, 'PVE', $data, $aad);
+    return PVE::Ticket::assemble_rsa_ticket(
+        $rsa_priv,
+        'PVE',
+        $data,
+        $aad,
+        get_ticket_signature_hash(),
+    );
 }
 
 # Returns the username, "age" and tfa info.
@@ -516,7 +529,13 @@ my $assemble_short_lived_ticket = sub {
     my $secret_data = "$username:$path";
     $secret_data .= ":$additional_secret" if defined($additional_secret);
 
-    return PVE::Ticket::assemble_rsa_ticket($rsa_priv, $prefix, undef, $secret_data);
+    return PVE::Ticket::assemble_rsa_ticket(
+        $rsa_priv,
+        $prefix,
+        undef,
+        $secret_data,
+        get_ticket_signature_hash(),
+    );
 };
 
 my $verify_short_lived_ticket = sub {
diff --git a/src/test/Makefile b/src/test/Makefile
index 8f3ba47..ac8c6cc 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -22,4 +22,5 @@ check:
 	perl -I.. api-tests.pl
 	perl -I.. sdn_acl_pruning_test.pl
 	perl -I.. sdn_acl_migration_test.pl
+	perl -I.. ticket-signature-hash-test.pl
 
diff --git a/src/test/ticket-signature-hash-test.pl b/src/test/ticket-signature-hash-test.pl
new file mode 100644
index 0000000..2e4d05b
--- /dev/null
+++ b/src/test/ticket-signature-hash-test.pl
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+
+use v5.36;
+
+use lib qw(..);
+
+use Crypt::OpenSSL::RSA;
+use MIME::Base64;
+use Test::MockModule;
+use Test::More;
+
+use PVE::AccessControl;
+
+# Tickets are signed with the hash from the 'ticket-signature-hash' datacenter option, which
+# defaults to SHA-1. Whether a signature is SHA-1 or SHA-256 is checked by verifying it with a
+# public key where only that hash is accepted.
+
+my $rsa_priv = Crypt::OpenSSL::RSA->generate_key(2048);
+my $pub_pem = $rsa_priv->get_public_key_string();
+
+my $datacenter_conf = {};
+
+my $access_control_module = Test::MockModule->new('PVE::AccessControl');
+$access_control_module->mock(
+    get_privkey => sub { return $rsa_priv },
+    get_pubkey => sub { return (Crypt::OpenSSL::RSA->new_public_key($pub_pem), time()) },
+    cfs_read_file => sub($file) {
+        die "unexpected cfs_read_file('$file') call\n" if $file ne 'datacenter.cfg';
+        return $datacenter_conf;
+    },
+);
+
+my sub signed_with($ticket, $hash, $secret_data) {
+    my $pub = Crypt::OpenSSL::RSA->new_public_key($pub_pem);
+    $hash eq 'sha256' ? $pub->use_sha256_hash() : $pub->use_sha1_hash();
+    my ($plain, $sig) = $ticket =~ m/^(.+)::([^:]+)$/ or die "unexpected ticket '$ticket'\n";
+    my $full = defined($secret_data) ? "$plain:$secret_data" : $plain;
+    return $pub->verify($full, decode_base64($sig)) ? 1 : 0;
+}
+
+# name, assemble function and the secret data that is signed along but not part of the ticket
+my @tickets = (
+    ['login ticket', sub { PVE::AccessControl::assemble_ticket('root@pam') }, undef],
+    [
+        'TFA ticket',
+        sub { PVE::AccessControl::assemble_ticket('root@pam', 'tfa-aad') },
+        'tfa-aad',
+    ],
+    [
+        'VNC ticket',
+        sub { PVE::AccessControl::assemble_vnc_ticket('root@pam', '/vms/100', 5900) },
+        'root@pam:/vms/100:5900',
+    ],
+    [
+        'tunnel ticket',
+        sub { PVE::AccessControl::assemble_tunnel_ticket('root@pam', '/vms/100') },
+        'root@pam:/vms/100',
+    ],
+);
+
+my @options = (
+    ['unset', {}, 'sha1'],
+    ['sha1', { 'ticket-signature-hash' => 'sha1' }, 'sha1'],
+    ['sha256', { 'ticket-signature-hash' => 'sha256' }, 'sha256'],
+);
+
+for my $option (@options) {
+    my ($name, $conf, $expected) = @$option;
+    my $other = $expected eq 'sha1' ? 'sha256' : 'sha1';
+    $datacenter_conf = $conf;
+
+    for my $ticket_type (@tickets) {
+        my ($type, $assemble, $secret) = @$ticket_type;
+        my $ticket = $assemble->();
+        is(
+            signed_with($ticket, $expected, $secret),
+            1,
+            "$type is signed with $expected if option is $name",
+        );
+        is(
+            signed_with($ticket, $other, $secret),
+            0,
+            "$type is not signed with $other if option is $name",
+        );
+    }
+}
+
+# tickets of either hash have to be accepted, independent of the option
+for my $option (@options) {
+    my ($name, $conf) = @$option;
+    $datacenter_conf = $conf;
+    my $ticket = PVE::AccessControl::assemble_ticket('root@pam');
+    for my $verify_conf (@options) {
+        $datacenter_conf = $verify_conf->[1];
+        my ($user) = PVE::AccessControl::verify_ticket($ticket, 1);
+        is($user, 'root@pam', "ticket created with option $name is valid with $verify_conf->[0]");
+    }
+}
+
+done_testing();



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

* Re: [PATCH access-control v2 1/1] tickets: sign with the hash from the datacenter configuration
  2026-11-13  3:06 ` [PATCH access-control v2 1/1] tickets: sign with the hash from the datacenter configuration Mark Atwood
@ 2026-11-17 16:05   ` Shannon Sterz
  0 siblings, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2026-11-17 16:05 UTC (permalink / raw)
  To: Mark Atwood, pve-devel

On Fri Nov 13, 2026 at 4:06 AM CET, Mark Atwood wrote:
> Read the new 'ticket-signature-hash' option of datacenter.cfg and pass
> it to PVE::Ticket::assemble_rsa_ticket() for all tickets that are
> signed here: login and TFA tickets, as well as the short-lived VNC and
> tunnel tickets. Without the option, tickets are signed with SHA-1 as
> before.
>
> This lets setups where SHA-1 signatures are not acceptable, like
> running in FIPS mode, create tickets. It depends on the option in
> pve-cluster and on the changes to PVE::Ticket in pve-common, which
> should be applied first. With older versions of those, the option is
> not set and the parameter is ignored, so tickets are still signed with
> SHA-1.

nit: typically we don't handle apply order of patches in the commit
message itself, as once it is applied is too late for that information
to be useful. rather add it in the notes section (below `---`).

also sadly this does not apply anymore.

-->8 snip 8<--




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

end of thread, other threads:[~2026-11-17 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  3:06 [PATCH access-control v2 0/1] tickets: sign with the hash from datacenter.cfg Mark Atwood
2026-11-13  3:06 ` [PATCH access-control v2 1/1] tickets: sign with the hash from the datacenter configuration Mark Atwood
2026-11-17 16:05   ` Shannon Sterz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal