From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4AD799D95A for ; Mon, 5 Jun 2023 16:22:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2FE6128AC1 for ; Mon, 5 Jun 2023 16:21:46 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 5 Jun 2023 16:21:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3D06F489DE for ; Mon, 5 Jun 2023 16:21:45 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Mon, 5 Jun 2023 16:21:36 +0200 Message-Id: <20230605142137.854891-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.073 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH access-control 1/2] roles: restrict Permissions.Modify to Administrator X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2023 14:22:16 -0000 to reduce the chances of accidentally handing out privilege modification privileges. the old default setup of having Permissions.Modify in PVESysAdmin and PVEAdmin weakened the distinction between those roles and Administrator. Signed-off-by: Fabian Grünbichler --- Notes: this is obviously a breaking change can be detected in pve7to8 if any ACLs with PVESysAdmin or PVEAdmin are configured, with a hint about adding a custom role if desired. src/PVE/AccessControl.pm | 5 +++-- src/test/perm-test1.pl | 4 ++++ src/test/perm-test8.pl | 4 ++-- src/test/test1.cfg | 2 ++ src/test/test8.cfg | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm index eee0869..9107653 100644 --- a/src/PVE/AccessControl.pm +++ b/src/PVE/AccessControl.pm @@ -1066,7 +1066,6 @@ my $privgroups = { 'Sys.Incoming', # incoming storage/guest migrations ], admin => [ - 'Permissions.Modify', 'Sys.Console', 'Sys.Syslog', ], @@ -1124,7 +1123,9 @@ my $privgroups = { }, }; -my $valid_privs = {}; +my $valid_privs = { + 'Permissions.Modify' => 1, # not contained in a group +}; my $special_roles = { 'NoAccess' => {}, # no privileges diff --git a/src/test/perm-test1.pl b/src/test/perm-test1.pl index d8527e7..d7cab3d 100755 --- a/src/test/perm-test1.pl +++ b/src/test/perm-test1.pl @@ -58,6 +58,10 @@ check_permission('max@pve', '/vms/100', 'VM.Audit,VM.PowerMgmt'); check_permission('alex@pve', '/vms', ''); check_permission('alex@pve', '/vms/100', 'VM.Audit,VM.PowerMgmt'); +# PVEVMAdmin -> no Permissions.Modify! +check_permission('alex@pve', '/vms/300', 'VM.Allocate,VM.Audit,VM.Backup,VM.Clone,VM.Config.CDROM,VM.Config.CPU,VM.Config.Cloudinit,VM.Config.Disk,VM.Config.HWType,VM.Config.Memory,VM.Config.Network,VM.Config.Options,VM.Console,VM.Migrate,VM.Monitor,VM.PowerMgmt,VM.Snapshot,VM.Snapshot.Rollback'); +# Administrator -> Permissions.Modify! +check_permission('alex@pve', '/vms/400', 'Datastore.Allocate,Datastore.AllocateSpace,Datastore.AllocateTemplate,Datastore.Audit,Group.Allocate,Permissions.Modify,Pool.Allocate,Pool.Audit,Realm.Allocate,Realm.AllocateUser,SDN.Allocate,SDN.Audit,Sys.Audit,Sys.Console,Sys.Incoming,Sys.Modify,Sys.PowerMgmt,Sys.Syslog,User.Modify,VM.Allocate,VM.Audit,VM.Backup,VM.Clone,VM.Config.CDROM,VM.Config.CPU,VM.Config.Cloudinit,VM.Config.Disk,VM.Config.HWType,VM.Config.Memory,VM.Config.Network,VM.Config.Options,VM.Console,VM.Migrate,VM.Monitor,VM.PowerMgmt,VM.Snapshot,VM.Snapshot.Rollback'); check_roles('max@pve', '/vms/200', 'storage_manager'); check_roles('joe@pve', '/vms/200', 'vm_admin'); diff --git a/src/test/perm-test8.pl b/src/test/perm-test8.pl index 980a990..21bf1d3 100644 --- a/src/test/perm-test8.pl +++ b/src/test/perm-test8.pl @@ -50,7 +50,7 @@ check_roles('max@pve', '/vms/100', 'customer'); check_roles('max@pve', '/vms/101', 'vm_admin'); check_permission('max@pve', '/', ''); -check_permission('max@pve', '/vms', 'Permissions.Modify,VM.Allocate,VM.Audit,VM.Console'); +check_permission('max@pve', '/vms', 'VM.Allocate,VM.Audit,VM.Console'); check_permission('max@pve', '/vms/100', 'VM.Audit,VM.PowerMgmt'); check_permission('alex@pve', '/vms', ''); @@ -66,7 +66,7 @@ check_roles('max@pve!token', '/vms/200', 'storage_manager'); check_roles('max@pve!token2', '/vms/200', 'customer'); # check intersection -> token has Administrator, but user only vm_admin -check_permission('max@pve!token2', '/vms/300', 'Permissions.Modify,VM.Allocate,VM.Audit,VM.Console,VM.PowerMgmt'); +check_permission('max@pve!token2', '/vms/300', 'VM.Allocate,VM.Audit,VM.Console,VM.PowerMgmt'); print "all tests passed\n"; diff --git a/src/test/test1.cfg b/src/test/test1.cfg index d27c5d6..0b1b587 100644 --- a/src/test/test1.cfg +++ b/src/test/test1.cfg @@ -19,4 +19,6 @@ acl:1:/users:max@pve:Administrator: acl:1:/vms/200:@testgroup3:storage_manager: acl:1:/vms/200:@testgroup2:NoAccess: +acl:1:/vms/300:alex@pve:PVEVMAdmin: +acl:1:/vms/400:alex@pve:Administrator: diff --git a/src/test/test8.cfg b/src/test/test8.cfg index d5c7e86..ce704ef 100644 --- a/src/test/test8.cfg +++ b/src/test/test8.cfg @@ -13,7 +13,7 @@ group:testgroup3:max@pve: role:storage_manager:Datastore.AllocateSpace,Datastore.Audit: role:customer:VM.Audit,VM.PowerMgmt: -role:vm_admin:VM.Audit,VM.Allocate,Permissions.Modify,VM.Console: +role:vm_admin:VM.Audit,VM.Allocate,VM.Console: acl:1:/vms:@testgroup1:vm_admin: acl:0:/vms/300:max@pve:customer: -- 2.39.2