From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 124A51FF09B for ; Mon, 31 Aug 2026 09:09:09 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 45028214FF; Mon, 31 Aug 2026 09:09:04 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 2/2] server: api: pve firewall: fix permission check Date: Mon, 31 Aug 2026 09:08:48 +0200 Message-ID: <20260831070855.568455-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260831070855.568455-1-d.csapak@proxmox.com> References: <20260831070855.568455-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.546 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: KZPIXRPM4HPBHRY62DNCTXW2COJCXN3B X-Message-ID-Hash: KZPIXRPM4HPBHRY62DNCTXW2COJCXN3B X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is the api call for the overall firewall status, not a specific remote, so there isn't a 'remote' parameter to limit us to. Instead, check the users permission against /resource/{resource} for each remote and only show those where the user has permission. This fixes a 403 error on the firewall panel for non root@pam users. Signed-off-by: Dominik Csapak --- server/src/api/pve/firewall.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/src/api/pve/firewall.rs b/server/src/api/pve/firewall.rs index 5a6a209e..ceddf205 100644 --- a/server/src/api/pve/firewall.rs +++ b/server/src/api/pve/firewall.rs @@ -1,8 +1,10 @@ use std::collections::HashMap; use std::sync::Arc; -use anyhow::Error; +use anyhow::{Context, Error}; +use proxmox_access_control::CachedUserInfo; +use proxmox_auth_api::types::Authid; use proxmox_router::{Permission, Router, RpcEnvironment, SubdirMap, list_subdirs_api_method}; use proxmox_schema::api; use proxmox_sortable_macro::sortable; @@ -242,16 +244,26 @@ async fn fetch_node_firewall_status( items: { type: RemoteFirewallStatus }, }, access: { - permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), + permission: &Permission::Anybody, + description: "A user needs `Resource.Audit` privileges on /resource/{remote}." }, )] /// Get firewall status of all PVE remotes. pub async fn pve_firewall_status( - _rpcenv: &mut dyn RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result, Error> { + let auth_id: Authid = rpcenv + .get_auth_id() + .context("no authid available")? + .parse()?; + let user_info = CachedUserInfo::new()?; + let pve_remotes: Vec = crate::api::remotes::RemoteIterator::new()? .remote_type(pdm_api_types::remotes::RemoteType::Pve) .into_remotes() + .filter(|remote| { + user_info.lookup_privs(&auth_id, &["resource", &remote.id]) & PRIV_RESOURCE_AUDIT != 0 + }) .collect(); if pve_remotes.is_empty() { -- 2.47.3