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.
This commit is contained in:
gbrodman
2026-07-24 15:11:06 +00:00
committed by GitHub
parent 9c4a558d7b
commit 0b8025d3db
2 changed files with 22 additions and 7 deletions
@@ -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");
}
}
@@ -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(