mirror of
https://github.com/google/nomulus
synced 2026-07-26 18:12:38 +00:00
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:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-4
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user