fix(iam): authorize Budgets operations as ModifyBudget and ViewBudget (#6436)

Under IAM enforcement a Budgets operation other than a budget action was
authorized as its own name, budgets:CreateBudget and the like, which is
no IAM action. A policy granting budgets:ModifyBudget was denied
CreateBudget, and one granting budgets:ViewBudget was denied
DescribeBudgets, while a policy naming the operation, which grants
nothing on AWS, let it through.

AWS's Service Reference authorizes these operations as
budgets:ModifyBudget or budgets:ViewBudget. Beside that action it lists
the aws-portal Billing console permissions and, for CreateBudget, the
tag-on-create budgets:TagResource, so the authorized-action generator
counted two or three actions and left them out. It now counts neither:
the aws-portal actions gate the Billing console, and the Billing and
Cost Management user guide says programmatic requests to AWS Budgets
are not affected by them; a namespace's tagging action beside exactly
one other is the tag-on-create permission. That adds the 15 Budgets
operations and IoT FleetWise BatchCreateVehicle, which Floci does not
serve, to the vendored map.

Not checked: budgets:TagResource when CreateBudget or CreateBudgetAction
carries tags.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-24 14:58:08 -05:00
1 parent e5ea747644
commit b36fd2f0be
7 files changed
+147 -8

No files matched your search

@@ -151,6 +151,35 @@ class IamAuthorizedActionEnforcementIntegrationTest {
.body(containsString("dynamodb:GetItem"));
}
@Test
void aBudgetIsChangedUnderModifyBudgetAndReadUnderViewBudget() {
String budget = "authorized-" + UUID.randomUUID().toString().substring(0, 8);
String create = """
{"AccountId": "%s", "Budget": {"BudgetName": "%s", "BudgetType": "COST", "TimeUnit": "MONTHLY",
"BudgetLimit": {"Amount": "100", "Unit": "USD"}}}
""".formatted(ACCOUNT_ID, budget);
String named = """
{"AccountId": "%s", "BudgetName": "%s"}
""".formatted(ACCOUNT_ID, budget);
// CreateBudget is no IAM action, so a policy naming it grants nothing.
budgets(userAllowed("budgets:CreateBudget"), "CreateBudget", create)
.statusCode(400)
.body("__type", equalTo("AccessDeniedException"))
.body(containsString("budgets:ModifyBudget"));
budgets(userAllowed("budgets:ModifyBudget"), "CreateBudget", create).statusCode(200);
cleanup.register(() -> budgets(ACCOUNT_ID, "DeleteBudget", named).statusCode(200));
String reader = userAllowed("budgets:ViewBudget");
budgets(reader, "DescribeBudget", named)
.statusCode(200)
.body("Budget.BudgetName", equalTo(budget));
budgets(reader, "DeleteBudget", named)
.statusCode(400)
.body("__type", equalTo("AccessDeniedException"))
.body(containsString("budgets:ModifyBudget"));
}
private String createTable() {
String table = "authorized-" + UUID.randomUUID();
dynamoDb(ACCOUNT_ID, "CreateTable", """
@@ -219,6 +248,17 @@ class IamAuthorizedActionEnforcementIntegrationTest {
.then();
}
private static ValidatableResponse budgets(String accessKeyId, String operation, String body) {
return given()
.header("Authorization", auth(accessKeyId, "budgets"))
.header("X-Amz-Target", "AWSBudgetServiceGateway." + operation)
.contentType("application/x-amz-json-1.1")
.body(body)
.when()
.post("/")
.then();
}
private static ValidatableResponse sqsQuery(String accessKeyId, String action, Map<String, String> params) {
RequestSpecification spec = given()
.header("Authorization", auth(accessKeyId, "sqs"))
@@ -22,6 +22,15 @@ class IamAuthorizedActionsTest {
assertEquals("sns:Publish", IamAuthorizedActions.actionFor("sns", "PublishBatch"));
}
@Test
void budgetsOperationsAreAuthorizedAsModifyBudgetOrViewBudget() {
assertEquals("budgets:ModifyBudget", IamAuthorizedActions.actionFor("budgets", "CreateBudget"));
assertEquals("budgets:ModifyBudget", IamAuthorizedActions.actionFor("budgets", "UpdateSubscriber"));
assertEquals("budgets:ViewBudget", IamAuthorizedActions.actionFor("budgets", "DescribeBudgets"));
// A budget action is authorized by an action of its own.
assertEquals("budgets:CreateBudgetAction", IamAuthorizedActions.actionFor("budgets", "CreateBudgetAction"));
}
@Test
void anOperationTheFileDoesNotNameKeepsItsOwnName() {
assertEquals("sqs:SendMessage", IamAuthorizedActions.actionFor("sqs", "SendMessage"));