Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

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

Priamo Germosenb36fd2f0be69
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 7fbc9f52b9..c6ef377b77 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -1668,9 +1668,13 @@ or on the `x-amz-cbor-1.1` one, names its resource and condition keys (a queue U
authorizes an operation as a single action of another name, Floci does the same: `SendMessageBatch`
is checked as `sqs:SendMessage` and `PublishBatch` as `sns:Publish`, so a policy granting the
single-message action covers the batch call, and one naming the batch operation, which is not an
-IAM action, grants nothing. The mapping is taken from AWS's Service Reference and vendored in
-`src/main/resources/aws/iam-authorized-actions.json`. DynamoDB `TransactGetItems`, which AWS checks
-as `dynamodb:GetItem`, is checked item by item, as described under
+IAM action, grants nothing. Budgets operations other than its budget actions are checked as
+`budgets:ModifyBudget` or `budgets:ViewBudget`, which the Service Reference lists for them beside the
+`aws-portal` Billing console permissions. Those are not checked: the Billing and Cost Management user
+guide, on moving off them, says "Programmatic requests to AWS Cost Explorer, AWS Cost and Usage
+Reports, and AWS Budgets remains unaffected". The mapping is taken from AWS's Service Reference and
+vendored in `src/main/resources/aws/iam-authorized-actions.json`. DynamoDB `TransactGetItems`, which
+AWS checks as `dynamodb:GetItem`, is checked item by item, as described under
[Condition keys floci populates](#condition-keys-floci-populates): each `Get` as
`dynamodb:GetItem` on its own table, with its own `dynamodb:LeadingKeys`.
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActions.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActions.java
index f9173f526e..2d11b4b7d0 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActions.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActions.java
@@ -25,7 +25,10 @@ import java.util.Set;
* <p>The file is generated by {@code tools/aws/regen_iam_authorized_actions.py} from the
* {@code Operations} AWS's Service Reference publishes per service, which name the actions each SDK
* operation is authorized by. It carries only operations authorized by exactly one action of their
- * own namespace under another name; the generator documents the shapes it leaves out and why.
+ * own namespace under another name, counting neither a Billing console permission nor a
+ * tag-on-create permission beside that action: Budgets {@code CreateBudget} is authorized as
+ * {@code budgets:ModifyBudget} and {@code DescribeBudgets} as {@code budgets:ViewBudget}. The generator
+ * documents the shapes it leaves out and why.
* {@code make iam-authorized-actions-check} gates its shape offline and
* {@code make iam-authorized-actions-verify} checks every entry against AWS. A namespace Floci
* authorizes under a name other than the IAM namespace matches nothing here, and its operations keep
diff --git a/src/main/resources/aws/iam-authorized-actions.json b/src/main/resources/aws/iam-authorized-actions.json
index b677ec7531..b2c39fa661 100644
--- a/src/main/resources/aws/iam-authorized-actions.json
+++ b/src/main/resources/aws/iam-authorized-actions.json
@@ -2,7 +2,7 @@
"_source": {
"generator": "tools/aws/regen_iam_authorized_actions.py",
"reference": "https://servicereference.us-east-1.amazonaws.com/",
- "retrieved": "2026-10-14",
+ "retrieved": "2026-10-24",
"note": "make iam-authorized-actions-verify checks every entry against AWS."
},
"authorizedActions": {
@@ -140,6 +140,23 @@
"InvokeModelWithBidirectionalStream": "bedrock:InvokeModel",
"RetrieveAndGenerateStream": "bedrock:RetrieveAndGenerate"
},
+ "budgets": {
+ "CreateBudget": "budgets:ModifyBudget",
+ "CreateNotification": "budgets:ModifyBudget",
+ "CreateSubscriber": "budgets:ModifyBudget",
+ "DeleteBudget": "budgets:ModifyBudget",
+ "DeleteNotification": "budgets:ModifyBudget",
+ "DeleteSubscriber": "budgets:ModifyBudget",
+ "DescribeBudget": "budgets:ViewBudget",
+ "DescribeBudgetNotificationsForAccount": "budgets:ViewBudget",
+ "DescribeBudgetPerformanceHistory": "budgets:ViewBudget",
+ "DescribeBudgets": "budgets:ViewBudget",
+ "DescribeNotificationsForBudget": "budgets:ViewBudget",
+ "DescribeSubscribersForNotification": "budgets:ViewBudget",
+ "UpdateBudget": "budgets:ModifyBudget",
+ "UpdateNotification": "budgets:ModifyBudget",
+ "UpdateSubscriber": "budgets:ModifyBudget"
+ },
"cassandra": {
"GetKeyspace": "cassandra:Select",
"GetTable": "cassandra:Select",
@@ -194,6 +211,9 @@
"ListDataQualityStatistics": "glue:GetDataQualityResult",
"PublishDataQualityResultV2": "glue:PublishDataQuality"
},
+ "iotfleetwise": {
+ "BatchCreateVehicle": "iotfleetwise:CreateVehicle"
+ },
"lakeformation": {
"GetTemporaryDataLocationCredentials": "lakeformation:GetDataAccess"
},
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionEnforcementIntegrationTest.java
index 2279564f58..ed77021cc6 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionEnforcementIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionEnforcementIntegrationTest.java
@@ -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"))
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionsTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionsTest.java
index 00fe570234..5fea09a895 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionsTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamAuthorizedActionsTest.java
@@ -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"));
diff --git a/tools/aws/regen_iam_authorized_actions.py b/tools/aws/regen_iam_authorized_actions.py
index 96baa4aa4f..baad0e4b64 100644
--- a/tools/aws/regen_iam_authorized_actions.py
+++ b/tools/aws/regen_iam_authorized_actions.py
@@ -33,6 +33,23 @@ each exclusion is deliberate:
- **A tagging action alone.** EC2 lists `CreateCapacityReservationDateChangeQuote` as authorized by
`ec2:CreateTags` only, the tag-on-create permission with the operation's own action missing.
+Two kinds of listed action do not count towards "exactly one":
+
+- **A Billing console permission.** Budgets lists `CreateNotification` as authorized by
+ `budgets:ModifyBudget` and `aws-portal:ModifyBilling`, and `DescribeBudgets` by
+ `budgets:ViewBudget` and `aws-portal:ViewBilling`. The `aws-portal` actions gate the Billing
+ console: the Service Authorization Reference has `aws-portal:UpdateConsoleActionSetEnforced`
+ choosing "whether existing or fine-grained IAM actions will be used to control authorization to
+ Billing, Cost Management, and Account consoles", and the Billing and Cost Management user guide
+ says the `aws-portal` namespace "reached the end of standard support on July 2023" and that
+ "Programmatic requests to AWS Cost Explorer, AWS Cost and Usage Reports, and AWS Budgets remains
+ unaffected".
+- **A tagging action beside one other.** Budgets lists `CreateBudget` as authorized by
+ `budgets:ModifyBudget` and `budgets:TagResource`, and the tagging action is the tag-on-create
+ permission: the Service Authorization Reference has `ModifyBudget` "Grants permission to create
+ and modify budgets", adding "Creating a budget with tags also requires the 'budgets:TagResource'
+ permission".
+
The endpoint is live rather than a pinned dependency, so a fresh generation is not byte-identical.
As with `regen_iam_action_resources.py`, what must hold is that nothing here is invented:
@@ -73,14 +90,21 @@ NAME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9]{0,127}$")
TAGGING_ACTION_RE = re.compile(r"^(CreateTags|DeleteTags|TagResource|UntagResource|CreateOrUpdateTags"
r"|AddTags\w*|RemoveTags\w*)$")
+# The namespaces of console permissions, which an operation's authorized actions may list beside
+# the action its API call is authorized as.
+CONSOLE_NAMESPACES = {"aws-portal"}
+
# The cases that justify vendoring this: batch operations authorized as their single-item action,
-# none of them an IAM action of its own.
+# and Budgets operations authorized as ModifyBudget or ViewBudget, none of them an IAM action of
+# its own.
ANCHORS = {
("sqs", "SendMessageBatch"): "sqs:SendMessage",
("sqs", "DeleteMessageBatch"): "sqs:DeleteMessage",
("sqs", "ChangeMessageVisibilityBatch"): "sqs:ChangeMessageVisibility",
("sns", "PublishBatch"): "sns:Publish",
("dynamodb", "TransactGetItems"): "dynamodb:GetItem",
+ ("budgets", "CreateBudget"): "budgets:ModifyBudget",
+ ("budgets", "DescribeBudgets"): "budgets:ViewBudget",
}
@@ -129,7 +153,7 @@ def authorized_actions_from(documents: list[dict]) -> dict[str, dict[str, str]]:
name = operation.get("Name") if isinstance(operation, dict) else None
if not isinstance(name, str) or not NAME_RE.match(name):
raise ValueError(f"{namespace}: operation entry without a usable 'Name': {operation!r}")
- authorized = _authorized_actions(namespace, operation)
+ authorized = _counted_actions(namespace, _authorized_actions(namespace, operation))
mapped = None
if len(authorized) == 1 and len(_sdk_clients(namespace, operation)) <= 1:
service, action = authorized[0]
@@ -156,6 +180,15 @@ def _authorized_actions(namespace: str, operation: dict) -> list[tuple[str, str]
return [(entry["Service"], entry["Name"]) for entry in authorized]
+def _counted_actions(namespace: str, authorized: list[tuple[str, str]]) -> list[tuple[str, str]]:
+ """The authorized actions that count towards the operation's one action: none of a console's,
+ and, beside one other action, none of the namespace's tagging actions."""
+ counted = [(service, action) for service, action in authorized if service not in CONSOLE_NAMESPACES]
+ untagged = [(service, action) for service, action in counted
+ if service != namespace or not TAGGING_ACTION_RE.match(action)]
+ return untagged if len(untagged) == 1 else counted
+
+
def _sdk_clients(namespace: str, operation: dict) -> set[str]:
"""The SDK clients the operation is listed for."""
sdks = operation.get("SDK") or []
diff --git a/tools/aws/test_regen_iam_authorized_actions.py b/tools/aws/test_regen_iam_authorized_actions.py
index 3cbad657de..ae4ab3e540 100644
--- a/tools/aws/test_regen_iam_authorized_actions.py
+++ b/tools/aws/test_regen_iam_authorized_actions.py
@@ -32,6 +32,9 @@ ANCHOR_SERVICES = [
["SendMessage", "DeleteMessage", "ChangeMessageVisibility"]),
service("sns", {"PublishBatch": ["sns:Publish"]}, ["Publish"]),
service("dynamodb", {"TransactGetItems": ["dynamodb:GetItem"]}, ["GetItem"]),
+ service("budgets", {"CreateBudget": ["aws-portal:ModifyBilling", "budgets:ModifyBudget", "budgets:TagResource"],
+ "DescribeBudgets": ["aws-portal:ViewBilling", "budgets:ViewBudget"]},
+ ["ModifyBudget", "TagResource", "ViewBudget"]),
]
@@ -87,6 +90,33 @@ def test_a_tagging_action_alone_is_a_side_permission():
assert found == {}
+def test_a_billing_console_permission_does_not_count():
+ # The aws-portal actions gate the Billing console; the Budgets API is authorized by budgets alone.
+ found = r.authorized_actions_from([service(
+ "budgets", {"CreateNotification": ["aws-portal:ModifyBilling", "budgets:ModifyBudget"],
+ "DescribeBudgets": ["aws-portal:ViewBilling", "budgets:ViewBudget"]},
+ ["ModifyBudget", "ViewBudget"])])
+ assert found == {"budgets": {"CreateNotification": "budgets:ModifyBudget",
+ "DescribeBudgets": "budgets:ViewBudget"}}
+
+
+def test_a_console_permission_alone_is_no_action():
+ assert r.authorized_actions_from([service("budgets", {"DescribeBudget": ["aws-portal:ViewBilling"]})]) == {}
+
+
+def test_a_tagging_action_beside_one_other_is_the_tag_on_create_permission():
+ found = r.authorized_actions_from([service(
+ "budgets", {"CreateBudget": ["aws-portal:ModifyBilling", "budgets:ModifyBudget", "budgets:TagResource"]},
+ ["ModifyBudget", "TagResource"])])
+ assert found == {"budgets": {"CreateBudget": "budgets:ModifyBudget"}}
+
+
+def test_a_tagging_action_beside_several_leaves_them_several():
+ found = r.authorized_actions_from([service(
+ "budgets", {"CreateBudget": ["budgets:ModifyBudget", "budgets:ViewBudget", "budgets:TagResource"]})])
+ assert found == {}
+
+
def test_namespaces_and_operations_are_sorted():
found = r.authorized_actions_from([
service("sqs", {"SendMessageBatch": ["sqs:SendMessage"],
@@ -155,7 +185,7 @@ def test_a_name_listed_twice_with_different_answers_keeps_its_own_name():
found = r.authorized_actions_from([
service("s3", {"GetPublicAccessBlock": ["s3:GetBucketPublicAccessBlock"]}),
- service("s3", {"GetPublicAccessBlock": ["s3:GetBucketPublicAccessBlock", "s3:TagResource"]}),
+ service("s3", {"GetPublicAccessBlock": ["s3:GetBucketPublicAccessBlock", "iam:PassRole"]}),
])
assert found == {}