fix(core): stop accepting SigV4 scopes no SDK signs with (#5005)

ResolvedServiceCatalog declared apigatewayv2 and sesv2 as credential
scopes, but every SDK signs those services as apigateway and ses
(botocore signingName, Java v2 codegen, Go v2 endpoints, JS v3 auth
scheme). The extra names only widened what the unknown-service guard let
through: a REST request signed apigatewayv2 or sesv2 reached a route no
real client would send it to. Both are dropped; API Gateway v2 JSON
requests still route by their AmazonApiGatewayV2. target and REST
/v2/apis by its resource class. A hand-written client that signed with
either name now gets UnknownOperationException, and
floci.protocols.reject-unknown-service-scope=false still turns the guard
off.

The tests that signed with the dropped names now sign as their SDKs do,
and UnknownServiceScopeGuardIntegrationTest pins both rejections next to
the accepted scope.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-03 09:42:44 -04:00
1 parent a18aa246d3
commit 0740adf9ae
6 files changed
+49 -8

No files matched your search

@@ -259,7 +259,9 @@ public class ResolvedServiceCatalog {
descriptor("apigatewayv2", "apigatewayv2", config.services().apigatewayv2().enabled(), true,
"apigatewayv2", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("AmazonApiGatewayV2."), Set.of("apigatewayv2"), Set.of(), Set.of()),
// No credential scope: every SDK signs API Gateway v2 as apigateway, which the
// apigateway descriptor declares; REST /v2/apis routes by its resource class.
Set.of("AmazonApiGatewayV2."), Set.of(), Set.of(), Set.of()),
descriptor("kinesis", "kinesis", config.services().kinesis().enabled(), true,
"kinesis", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON, ServiceProtocol.CBOR),
@@ -310,7 +312,8 @@ public class ResolvedServiceCatalog {
descriptor("email", "ses", config.services().ses().enabled(), true,
"ses", config.storage().mode(), 5000L, AwsNamespaces.SES, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON, ServiceProtocol.QUERY),
Set.of(), Set.of("email", "ses", "sesv2"), Set.of(),
// SES v2 signs as ses in every SDK, so sesv2 is not a credential scope.
Set.of(), Set.of("email", "ses"), Set.of(),
Set.of(SesAccountController.class, SesConfigurationSetController.class,
SesContactController.class, SesCvetController.class,
SesDedicatedIpController.class, SesExportJobController.class,
@@ -68,7 +68,6 @@ class CredentialScopeAliasTest {
// canonical scope from the external key would rewrite valid scopes onto prefixes AWS
// never issues, so every action would resolve to null and enforcement would be skipped.
assertEquals("ses", catalog.canonicalCredentialScope("ses"));
assertEquals("sesv2", catalog.canonicalCredentialScope("sesv2"));
assertEquals("bedrock", catalog.canonicalCredentialScope("bedrock"));
assertEquals("logs", catalog.canonicalCredentialScope("logs"));
}
@@ -54,7 +54,7 @@ class ServiceCatalogRoutingIntegrationTest {
@Test
void queryProtocolAliasesAreDeclaredOnDescriptors() {
assertTrue(catalog.byCredentialScope("sesv2").orElseThrow().supportsProtocol(ServiceProtocol.QUERY));
assertTrue(catalog.byCredentialScope("ses").orElseThrow().supportsProtocol(ServiceProtocol.QUERY));
assertTrue(catalog.byCredentialScope("cognito-idp").orElseThrow().supportsProtocol(ServiceProtocol.QUERY));
}
@@ -115,6 +115,45 @@ class UnknownServiceScopeGuardIntegrationTest {
.body("__type", not(equalTo("UnknownOperationException")));
}
@Test
void sesv2IsNotASigningScope() {
// Every SDK signs SES v2 as ses (botocore sesv2 signingName), so a REST request signed
// sesv2 names no service Floci serves.
given()
.header("Authorization", authorization("sesv2"))
.when()
.get("/v2/email/account")
.then()
.statusCode(404)
.body("__type", equalTo("UnknownOperationException"));
given()
.header("Authorization", authorization("ses"))
.when()
.get("/v2/email/account")
.then()
.statusCode(200);
}
@Test
void apigatewayv2IsNotASigningScope() {
// API Gateway v2 signs as apigateway in every SDK (botocore apigatewayv2 signingName).
given()
.header("Authorization", authorization("apigatewayv2"))
.when()
.get("/v2/apis")
.then()
.statusCode(404)
.body("__type", equalTo("UnknownOperationException"));
given()
.header("Authorization", authorization("apigateway"))
.when()
.get("/v2/apis")
.then()
.statusCode(200);
}
@Test
void unsignedRequestIsUntouched() {
given()
@@ -42,7 +42,7 @@ class ApiGatewayV2UnsignedAccountRoutingTest {
}
private String createApiGraph(String accountId, String functionName) {
String authorization = authorization(accountId, "apigatewayv2");
String authorization = authorization(accountId, "apigateway");
String apiId = given()
.contentType(ContentType.JSON)
.header("Authorization", authorization)
@@ -102,7 +102,7 @@ class ApiGatewayV2UnsignedAccountRoutingTest {
private void createApiWithId(String accountId, String apiId, int expectedStatus) {
given()
.contentType(ContentType.JSON)
.header("Authorization", authorization(accountId, "apigatewayv2"))
.header("Authorization", authorization(accountId, "apigateway"))
.body("""
{
"name":"account-owned-api",
@@ -304,10 +304,10 @@ class SesIntegrationTest {
@Test
@Order(15)
void getAccountSendingEnabled_acceptsSesv2CredentialScopeAlias() {
void getAccountSendingEnabled_acceptsTheSesCredentialScope() {
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", authorization("sesv2"))
.header("Authorization", authorization("ses"))
.formParam("Action", "GetAccountSendingEnabled")
.when()
.post("/")