From 0740adf9aeda89c8a0695eccc7bc73185899277d Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Sat, 3 Oct 2026 08:42:44 -0500 Subject: [PATCH] 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. --- .../core/common/ResolvedServiceCatalog.java | 7 +++- .../core/common/CredentialScopeAliasTest.java | 1 - .../ServiceCatalogRoutingIntegrationTest.java | 2 +- ...knownServiceScopeGuardIntegrationTest.java | 39 +++++++++++++++++++ ...piGatewayV2UnsignedAccountRoutingTest.java | 4 +- .../services/ses/SesIntegrationTest.java | 4 +- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java index 48e5bbf4b1..830b0ffbef 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java @@ -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, diff --git a/src/test/java/io/github/hectorvent/floci/core/common/CredentialScopeAliasTest.java b/src/test/java/io/github/hectorvent/floci/core/common/CredentialScopeAliasTest.java index 3a07502ee9..8916a81cb8 100644 --- a/src/test/java/io/github/hectorvent/floci/core/common/CredentialScopeAliasTest.java +++ b/src/test/java/io/github/hectorvent/floci/core/common/CredentialScopeAliasTest.java @@ -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")); } diff --git a/src/test/java/io/github/hectorvent/floci/core/common/ServiceCatalogRoutingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/core/common/ServiceCatalogRoutingIntegrationTest.java index ee037678de..2c4f1e0056 100644 --- a/src/test/java/io/github/hectorvent/floci/core/common/ServiceCatalogRoutingIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/core/common/ServiceCatalogRoutingIntegrationTest.java @@ -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)); } diff --git a/src/test/java/io/github/hectorvent/floci/core/common/UnknownServiceScopeGuardIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/core/common/UnknownServiceScopeGuardIntegrationTest.java index 9cdaa8d410..7807b88157 100644 --- a/src/test/java/io/github/hectorvent/floci/core/common/UnknownServiceScopeGuardIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/core/common/UnknownServiceScopeGuardIntegrationTest.java @@ -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() diff --git a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2UnsignedAccountRoutingTest.java b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2UnsignedAccountRoutingTest.java index 0a5f8ad8c6..f436da1a9d 100644 --- a/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2UnsignedAccountRoutingTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/apigatewayv2/ApiGatewayV2UnsignedAccountRoutingTest.java @@ -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", diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java index 4f287b1bc4..839567dbe5 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIntegrationTest.java @@ -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("/")