fix(athena): read and check a request naming no catalog as AwsDataCatalog (#7061)

Athena's GetDataCatalog, ListDatabases, ListTableMetadata and
GetTableMetadata handlers read the catalog name with has() and
asText(), so a JSON null became a catalog named `null`: GetDataCatalog
then answered InvalidRequestException rather than the AwsDataCatalog
it answers for a request naming none. They now read it through the
handler's text(), as GetWorkGroup and StartQueryExecution read
WorkGroup, so a JSON null names no catalog.

Under IAM enforcement, a GetDataCatalog naming no catalog was checked
on `*` though Floci answers AwsDataCatalog, so a grant on that catalog
was refused and a deny on it did not apply, and the three catalog
reads given a JSON null CatalogName were checked on `datacatalog/null`
as well as on AwsDataCatalog. The request-resources table now reads a
request naming none, or a JSON null, as naming AwsDataCatalog for all
four, as it reads Athena's primary workgroup.

The table's regeneration also takes up drift in AWS's Service
Reference since the last sync, which the online check of both IAM
tables fails on: AWS now lists cognito-idp:DescribeTermsByClient among
the actions it authorizes DescribeTermsByClient as, so the
authorized-actions map no longer maps it to DescribeTerms and the
request-resources table checks it as its own action, and the map
gains MediaConnect's new BatchGetDestinationEndpoint and
BatchGetSourceEndpoint. Floci serves none of these operations.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-31 10:27:14 -05:00
1 parent f40d784f66
commit bfd3bcbbce
8 files changed
+69 -21

No files matched your search

@@ -124,10 +124,8 @@ public class AthenaJsonHandler {
}
yield Response.ok(response).build();
}
case "GetDataCatalog" -> {
String name = request.has("Name") ? request.get("Name").asText() : AthenaService.DEFAULT_CATALOG;
yield Response.ok(Map.of("DataCatalog", athenaService.getDataCatalog(region, name))).build();
}
case "GetDataCatalog" -> Response.ok(
Map.of("DataCatalog", athenaService.getDataCatalog(region, text(request, "Name")))).build();
case "CreateDataCatalog" -> {
Map<String, Object> catalog = athenaService.createDataCatalog(region,
text(request, "Name"),
@@ -156,16 +154,16 @@ public class AthenaJsonHandler {
yield Response.ok(Map.of()).build();
}
case "ListDatabases" -> {
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
String catalog = catalogName(request);
yield Response.ok(Map.of("DatabaseList", athenaService.listDatabases(catalog))).build();
}
case "ListTableMetadata" -> {
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
String catalog = catalogName(request);
String database = request.path("DatabaseName").asText(request.path("Database").asText(""));
yield Response.ok(Map.of("TableMetadataList", athenaService.listTableMetadata(catalog, database))).build();
}
case "GetTableMetadata" -> {
String catalog = request.has("CatalogName") ? request.get("CatalogName").asText() : AthenaService.DEFAULT_CATALOG;
String catalog = catalogName(request);
String database = request.path("DatabaseName").asText(request.path("Database").asText(""));
String tableName = request.get("TableName").asText();
yield Response.ok(Map.of("TableMetadata", athenaService.getTableMetadata(catalog, database, tableName))).build();
@@ -194,6 +192,11 @@ public class AthenaJsonHandler {
return node == null || node.isNull() ? null : node.asText();
}
private static String catalogName(JsonNode request) {
String named = text(request, "CatalogName");
return named != null ? named : AthenaService.DEFAULT_CATALOG;
}
private static Map<String, String> parameters(JsonNode request) {
JsonNode node = request.get("Parameters");
if (node == null || !node.isObject()) {
@@ -2,7 +2,7 @@
"_source": {
"generator": "tools/aws/regen_iam_authorized_actions.py",
"reference": "https://servicereference.us-east-1.amazonaws.com/",
"retrieved": "2026-10-24",
"retrieved": "2026-10-31",
"note": "make iam-authorized-actions-verify checks every entry against AWS."
},
"authorizedActions": {
@@ -165,9 +165,6 @@
"ListTables": "cassandra:Select",
"ListTypes": "cassandra:Select"
},
"cognito-idp": {
"DescribeTermsByClient": "cognito-idp:DescribeTerms"
},
"connect": {
"UpdateUserConfig": "connect:UpdateUserPhoneConfig"
},
@@ -227,9 +224,11 @@
"ListUtteranceMetrics": "lex:ListAggregatedUtterances"
},
"mediaconnect": {
"BatchGetDestinationEndpoint": "mediaconnect:GetDestinationEndpoint",
"BatchGetRouterInput": "mediaconnect:GetRouterInput",
"BatchGetRouterNetworkInterface": "mediaconnect:GetRouterNetworkInterface",
"BatchGetRouterOutput": "mediaconnect:GetRouterOutput"
"BatchGetRouterOutput": "mediaconnect:GetRouterOutput",
"BatchGetSourceEndpoint": "mediaconnect:GetSourceEndpoint"
},
"qapps": {
"CreatePresignedUrl": "qapps:ImportDocument"
@@ -1,5 +1,5 @@
{
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-10-30", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-10-31", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
"namespaces": {"acm": ["acm"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "events": ["events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "kinesisanalytics": ["kinesisanalyticsv2"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]},
"clientsNotRead": {"eventbridgev2": "EventBridge V2, the AWSEventsV2 target over Smithy RPC v2 CBOR on the eventsv2 endpoint, which Floci does not serve; its operations share EventBridge's names and name their resources by other members", "kinesisanalytics": "Kinesis Data Analytics v1, SQL applications on the KinesisAnalytics_20150814 target, which Floci does not serve (it serves v2, kinesisanalyticsv2); its operations share v2's names and name their resources by other members"},
"handBuilt": ["apigateway", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"],
@@ -72,7 +72,7 @@
"athena:GetCalculationExecutionStatus": {"action": "athena:GetCalculationExecutionStatus", "types": ["workgroup"], "resources": []},
"athena:GetCapacityAssignmentConfiguration": {"action": "athena:GetCapacityAssignmentConfiguration", "types": ["capacity-reservation"], "resources": [{"type": "capacity-reservation", "fill": {"CapacityReservationName": "CapacityReservationName"}}]},
"athena:GetCapacityReservation": {"action": "athena:GetCapacityReservation", "types": ["capacity-reservation"], "resources": [{"type": "capacity-reservation", "fill": {"CapacityReservationName": "Name"}}]},
"athena:GetDataCatalog": {"action": "athena:GetDataCatalog", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "Name"}}]},
"athena:GetDataCatalog": {"action": "athena:GetDataCatalog", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "Name"}, "absent": {"Name": "AwsDataCatalog"}}]},
"athena:GetDatabase": {"action": "athena:GetDatabase", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}}]},
"athena:GetNamedQuery": {"action": "athena:GetNamedQuery", "types": ["workgroup"], "resources": []},
"athena:GetNotebookMetadata": {"action": "athena:GetNotebookMetadata", "types": ["workgroup"], "resources": []},
@@ -84,14 +84,14 @@
"athena:GetSession": {"action": "athena:GetSession", "types": ["session", "workgroup"], "resources": [{"type": "session", "fill": {"SessionId": "SessionId"}}]},
"athena:GetSessionEndpoint": {"action": "athena:GetSessionEndpoint", "types": ["session", "workgroup"], "resources": [{"type": "session", "fill": {"SessionId": "SessionId"}}]},
"athena:GetSessionStatus": {"action": "athena:GetSessionStatus", "types": ["session", "workgroup"], "resources": [{"type": "session", "fill": {"SessionId": "SessionId"}}]},
"athena:GetTableMetadata": {"action": "athena:GetTableMetadata", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:GetTableMetadata": {"action": "athena:GetTableMetadata", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}, "absent": {"CatalogName": "AwsDataCatalog"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:GetWorkGroup": {"action": "athena:GetWorkGroup", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}, "absent": {"WorkGroup": "primary"}}]},
"athena:ImportNotebook": {"action": "athena:ImportNotebook", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}}]},
"athena:ListApplicationDPUSizes": {"action": "athena:ListApplicationDPUSizes", "types": [], "resources": []},
"athena:ListCalculationExecutions": {"action": "athena:ListCalculationExecutions", "types": ["workgroup"], "resources": []},
"athena:ListCapacityReservations": {"action": "athena:ListCapacityReservations", "types": [], "resources": []},
"athena:ListDataCatalogs": {"action": "athena:ListDataCatalogs", "types": [], "resources": []},
"athena:ListDatabases": {"action": "athena:ListDatabases", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:ListDatabases": {"action": "athena:ListDatabases", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}, "absent": {"CatalogName": "AwsDataCatalog"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:ListEngineVersions": {"action": "athena:ListEngineVersions", "types": [], "resources": []},
"athena:ListExecutors": {"action": "athena:ListExecutors", "types": [], "resources": []},
"athena:ListNamedQueries": {"action": "athena:ListNamedQueries", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}, "absent": {"WorkGroup": "primary"}}]},
@@ -100,7 +100,7 @@
"athena:ListPreparedStatements": {"action": "athena:ListPreparedStatements", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}}]},
"athena:ListQueryExecutions": {"action": "athena:ListQueryExecutions", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}, "absent": {"WorkGroup": "primary"}}]},
"athena:ListSessions": {"action": "athena:ListSessions", "types": ["workgroup"], "resources": [{"type": "workgroup", "fill": {"WorkGroupName": "WorkGroup"}}]},
"athena:ListTableMetadata": {"action": "athena:ListTableMetadata", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:ListTableMetadata": {"action": "athena:ListTableMetadata", "types": ["datacatalog"], "resources": [{"type": "datacatalog", "fill": {"DataCatalogName": "CatalogName"}, "absent": {"CatalogName": "AwsDataCatalog"}}, {"type": "datacatalog", "fill": {}, "fixed": {"DataCatalogName": "AwsDataCatalog"}}]},
"athena:ListTagsForResource": {"action": "athena:ListTagsForResource", "types": ["capacity-reservation", "datacatalog", "session", "workgroup"], "resources": [{"types": ["capacity-reservation", "datacatalog", "session", "workgroup"], "arn": "ResourceARN"}]},
"athena:ListWorkGroups": {"action": "athena:ListWorkGroups", "types": [], "resources": []},
"athena:PutCapacityAssignmentConfiguration": {"action": "athena:PutCapacityAssignmentConfiguration", "types": ["capacity-reservation", "workgroup"], "resources": [{"type": "capacity-reservation", "fill": {"CapacityReservationName": "CapacityReservationName"}}]},
@@ -491,7 +491,7 @@
"cognito-idp:DescribeResourceServer": {"action": "cognito-idp:DescribeResourceServer", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeRiskConfiguration": {"action": "cognito-idp:DescribeRiskConfiguration", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeTerms": {"action": "cognito-idp:DescribeTerms", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeTermsByClient": {"action": "cognito-idp:DescribeTerms", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeTermsByClient": {"action": "cognito-idp:DescribeTermsByClient", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeUserImportJob": {"action": "cognito-idp:DescribeUserImportJob", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeUserPool": {"action": "cognito-idp:DescribeUserPool", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
"cognito-idp:DescribeUserPoolClient": {"action": "cognito-idp:DescribeUserPoolClient", "types": ["userpool"], "resources": [{"type": "userpool", "fill": {"UserPoolId": "UserPoolId"}}]},
@@ -486,4 +486,19 @@ class AthenaDataCatalogIntegrationTest {
.statusCode(400)
.body("__type", equalTo("InvalidRequestException"));
}
@Test
@Order(19)
void getDataCatalogNamingNullServesTheBuiltInGlueCatalog() {
given()
.header("X-Amz-Target", "AmazonAthena.GetDataCatalog")
.contentType(CONTENT_TYPE)
.body("{ \"Name\": null }")
.when()
.post("/")
.then()
.statusCode(200)
.body("DataCatalog.Name", equalTo("AwsDataCatalog"))
.body("DataCatalog.Type", equalTo("GLUE"));
}
}
@@ -818,6 +818,28 @@ class IamRequestResourceEnforcementIntegrationTest {
"athena:ListDatabases");
}
/**
* An Athena catalog request naming no catalog, or a JSON null, is checked on {@code AwsDataCatalog}, the one
* {@code GetDataCatalog} answers and the catalog reads read, so a grant on it reaches them and a deny on it applies.
*/
@Test
void aCatalogRequestNamingNoCatalogIsCheckedOnTheGlueOne() {
String glue = "arn:aws:athena:" + REGION + ":" + ACCOUNT + ":datacatalog/AwsDataCatalog";
User user = user("res-glue-catalog");
user.policy(allowOn("athena:GetDataCatalog", glue) + "," + allowOn("athena:ListDatabases", glue));
send(user, "athena", "AmazonAthena.GetDataCatalog", "1.1", "{}").statusCode(200)
.body("DataCatalog.Name", equalTo("AwsDataCatalog"));
send(user, "athena", "AmazonAthena.GetDataCatalog", "1.1", "{\"Name\":null}").statusCode(200)
.body("DataCatalog.Name", equalTo("AwsDataCatalog"));
send(user, "athena", "AmazonAthena.ListDatabases", "1.1", "{\"CatalogName\":null}").statusCode(200);
refusedJson(send(user, "athena", "AmazonAthena.GetDataCatalog", "1.1", "{\"Name\":\"res-other\"}"),
"athena:GetDataCatalog");
User denied = user("res-glue-denied");
denied.policy(allowOn("athena:GetDataCatalog", "*") + ",{\"Effect\":\"Deny\",\"Action\":"
+ "\"athena:GetDataCatalog\",\"Resource\":\"" + glue + "\"}");
refusedJson(send(denied, "athena", "AmazonAthena.GetDataCatalog", "1.1", "{}"), "athena:GetDataCatalog");
}
/**
* A Data Exports export is checked on its ARN, and a create not on the ARN its {@code Export.ExportArn} gives,
* which is the new export's own, so a table's there checks nothing.