From 8e23699987a6d356d0cb57be2daf599636417e80 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 2 Oct 2026 22:04:05 +0300 Subject: [PATCH] fix(instances): show console settings and the VNC password only to console managers The console settings form on the VM detail page renders the VNC password (PasswordInput(render_value=True)) and was shown to every is_staff user. A staff user with the global view_instances permission, or a staff owner without is_vnc, could read the VNC password of every VM they could see. Add instances.utils.can_manage_console (active superuser, or an active owner with is_change and is_vnc), which matches what update_console already enforced. The detail view only builds the form, and so only puts the password into the page, when it returns True; the template and update_console use the same rule. --- .../templates/instances/settings_tab.html | 4 +- instances/test_console_settings_access.py | 87 +++++++++++++++++++ instances/utils.py | 15 ++++ instances/views.py | 27 +++--- 4 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 instances/test_console_settings_access.py diff --git a/instances/templates/instances/settings_tab.html b/instances/templates/instances/settings_tab.html index 74ae23ed..183aecbf 100644 --- a/instances/templates/instances/settings_tab.html +++ b/instances/templates/instances/settings_tab.html @@ -23,7 +23,7 @@ {% endif %} - {% if request.user.is_superuser or request.user.is_staff or userinstance.is_vnc %} + {% if can_manage_console %}