From 17e0b01b7fcf1ee6070cb05b81bcdcf939147fed Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 19 Feb 2024 17:13:41 +0100 Subject: [PATCH] fix #5254: api: allow usage of download-url with Sys.AccessNetwork MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The download-url API endpoint has some implications that admins are unaware of, namely that it basically allow to scan the whole network via HTTP URLs, and potentially even download some image that the user should not have access to and adding to a VM that the user controls. That's why in addition to the Datastore.AllocateTemplate privilege on the storage, the Sys.Modify on the whole Cluster was required to use the API call. That design was chosen as we were not fully sure if a separate privilege is warranted, but user feedback has shown that the (not so big) cost of adding such a new privilege is justified. Change the permission check to allow the combination of Datastore.AllocateTemplate on the storage and either 'Sys.Modify' on /, for backwards compatibility, or the newer 'Sys.AccessNetwork' on the node that handles the download. Using a node-specific ACL path allows admins to e.g. prepare one specific node's firewall so that pveproxy can access only a safe set of hosts via outgoing HTTP (not stemming from valid connection tracking to the PVE API), and thus even further limit the privileges of users or tools that are trusted to download images to a storage. Buglink: https://bugzilla.proxmox.com/show_bug.cgi?id=5254 Signed-off-by: Thomas Lamprecht Tested-by: Hannes Duerr Reviewed-by: Fabian Grünbichler --- src/PVE/API2/Storage/Status.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index b2336e6..bc67b81 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -546,9 +546,15 @@ __PACKAGE__->register_method({ description => "Download templates and ISO images by using an URL.", proxyto => 'node', permissions => { + description => 'Requires allocation access on the storage and as this allows one to probe' + .' the (local!) host network indirectly it also requires one of Sys.Modify on / (for' + .' backwards compatibility) or the newer Sys.AccessNetwork privilege on the node.', check => [ 'and', ['perm', '/storage/{storage}', [ 'Datastore.AllocateTemplate' ]], - ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + [ 'or', + ['perm', '/', [ 'Sys.Audit', 'Sys.Modify' ]], + ['perm', '/nodes/{node}', [ 'Sys.AccessNetwork' ]], + ], ], }, protected => 1,