Repository navigation
Conversation
| // Admin requests execute EPP with isSuperuser=true, which bypasses EPP's own | ||
| // verifyResourceOwnership check. Load active domains up front so we always enforce that | ||
| // each target domain is sponsored by the request's registrarId. |
There was a problem hiding this comment.
Cross-PR conflict & semantic drift with #3278:
- Both PRs modify these same lines in
ConsoleBulkDomainActionandConsoleBulkDomainActionTest. Make sure Enforce registrar ownership in bulk domain action #3287 merges before Fix Console bulk domain suspend and history #3278—Fix Console bulk domain suspend and history #3278 changesisSuperusertoactionType.runAsSuperuser()(trueforSUSPENDandUNSUSPENDfor non-adminFTEandSUPPORT_LEADusers as well), which would otherwise widen this cross-registrar vulnerability. - Once Fix Console bulk domain suspend and history #3278 lands/rebases,
DELETEnever runs as superuser whileSUSPEND/UNSUSPENDrun as superuser for all permitted users (actionType.runAsSuperuser()), andexecuteEpptakes(String xml, boolean isSuperuser). Update this comment accordingly and add a non-adminFTE/SUPPORT_LEADcross-registrarSUSPEND/UNSUSPENDtest.
| ImmutableMap<String, ConsoleEppOutput> result = | ||
| domainList.domainList.stream() | ||
| .collect( | ||
| toImmutableMap(d -> d, d -> executeEpp(actionType.getXmlContentsToRun(d), user))); | ||
| toImmutableMap( | ||
| d -> d, d -> executeIfOwned(d, activeDomains.get(d), actionType, user))); |
There was a problem hiding this comment.
If domainList.domainList contains duplicate domain names (e.g., ["example.tld", "example.tld"]), ForeignKeyUtils.loadResources succeeds (SQL IN + GROUP BY deduplicates), executeIfOwned executes EPP twice (committing the mutation in the DB), and then .collect(toImmutableMap(...)) throws IllegalArgumentException: Multiple entries with same key—returning HTTP 400 after mutating the domain and skipping handleHistoryAdditions (leaving no ConsoleUpdateHistory audit entry).
Also, if domainList.domainList contains null, activeDomains.get(null) throws NullPointerException (ImmutableMap.get(null)), returning HTTP 500 instead of 400.
| private ConsoleEppOutput executeIfOwned( | ||
| String domainName, @Nullable Domain domain, ConsoleDomainActionType actionType, User user) { | ||
| if (domain != null && !domain.getCurrentSponsorRegistrarId().equals(registrarId)) { | ||
| return new ConsoleEppOutput( | ||
| String.format("Domain %s is not owned by registrar %s", domainName, registrarId), | ||
| Result.Code.AUTHORIZATION_ERROR.code); | ||
| } | ||
| return executeEpp(actionType.getXmlContentsToRun(domainName), user); | ||
| } |
There was a problem hiding this comment.
TOCTOU window between upfront loadResources transaction and per-domain EPP transactions:
activeDomains is loaded once in a standalone transaction for up to consoleBulkDomainActionLimit (500) domains, and then each executeEpp runs sequentially in its own transaction with isSuperuser = true:
domain == nullsuperuser fallthrough: Becausedomain == nullfalls through to superuserexecuteEpp(to preserve2303), if a domain did not exist at the upfront load timestamp but is registered/restored by another registrar before the batch reaches it,executeEppruns withisSuperuser = trueand mutates/deletes the other registrar's domain. PassingisSuperuser = falsewhendomain == nullstill preserves2303while closing this gap.- Concurrent transfer completion: If a domain's
PENDING_TRANSFERexpires (implicit server approval) or is approved between the upfrontloadResourcestransaction and itsexecuteEpptransaction,DomainUpdateFlow/DomainDeleteFlowprojects the domain at the later transaction time and mutates the gaining registrar's domain as superuser.
| .containsNoneIn(serverSuspensionStatuses); | ||
| ConsoleUpdateHistory history = loadSingleton(ConsoleUpdateHistory.class).get(); | ||
| assertThat(history.getType()).isEqualTo(ConsoleUpdateHistory.Type.DOMAIN_SUSPEND); | ||
| assertThat(history.getDescription()).hasValue("example.tld"); |
ConsoleBulkDomainAction executes EPP commands with isSuperuser=true for admin users, which bypasses EPP's verifyResourceOwnership check in DomainDeleteFlow and DomainUpdateFlow. As a result, a bulk delete, suspend, or unsuspend request tagged with registrarId=B could mutate domains sponsored by registrar A when submitted by an admin (e.g. during a UI registrar switch race). For each target domain, load the active domain via ForeignKeyUtils.loadResource inside the same transaction that the EPP flow enlists in so ownership is verified atomically at the flow's transaction timestamp (eliminating TOCTOU races with concurrent transfers or registrations). Return an EPP 2201 authorization error without running EPP or recording ConsoleUpdateHistory when the domain's current sponsor does not match registrarId. For nonexistent or deleted domains, invoke EPP with isSuperuser=false to preserve existing 2303 behavior without superuser fallthrough. Also reject null entries in domainList with HTTP 400 and deduplicate domainList (preserving order) before execution so duplicate entries do not execute EPP twice or fail in toImmutableMap after mutating the DB. Add unit tests covering admin cross-registrar delete, suspend, mixed batches, duplicate domains, null list entries, nonexistent/deleted domains, and expired pending transfers projected to another registrar. BUG= http://b/588464773
b2acea4 to
5db581b
Compare
ConsoleBulkDomainAction (
/console-api/bulk-domain) executes EPP commands withisSuperuser = user.getUserRoles().isAdmin(), which bypasses EPP'sverifyResourceOwnershipcheck inDomainDeleteFlowandDomainUpdateFlow. As a result, a bulk delete, suspend, or unsuspend request tagged withregistrarId = Bcan mutate domains sponsored by registrar A when submitted by an admin (for example, during a UI registrar-switch race).Other Console mutation endpoints already enforce server-side registrar scoping (
ConsoleUsersAction.validateUserRegistrarAssociation,ContactAction, andDomainLockUtils.getDomain).Changes
ForeignKeyUtils.loadResourceinside the same per-domaintm().transact(...)block thatFlowRunnerenlists in so ownership is verified atomically at the flow's transaction timestamp (eliminating TOCTOU races with concurrent transfers or registrations).2201(AUTHORIZATION_ERROR) without invoking EPP or recordingConsoleUpdateHistoryfor any domain whosecurrentSponsorRegistrarIddoes not match the request'sregistrarId.isSuperuser = falseto preserve existing EPP2303behavior without superuser fallthrough.nulldomain list ornullentries upfront with HTTP400(IllegalArgumentException), and deduplicatedomainList(preserving order) after the size limit check so duplicates never execute EPP twice or fail intoImmutableMapafter mutating the DB.ConsoleBulkDomainActionTestcovering admin cross-registrarDELETE, admin cross-registrarSUSPEND, mixed batches, duplicate domains,nulllist entries, nonexistent/deleted domains, and expired pending transfers projected to another registrar.BUG= http://b/588464773
This change is