From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: "Max R. Carrara" <m.carrara@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] applied: [PATCH pmg-api master v1] pmgproxy: fix matching against potentially uninitialized value $ticket
Date: Mon, 22 Sep 2025 23:49:45 +0200 [thread overview]
Message-ID: <20250922234945.7ec48eed@rosa.proxmox.com> (raw)
In-Reply-To: <20250922133935.353421-1-m.carrara@proxmox.com>
Thanks for getting to this so quickly!
applied the patch after quickly verifying it works as advertised.
On Mon, 22 Sep 2025 15:39:17 +0200
"Max R. Carrara" <m.carrara@proxmox.com> wrote:
> `$ticket` here is undef if a non-empty `Cookie` header is included in
> the request, but `PMGAuthCookie` isn't actually set.
> `extract_auth_value()` returns undef, because the match fails.
>
> Therefore, check for definedness before matching on `$ticket`.
>
> Additional Context:
> Ran into this during testing; as it didn't appear for all VMs, I
> figured that some of the VMs' IP addresses belonged to other VMs
> previously. After digging a little in the Firefox dev tools, it turned
> out that `PVEAuthCookie` is actually sent as well, confirming my
> suspicion.
>
> Can easily be reproduced via:
> `curl -k -H 'Cookie: Foo=bar' https://$HOSTNAME:8006/`
>
> Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
> ---
> src/PMG/Service/pmgproxy.pm | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/PMG/Service/pmgproxy.pm b/src/PMG/Service/pmgproxy.pm
> index c92a3f3..de7a6c5 100644
> --- a/src/PMG/Service/pmgproxy.pm
> +++ b/src/PMG/Service/pmgproxy.pm
> @@ -226,10 +226,12 @@ sub get_index {
>
> my $ticket = PVE::APIServer::Formatter::extract_auth_value($cookie, $server->{cookie_name});
>
> - if ($ticket =~ m/^PMGQUAR:/) {
> - $username = PMG::Ticket::verify_quarantine_ticket($ticket, 1);
> - } else {
> - $username = PMG::Ticket::verify_ticket($ticket, undef, 1);
> + if (defined($ticket)) {
> + if ($ticket =~ m/^PMGQUAR:/) {
> + $username = PMG::Ticket::verify_quarantine_ticket($ticket, 1);
> + } else {
> + $username = PMG::Ticket::verify_ticket($ticket, undef, 1);
> + }
> }
> } else {
> if (defined($args->{ticket})) {
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
prev parent reply other threads:[~2025-09-22 21:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 13:39 [pmg-devel] " Max R. Carrara
2025-09-22 21:49 ` Stoiko Ivanov [this message]
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=20250922234945.7ec48eed@rosa.proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=m.carrara@proxmox.com \
--cc=pmg-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