From 96d0a87fc418c88faf2748e0af3d01b97312d8d5 Mon Sep 17 00:00:00 2001
From: Priamo
Date: Thu, 19 Nov 2026 07:15:20 -0400
Subject: [PATCH] fix(iam): check EKS requests on the resources the generated
table gives them
EKS was built by hand: ResourceArnBuilder walked an EKS path, looked
each resource up through EksService, and checked a tagging route on the
caller's cluster named after the ARN's last segment; the request
resources table held no EKS operation, and nothing gave a policy
condition an EKS resource's tags. eks moves from HAND_BUILT to
NAMESPACES, so the table gives each operation the cluster its path
names, the node group, add-on or Fargate profile EksStoredResourceArns
finds by its cluster and name, the ARN a tagging route carries, and
parts of an ARN the request does not give open. CreateCluster, for which
the Service Reference lists no resource type, is checked on the cluster
its body names from a MEASURED entry quoting the EKS user guide's
example policy for creating a cluster. ResourceArnBuilder's EKS section
and its EksService dependency go. EksStoredResourceArns answers the
stored tags of a cluster, node group, Fargate profile, add-on, Pod
Identity association or access entry; EKS's tag changes take one lock
and give a cluster, node group or Fargate profile a new map, whose tags
field is now volatile, and a cluster is tagged only when its ARN is the
whole ARN the request names. Tag changes and tag reads find a cluster,
node group or Fargate profile through one lookup, and an ARN with a part
left open is not looked up. Read from its model, EKS tags only on
/tags/{resourceArn} with the ARN encoded, as the SDKs send it, so the
tagging tests that sent it unencoded now encode it. Only EKS's
operations change in the table.
---
docs/services/iam.md | 37 ++--
.../aws/core/common/StoredResourceArns.java | 7 +-
.../services/eks/EksAccessEntryService.java | 20 ++
.../aws/services/eks/EksAddonService.java | 11 ++
.../eks/EksPodIdentityAssociationService.java | 12 ++
.../io/floci/aws/services/eks/EksService.java | 100 ++++++++--
.../services/eks/EksStoredResourceArns.java | 77 ++++++++
.../floci/aws/services/eks/model/Cluster.java | 2 +-
.../services/eks/model/FargateProfile.java | 2 +-
.../aws/services/eks/model/Nodegroup.java | 2 +-
.../aws/services/iam/ResourceArnBuilder.java | 140 +-------------
.../resources/aws/iam-request-resources.json | 78 +++++++-
.../common/RequestResourceMembersTest.java | 10 +-
.../CloudFormationEksIntegrationTest.java | 6 +-
.../EksResourceTaggingIntegrationTest.java | 40 ++--
.../eks/EksStoredResourceArnsTest.java | 44 +++++
...amRestRouteEnforcementIntegrationTest.java | 77 +++++---
.../services/iam/ResourceArnBuilderTest.java | 173 +++++-------------
tools/aws/regen_iam_request_resources.py | 13 +-
19 files changed, 498 insertions(+), 353 deletions(-)
create mode 100644 src/main/java/io/floci/aws/services/eks/EksStoredResourceArns.java
create mode 100644 src/test/java/io/floci/aws/services/eks/EksStoredResourceArnsTest.java
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 6c80b03f372..d88213050e7 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -2332,7 +2332,7 @@ requests retain HTTP 403 XML `AccessDenied` responses, except SNS's, which retur
action is denied. The routed protocol determines the status, not just the request's content type.
A request is checked against the resources it names. Floci builds their ARNs itself for S3,
-DynamoDB, SSM, KMS, IAM, Resource Groups, EKS, API Gateway
+DynamoDB, SSM, KMS, IAM, Resource Groups, API Gateway
and CloudWatch Logs. For Secrets Manager, Elastic Load Balancing, ECR,
Step Functions, EventBridge, EventBridge Scheduler, Amazon Cognito user pools and identity pools, Amazon Data Firehose, Cloud
Map, ACM, CodePipeline, CodeBuild, Amazon Managed Service for Apache Flink (Kinesis Data Analytics v2),
@@ -2341,7 +2341,7 @@ AWS Data Exports, AWS Pricing Calculator, Cost Explorer, CloudTrail, Global Acce
Timestream for InfluxDB, Amazon Redshift, the Amazon Redshift Data API, AWS Payment Cryptography, AWS DataSync, Amazon EMR,
Amazon Rekognition, IAM Identity Center, Amazon Inspector, Amazon Macie, AWS Fault Injection Service, AWS Resource
Access Manager, CloudWatch Observability Access Manager, AWS Resource Explorer, AWS Account Management, AWS Control
-Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL and STS they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
+Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL, STS and Amazon EKS they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
operation's action, the resource types that action acts on with their ARN formats, and the request
members that name them: a member holding a resource's ARN, which counts when it matches the format
of a type the action acts on, or members filling the variables of a type's format. Nothing in it is
@@ -2560,26 +2560,24 @@ came from. `ListQueues`, and `CancelMessageMoveTask`, whose `TaskHandle` names n
`*`, so a grant scoped to a queue, or to the account's queues, does not allow cancelling a move task: it
takes a grant on `*`.
-An EKS request is checked in the caller's account, where EKS looks everything up. A cluster route is
-checked against the ARN EKS holds the cluster under, or `cluster/` in the request's Region for
-a cluster it does not hold, and `CreateCluster` against the cluster its body names, as the EKS user
-guide's example policy for creating a cluster grants it. A node group, Fargate profile, add-on,
-access entry or Pod Identity association route is checked against the ARN EKS holds that resource
-under, which ends in an id the request does not carry, so a policy names it with a wildcard, such as
-`nodegroup///*`; listing or creating them, and the other routes under a cluster, are
-checked against the cluster. A name holding an encoded `/` is read as one name, as EKS reads it.
-`DescribeUpdate` is checked against the add-on the update was made to, since the updates Floci keeps
-are its add-ons' and EKS returns one whether or not the request names its add-on, and otherwise
-against the cluster. An EKS tagging request is checked against the caller's own cluster named after
-the ARN's last `/`, whatever the ARN names before it, as EKS looks it up.
+An EKS request is checked on what the generated table reads from it, in the caller's account, where
+EKS looks everything up. A cluster route is checked against `cluster/`, the name its path gives,
+and `CreateCluster` against the cluster its body names, from a measured entry quoting the EKS user
+guide's example policy for creating a cluster, as the Service Reference lists no resource type for it.
+A node group, add-on or Fargate profile, whose ARN ends in an id EKS minted, is checked against the ARN
+EKS holds it under, found by the names its path gives in the request's Region, or with its names open
+when EKS holds none; an access entry, Pod Identity association, identity provider config or capability
+is checked with the parts of its ARN the request does not give open, so a policy names it with a
+wildcard, such as `access-entry//*`. Listing or creating them, and the other routes under a
+cluster, are checked against the cluster. An EKS tagging request is checked against the ARN its
+`/tags/{resourceArn}` carries, and EKS tags the resource whose ARN is that whole ARN.
The shared tagging routes, `/tags` and `/v1/tags`, hand a request to the service its ARN names,
-and it is checked as that service, against that ARN, or for EKS the cluster it tags, whatever scope
-it is signed with. The ARN is
+and it is checked as that service, against that ARN, whatever scope it is signed with. The ARN is
the one after `/tags/` or `/v1/tags/`, the body's `resourceArn` on `POST /tags`, and the
`resourceArn` query parameter on the other bare routes. A service whose resources the generated table reads
whole is served there only on the routes its model gives, as AWS, which tells these services apart by hostname,
-serves no other: EventBridge Scheduler, EMR Serverless, GuardDuty and Security Hub tag only on
+serves no other: EventBridge Scheduler, EMR Serverless, GuardDuty, Security Hub and EKS tag only on
`/tags/{resourceArn}`, the ARN encoded, and a request on the bare `/tags`, or naming an ARN whose `/` is not
encoded, is refused with `BadRequestException` ("Invalid resource ARN") and tags nothing.
@@ -3538,8 +3536,9 @@ floci populates:
subscriptions, Security Hub for its hubs and configuration policies, Control Tower for its landing zones and enabled
controls, GuardDuty for its detectors and Malware Protection plans, Cloud Map for its namespaces and services, Elastic
Load Balancing for its load balancers, target groups, listeners and rules and its Classic Load Balancers, SQS for its
- queues, SNS for its topics, Kinesis Data Streams for its streams and consumers, EventBridge Pipes for its pipes and
- Aurora DSQL for its clusters. Tag keys differing only in case are one condition key holding every value.
+ queues, SNS for its topics, Kinesis Data Streams for its streams and consumers, EventBridge Pipes for its pipes,
+ Aurora DSQL for its clusters and EKS for its clusters, node groups, Fargate profiles, add-ons, Pod Identity
+ associations and access entries. Tag keys differing only in case are one condition key holding every value.
- EC2 resource keys such as a network interface's `ec2:Vpc`, `ec2:Subnet`, `ec2:AvailabilityZone` and
`ec2:NetworkInterfaceID`: for every action on a resource EC2 holds, the members of the resource the
key names, an ARN for a key the Service Reference types as one. `resourceKeys` in
diff --git a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
index 7bf832155e7..e885fbe1291 100644
--- a/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
+++ b/src/main/java/io/floci/aws/core/common/StoredResourceArns.java
@@ -60,9 +60,10 @@
* Map, for the tags of a namespace or a service; Elastic Load Balancing, for the tags of a load balancer, a target
* group, a listener, a rule or a Classic Load Balancer; SQS, for the tags of a queue; SNS, for the tags of a topic;
* Kinesis Data Streams, for the tags of a stream or a consumer; EventBridge Pipes, for the tags of a pipe; Aurora DSQL,
- * for the tags of a cluster); looked up lazily by {@code ResourceArnBuilder} and {@code IamConditionContextResolver}
- * through {@code Instance} for the namespace a request or an ARN is of, so IAM never depends on
- * that service directly.
+ * for the tags of a cluster; EKS, for the tags of a cluster, a node group, a Fargate profile, an add-on, a Pod Identity
+ * association or an access entry); looked up lazily by {@code ResourceArnBuilder} and
+ * {@code IamConditionContextResolver} through {@code Instance} for the namespace a request or an
+ * ARN is of, so IAM never depends on that service directly.
*
* Each answer is a lookup of what the service holds, asked for by an entry of the generated table ({@code find},
* {@code through}, a default, {@code forwarded}, a type's {@code resourceTagKeys}): never a fact about what an operation acts on, which the table alone
diff --git a/src/main/java/io/floci/aws/services/eks/EksAccessEntryService.java b/src/main/java/io/floci/aws/services/eks/EksAccessEntryService.java
index 280bfd64bd0..3b9a293d600 100644
--- a/src/main/java/io/floci/aws/services/eks/EksAccessEntryService.java
+++ b/src/main/java/io/floci/aws/services/eks/EksAccessEntryService.java
@@ -305,6 +305,26 @@ public synchronized Optional