fix(cognito): refuse a custom domain certificate from another partition or account (#7110)

requireUsableCertificate checked only the certificate ARN's service, region and resource. ACM finds a certificate by its id in the caller's own account, so an ARN naming another partition or another account was accepted as the caller's certificate. Both now get the same InvalidParameterException as any other unusable certificate.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-31 14:05:03 -04:00
1 parent bc237ae980
commit 504c9d23bb
2 files changed
+21 -1

No files matched your search

@@ -109,4 +109,20 @@ class CognitoCustomDomainPartitionTest {
UserPoolDomain updated = service.updateUserPoolDomain(CUSTOM_DOMAIN, poolId, replacement, null);
assertEquals(replacement.get("CertificateArn"), updated.getCertificateArn());
}
@ParameterizedTest
@ValueSource(strings = {
"arn:aws-cn:acm:us-east-1:000000000000:certificate/abc",
"arn:aws:acm:us-east-1:111111111111:certificate/abc"})
void aCertificateFromAnotherPartitionOrAccountIsRefused(String certificateArn) {
CognitoService service = serviceIn("us-east-1");
String poolId = createPool(service, "us-east-1");
AwsException error = assertThrows(AwsException.class, () -> service.createUserPoolDomain(
CUSTOM_DOMAIN, poolId, Map.of("CertificateArn", certificateArn), null));
assertEquals("InvalidParameterException", error.getErrorCode());
assertThat(error.getMessage(), containsString("SSL certificate doesn't exist"));
assertTrue(service.findCustomDomain(CUSTOM_DOMAIN).isEmpty());
}
}