From 62527ebaa8d66f0ef9f8e7a1759b60f8ca49dde6 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:04:35 -0400 Subject: [PATCH] fix(iam): check ModifyReportDefinition on the report it names alone (#6935) The generated table of the resources requests name checked Cost and Usage Reports' ModifyReportDefinition on the report its ReportName names and also on its ReportDefinition.BillingViewArn, read as a report definition's ARN. That member is a billing view's ARN (arn:aws:billing:::billingview/...), never a report's, so a request carrying a report's ARN there was checked on a report it does not act on. PutReportDefinition's correction already leaves it out. A correction now reads ModifyReportDefinition's report from ReportName alone, sharing PutReportDefinition's reason, and the table is regenerated; nothing in it is edited by hand. --- docs/services/iam.md | 4 ++-- src/main/resources/aws/iam-request-resources.json | 2 +- .../IamRequestResourceEnforcementIntegrationTest.java | 10 ++++++++-- tools/aws/regen_iam_request_resources.py | 10 ++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/services/iam.md b/docs/services/iam.md index 260717754d..4b22425b60 100644 --- a/docs/services/iam.md +++ b/docs/services/iam.md @@ -1563,8 +1563,8 @@ namespace its `NamespaceId` names or, when it gives none or a JSON null, the one project, which its id names before its `:` (`:`), as CodeBuild authorizes `BatchGetBuilds`, `StopBuild`, `RetryBuild` and `BatchDeleteBuilds`. `CreateBudget` and `UpdateBudget` are checked on the budget their `Budget.BudgetName` or `NewBudget.BudgetName` names, and Cost and Usage -Reports' `PutReportDefinition` on the report its `ReportDefinition.ReportName` names, not on the billing -view ARN each may carry, which names no budget or report. An EventBridge rule is on the event bus +Reports' `PutReportDefinition` and `ModifyReportDefinition` on the report their `ReportDefinition.ReportName` +or `ReportName` names, not on the billing view ARN each may carry, which names no budget or report. An EventBridge rule is on the event bus its request's `EventBusName` names, by name or by ARN, and on the default bus when it names none or gives a null, whose rules are `rule/`, with no bus; a bus ARN of another account, the default bus's included, names that account's rule, checked as given and as the caller's own, which diff --git a/src/main/resources/aws/iam-request-resources.json b/src/main/resources/aws/iam-request-resources.json index 7b541ae82f..a055c5d3b4 100644 --- a/src/main/resources/aws/iam-request-resources.json +++ b/src/main/resources/aws/iam-request-resources.json @@ -336,7 +336,7 @@ "cur:DeleteReportDefinition": {"action": "cur:DeleteReportDefinition", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportName"}}]}, "cur:DescribeReportDefinitions": {"action": "cur:DescribeReportDefinitions", "types": [], "resources": []}, "cur:ListTagsForResource": {"action": "cur:ListTagsForResource", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportName"}}]}, - "cur:ModifyReportDefinition": {"action": "cur:ModifyReportDefinition", "types": ["cur"], "resources": [{"types": ["cur"], "arn": "ReportDefinition.BillingViewArn"}, {"type": "cur", "fill": {"ReportName": "ReportName"}}]}, + "cur:ModifyReportDefinition": {"action": "cur:ModifyReportDefinition", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportName"}}]}, "cur:PutReportDefinition": {"action": "cur:PutReportDefinition", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportDefinition.ReportName"}}]}, "cur:TagResource": {"action": "cur:TagResource", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportName"}}]}, "cur:UntagResource": {"action": "cur:UntagResource", "types": ["cur"], "resources": [{"type": "cur", "fill": {"ReportName": "ReportName"}}]}, diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java index a719c4c11f..68be5fdda6 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java @@ -809,17 +809,23 @@ class IamRequestResourceEnforcementIntegrationTest { /** * A Cost and Usage Report definition is checked on {@code definition/}, a put on the one its - * {@code ReportDefinition.ReportName} names, not on one its billing view ARN gives. + * {@code ReportDefinition.ReportName} names and a modify on the one its {@code ReportName} names, neither on one + * its billing view ARN gives. */ @Test void aReportDefinitionIsCheckedOnTheArnItsNameGives() { String name = "res-report-" + suffix(); String arn = "arn:aws:cur:" + REGION + ":" + ACCOUNT + ":definition/" + name; User user = user("res-report"); - user.policy(allowOn("cur:PutReportDefinition", arn) + "," + allowOn("cur:DeleteReportDefinition", arn)); + user.policy(allowOn("cur:PutReportDefinition", arn) + "," + allowOn("cur:ModifyReportDefinition", arn) + "," + + allowOn("cur:DeleteReportDefinition", arn)); refusedJson(cur(user, "PutReportDefinition", "{\"ReportDefinition\":" + reportDefinition(name + "-other", arn) + "}"), "cur:PutReportDefinition"); cur(user, "PutReportDefinition", "{\"ReportDefinition\":" + reportDefinition(name, null) + "}").statusCode(200); + cur(user, "ModifyReportDefinition", "{\"ReportName\":\"" + name + "\",\"ReportDefinition\":" + + reportDefinition(name, arn + "-other") + "}").statusCode(200); + refusedJson(cur(user, "ModifyReportDefinition", "{\"ReportName\":\"" + name + "-other\",\"ReportDefinition\":" + + reportDefinition(name + "-other", arn) + "}"), "cur:ModifyReportDefinition"); cur(user, "DeleteReportDefinition", "{\"ReportName\":\"" + name + "\"}").statusCode(200); } diff --git a/tools/aws/regen_iam_request_resources.py b/tools/aws/regen_iam_request_resources.py index 3ee065e59e..e4d5f30444 100644 --- a/tools/aws/regen_iam_request_resources.py +++ b/tools/aws/regen_iam_request_resources.py @@ -264,10 +264,12 @@ CORRECTIONS: dict[str, tuple[list[dict], str]] = { "its ':' (CODEBUILD_BUILD_ID, for example codebuild-demo-project:b1e6661e-...)") for operation, member in (("BatchDeleteBuilds", "ids[]"), ("BatchGetBuilds", "ids[]"), ("RetryBuild", "id"), ("StopBuild", "id"))}, - "cur:PutReportDefinition": ([{"type": "cur", "fill": {"ReportName": "ReportDefinition.ReportName"}}], - "the request names the report by ReportDefinition.ReportName ('The name of the report " - "that you want to create'), which the rule does not read inside a structure; its " - "BillingViewArn is a billing view's ARN, never a report definition's"), + **{f"cur:{operation}": ([{"type": "cur", "fill": {"ReportName": member}}], + f"the request names the report by {member} ('The name of the report that you want to " + "create') alone; its ReportDefinition's BillingViewArn, which the rule reads as a report " + "definition's ARN, is a billing view's (arn:aws:billing:::billingview/...)") + for operation, member in (("ModifyReportDefinition", "ReportName"), + ("PutReportDefinition", "ReportDefinition.ReportName"))}, **{f"codepipeline:{operation}": ([{"type": "pipeline", "fill": {"PipelineName": "pipeline.name"}}], "the request names the pipeline by its pipeline structure's name, which the " "rule does not read inside a structure; its roleArn is the role CodePipeline "