Repository navigation
fix(iam): check EKS requests on the resources the generated table gives them - #9070
Conversation
PR Summary by QodoCheck EKS IAM requests against generated resource targets
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
…es 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.
dbb9e9d to
96d0a87
Compare
Summary
EKS was one of the namespaces
ResourceArnBuilderbuilt by hand: it walked an EKS path, looked each resource up throughEksService, and checked a tagging route on the caller's cluster named after the ARN's last segment.iam-request-resources.jsonheld no EKS operation, and nothing gave a policy condition an EKS resource's tags, soaws:ResourceTag/on a cluster, node group or add-on saw none. It now comes from the generated table, as every namespace is meant to.eksmoves fromHAND_BUILTtoNAMESPACES, and the generator's existing rules give each of its 70 operations what botocore's REST model and the Service Reference give it: the cluster its path names, the node group, add-on or Fargate profile its cluster and name find, the ARN a tagging route carries, and the parts of an ARN the request does not give open, so an access entry, Pod Identity association, identity provider config or capability is checked asaccess-entry/<cluster>/*and the like. Listing clusters, registering one and the account-wide reads act on no resource type and are checked on*, as before.MEASURED. The Service Reference lists no resource type for it, so the rules alone would check it on*, and a policy granting it on one cluster, as the EKS user guide's own example does, would stop matching. The entry quotes the guide's identity-based policy examples: "This example policy includes the minimum permissions required to create an Amazon EKS cluster named my-cluster in the us-west-2 AWS Region", its statement allowingeks:CreateClusteronarn:aws:eks:us-west-2:111122223333:cluster/my-cluster, and "If you see a warning that says The actions in your policy do not support resource-level permissions ... it can be safely ignored".access-entry/<cluster>/*, an association aspodidentityassociation/<cluster>/*, and an update on its cluster unless the request names the add-on, capability or node group. A policy naming one entry's or one association's full ARN therefore no longer matches, for an Allow or a Deny; it names them with a wildcard. For the same reason anaws:ResourceTag/condition on an access entry's or an association's own actions reads no tags, so such an Allow does not apply and such a Deny does not match; their tagging routes, which carry the whole ARN, read them. UpdateAddon and DeleteAddon are also checked on the cluster's Pod Identity associations,podidentityassociation/<cluster>/*, which the Service Reference lists for both beside the add-on, so a policy granting them on add-ons alone no longer allows them.EksStoredResourceArnsanswerseks:findreturns the ARN EKS holds a node group, add-on or Fargate profile under, found byEksService.findResourceArnas the handlers find it, in the request's Region;storedTagsreads the tags of a cluster, node group, Fargate profile, add-on, Pod Identity association or access entry in the request's account, in place, matched on the whole ARN each records; an ARN with a part left open names none and is not looked up. EKS keys an access entry by its cluster and principal, which its ARN does not give whole, so a whole access-entry ARN, which reaches IAM only on a tagging route, is found by walking the stored entries, as the TagResource handler then finds it. Tag changes and tag reads find a cluster, node group or Fargate profile through one lookup, so they agree on which resource an ARN names.ResourceArnBuilder's EKS section is gone, and with it the builder'sEksServicedependency.tagsfield is volatile, so a lookup that takes no lock reads one whole set; the add-on, association and access entry records were already replaced whole under their services' locks. A cluster is tagged only when its ARN is the whole ARN the request names, as node groups and Fargate profiles already were:cluster/prod/extratagged the clusterprodwhile naming a different resource./tags/{resourceArn}alone, as it does Scheduler's: the ARN encoded as one path segment, as the SDKs send it. A path naming an ARN whose/is not encoded, or the bare/tags, is refused withBadRequestException("Invalid resource ARN") and tags nothing.EksResourceTaggingIntegrationTestandCloudFormationEksIntegrationTest, which sent the ARN unencoded, now send it as the SDKs do.make iam-request-resources-checkpasses on it.ResourceArnBuilderTest's EKS cases, which drove the hand builder, now drive the table throughEksStoredResourceArns: a cluster route, a cluster's list route and ListClusters, CreateCluster on its body's cluster, a node group and an add-on EKS holds, one it holds none of and one held in another Region, and a tagging route's ARN.IamRestRouteEnforcementIntegrationTestchecks an allow on a team's tag against two tagged clusters; its EKS cases now pin what the table checks: a Fargate profile and an add-on on their held ARNs, an update on its cluster, an access entry and an association with a wildcard, an access entry's policy routes on the cluster's entries, a tagging route on the ARN it carries with another account's ARN tagging nothing, and DeleteAddon's scoped waiter granted the cluster's associations too.EksStoredResourceArnsTestreads tags by a whole ARN and asks EKS nothing for one with a part left open.RequestResourceMembersTestletsMEASUREDgive a create acting on no type its resource, and expects a resource its service finds by several members only from a request giving them all, as the reader reads it.docs/services/iam.mdmoves EKS from the services whose ARNs Floci builds itself to those the table gives, rewrites its paragraph to say what the table checks, drops its exception from the shared tagging routes, and names it among those that answer stored tags;StoredResourceArnssays so.Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
The Service Authorization Reference gives EKS ten resource types, each with
aws:ResourceTag/${TagKey}. A condition such as"StringEquals": {"aws:ResourceTag/team": "data"}on an EKS action now reads the tags of the cluster, node group, Fargate profile, add-on, Pod Identity association or access entry the request names; before, it saw none, so such an Allow never applied and such a Deny never matched. botocore models EKS's tagging only on/tags/{resourceArn}.Checklist
./mvnw testpasses locally (ran the generator's tests, the request resource reader, builder, filter and tag dispatcher tests, the EKS unit tests, every EKS integration test class that needs no Docker,CloudFormationEksIntegrationTest, and the REST route, request resource and PassRole enforcement test classes, not the whole suite; the EKS classes that need Docker are left to CI)