From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 2737E1FF15C for ; Fri, 28 Nov 2025 16:15:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 197B11DDA7; Fri, 28 Nov 2025 16:16:09 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Fri, 28 Nov 2025 16:15:50 +0100 Message-ID: <20251128151550.369432-1-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764342926297 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.120 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH datacenter-manager] api: remote tasks: add fine-grained permission check on the remote level X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Adds a check for the remote task APIs that requires a user to have Resource.Audit on /resource/{remote}. Could make sense to a.) verify permissions on the node-level (we do so in PVE) and b.) allow a user to see their own tasks. But we can do that later as well, more important for now is getting rid of the bare Permission::Anybody. Signed-off-by: Lukas Wagner --- server/src/api/remote_tasks.rs | 32 ++++++++++++++++++++++++++------ server/src/remote_tasks/mod.rs | 5 +++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/server/src/api/remote_tasks.rs b/server/src/api/remote_tasks.rs index 02b6383b..1dff4bd6 100644 --- a/server/src/api/remote_tasks.rs +++ b/server/src/api/remote_tasks.rs @@ -27,10 +27,9 @@ const SUBDIRS: SubdirMap = &sorted!([ ]); #[api( - // FIXME:: see list-like API calls in resource routers, we probably want more fine-grained - // checks.. access: { permission: &Permission::Anybody, + description: "Resource.Audit privileges on /resource/{remote} are needed to list tasks from a given remote." }, input: { properties: { @@ -64,16 +63,26 @@ async fn list_tasks( user_info.check_privs(&auth_id, &["view", view], PRIV_RESOURCE_AUDIT, false)?; } - let tasks = remote_tasks::get_tasks(filters, remote, view).await?; + let check_privs = move |remote_name: &str| { + user_info + .check_privs( + &auth_id, + &["resource", remote_name], + PRIV_RESOURCE_AUDIT, + false, + ) + .is_ok() + }; + + let tasks = remote_tasks::get_tasks(filters, remote, check_privs, view).await?; Ok(tasks) } #[api( - // FIXME:: see list-like API calls in resource routers, we probably want more fine-grained - // checks.. access: { permission: &Permission::Anybody, + description: "Resource.Audit privileges on /resource/{remote} are needed to list tasks from a given remote." }, input: { properties: { @@ -106,7 +115,18 @@ async fn task_statistics( user_info.check_privs(&auth_id, &["view", view], PRIV_RESOURCE_AUDIT, false)?; } - let tasks = remote_tasks::get_tasks(filters, remote, view).await?; + let check_privs = move |remote_name: &str| { + user_info + .check_privs( + &auth_id, + &["resource", remote_name], + PRIV_RESOURCE_AUDIT, + false, + ) + .is_ok() + }; + + let tasks = remote_tasks::get_tasks(filters, remote, check_privs, view).await?; let mut by_type: HashMap = HashMap::new(); let mut by_remote: HashMap = HashMap::new(); diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs index ea3c5539..b080811f 100644 --- a/server/src/remote_tasks/mod.rs +++ b/server/src/remote_tasks/mod.rs @@ -31,6 +31,7 @@ const NUMBER_OF_UNCOMPRESSED_FILES: u32 = 2; pub async fn get_tasks( filters: TaskFilters, remote_filter: Option, + check_privs: impl Fn(&str) -> bool + Send + 'static, view: Option, ) -> Result, Error> { let view = views::get_optional_view(view.as_deref())?; @@ -64,6 +65,8 @@ pub async fn get_tasks( if !view.is_node_included(task.upid.remote(), &pve_upid.node) { return None; } + } else if !check_privs(task.upid.remote()) { + return None; } Some(TaskListItem { upid: task.upid.to_string(), @@ -83,6 +86,8 @@ pub async fn get_tasks( if !view.is_node_included(task.upid.remote(), &pbs_upid.node) { return None; } + } else if !check_privs(task.upid.remote()) { + return None; } Some(TaskListItem { upid: task.upid.to_string(), -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel