]> git.proxmox.com Git - pve-http-server.git/commitdiff
pass through streaming: only allow from privileged local pvedaemon
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 2 Jul 2022 05:59:50 +0000 (07:59 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 2 Jul 2022 05:59:53 +0000 (07:59 +0200)
Ensures that no external request can control streaming on proxying
requests as safety net for when we'd have another issue in the
request handling part.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/APIServer/AnyEvent.pm

index 8533c2f239db819d425b5fe462ab65f5d75be7af..dc12e7bd02139879ce444aa6924ec8c5ad7100a0 100644 (file)
@@ -710,10 +710,12 @@ sub proxy_request {
            return;
        }
 
            return;
        }
 
+       my $may_stream_file;
        if ($host eq 'localhost') {
            $target = "http://$host:85$uri";
            # keep alive for localhost is not worth (connection setup is about 0.2ms)
            $keep_alive = 0;
        if ($host eq 'localhost') {
            $target = "http://$host:85$uri";
            # keep alive for localhost is not worth (connection setup is about 0.2ms)
            $keep_alive = 0;
+           $may_stream_file = 1;
        } elsif (Net::IP::ip_is_ipv6($host)) {
            $target = "https://[$host]:8006$uri";
        } else {
        } elsif (Net::IP::ip_is_ipv6($host)) {
            $target = "https://[$host]:8006$uri";
        } else {
@@ -799,6 +801,10 @@ sub proxy_request {
                        $header->header(Location => $location);
                    }
                    if ($stream) {
                        $header->header(Location => $location);
                    }
                    if ($stream) {
+                       if (!$may_stream_file) {
+                           $self->error($reqstate, 403, 'streaming denied');
+                           return;
+                       }
                        sysopen(my $fh, "$stream", O_NONBLOCK | O_RDONLY)
                            or die "open stream path '$stream' for forwarding failed: $!\n";
                        my $resp = HTTP::Response->new($code, $msg, $header, undef);
                        sysopen(my $fh, "$stream", O_NONBLOCK | O_RDONLY)
                            or die "open stream path '$stream' for forwarding failed: $!\n";
                        my $resp = HTTP::Response->new($code, $msg, $header, undef);