From 0b8025d3dbf8b4d31bc2716b4c5dd4934e56cbb8 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Fri, 24 Jul 2026 11:11:06 -0400 Subject: [PATCH] Disallow adding ADMIN contacts via console (#3160) this is a potential security issue if we give users who only have EDIT_REGISTRAR_DETAILS access to become admin PoCs, which can have a different set of permissions. --- .../console/settings/ContactAction.java | 8 ++++--- .../console/settings/ContactActionTest.java | 21 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/google/registry/ui/server/console/settings/ContactAction.java b/core/src/main/java/google/registry/ui/server/console/settings/ContactAction.java index 8fd4d9095..53e1b5d0d 100644 --- a/core/src/main/java/google/registry/ui/server/console/settings/ContactAction.java +++ b/core/src/main/java/google/registry/ui/server/console/settings/ContactAction.java @@ -255,9 +255,11 @@ public class ContactAction extends ConsoleApiAction { newContactsByType.get(Type.ADMIN).stream() .map(RegistrarPoc::getEmailAddress) .collect(toImmutableSet()); - if (!newAdminEmails.containsAll(oldAdminEmails)) { - throw new ContactRequirementException( - "Cannot remove or change the email address of primary contacts"); + // ADMIN (primary) PoC emails are used for EPP password resets and potentially other + // security-sensitive tasks. A user with only EDIT_REGISTRAR_DETAILS should not be able to + // change this. + if (!newAdminEmails.equals(oldAdminEmails)) { + throw new ContactRequirementException("Cannot alter the set of primary contacts"); } } diff --git a/core/src/test/java/google/registry/ui/server/console/settings/ContactActionTest.java b/core/src/test/java/google/registry/ui/server/console/settings/ContactActionTest.java index 169d36b5d..1eebc4c0c 100644 --- a/core/src/test/java/google/registry/ui/server/console/settings/ContactActionTest.java +++ b/core/src/test/java/google/registry/ui/server/console/settings/ContactActionTest.java @@ -343,10 +343,23 @@ visibleInRdapAsTech=true, visibleInDomainRdapAsAbuse=false} testRegistrar.getRegistrarId(), adminPoc.asBuilder().setEmailAddress("testemail@example.com").build()); action.run(); - FakeResponse fakeResponse = response; - assertThat(fakeResponse.getStatus()).isEqualTo(400); - assertThat(fakeResponse.getPayload()) - .isEqualTo("Cannot remove or change the email address of primary contacts"); + assertThat(response.getStatus()).isEqualTo(SC_BAD_REQUEST); + assertThat(response.getPayload()).isEqualTo("Cannot alter the set of primary contacts"); + } + + @Test + void testFailure_addsAdminEmail() throws Exception { + RegistrarPoc newAdminPoc = + adminPoc + .asBuilder() + .setName("New Admin Contact") + .setEmailAddress("new.admin@example.com") + .build(); + ContactAction action = + createAction(Action.Method.POST, fteUser, testRegistrar.getRegistrarId(), newAdminPoc); + action.run(); + assertThat(response.getStatus()).isEqualTo(SC_BAD_REQUEST); + assertThat(response.getPayload()).isEqualTo("Cannot alter the set of primary contacts"); } private ContactAction createAction(