Skip to content

fix(iam): check EKS requests on the resources the generated table gives them - #9070

Merged
pgermosen merged 1 commit into
mainfrom
fix/iam-eks-request-resources
Nov 20, 2026
Merged

pgermosen merged 1 commit into
mainfrom
fix/iam-eks-request-resources

Conversation

@pgermosen

@pgermosen pgermosen commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

EKS was one of the namespaces ResourceArnBuilder built by hand: it 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. iam-request-resources.json held no EKS operation, and nothing gave a policy condition an EKS resource's tags, so aws:ResourceTag/ on a cluster, node group or add-on saw none. It now comes from the generated table, as every namespace is meant to.

  • EKS is read from the table. eks moves from HAND_BUILT to NAMESPACES, 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 as access-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.
  • CreateCluster stays on the cluster its body names, from 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 allowing eks:CreateCluster on arn: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".
  • Where the table reads less than the hand builder did. The hand builder looked up the full ARN of an access entry and a Pod Identity association, and checked an update on the add-on it was made to. Neither botocore nor the Service Reference ties an access entry's principal identity, an association's id or an update's add-on to those ARNs' variables, so the table checks an access entry as access-entry/<cluster>/*, an association as podidentityassociation/<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 an aws: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.
  • EKS only looks up. EksStoredResourceArns answers eks: find returns the ARN EKS holds a node group, add-on or Fargate profile under, found by EksService.findResourceArn as the handlers find it, in the request's Region; storedTags reads 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's EksService dependency.
  • Tagging, made safe to read. EKS's tag changes now take one lock, and a cluster, node group or Fargate profile gets a new map whose tags field 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/extra tagged the cluster prod while naming a different resource.
  • EKS's tagging route. With EKS read from its model, the shared tags controller serves its tagging on /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 with BadRequestException ("Invalid resource ARN") and tags nothing. EksResourceTaggingIntegrationTest and CloudFormationEksIntegrationTest, which sent the ARN unencoded, now send it as the SDKs do.
  • Only this namespace. The table keeps every other namespace's entries as they were, and make iam-request-resources-check passes on it.
  • Tests. ResourceArnBuilderTest's EKS cases, which drove the hand builder, now drive the table through EksStoredResourceArns: 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. IamRestRouteEnforcementIntegrationTest checks 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. EksStoredResourceArnsTest reads tags by a whole ARN and asks EKS nothing for one with a part left open. RequestResourceMembersTest lets MEASURED give 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. docs/services/iam.md moves 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; StoredResourceArns says so.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

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 test passes 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)
  • New or updated integration test added
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository (maintainers and dependency bots are exempt).

@pgermosen pgermosen added bug Something isn't working eks Amazon Elastic Kubernetes Service (EKS) iam AWS Identity and Access Management (IAM) labels Nov 20, 2026
@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Check EKS IAM requests against generated resource targets

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Move EKS authorization from hand-built path handling to the generated request-resource table.
• Resolve stored EKS ARNs and tags so resource-scoped policies and tag conditions check the intended
 targets.
• Preserve cluster-scoped CreateCluster grants and test changed authorization and tagging behavior.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: EKS IAM authorization and tagging integration.
  • This is the end-to-end authorization behavior for EKS API operations: the request-resource table and EKS lookup provider determine the IAM resource, which the IAM enforcement path uses before the EKS operation.
  • The table, provider, and request handler are implementation hops of the same bounded EKS authorization integration, not separate capabilities.
  • The same end-to-end EKS authorization capability covers both false allows and false denies; ARN construction and lookup are shared decision inputs to the IAM evaluator.
  • Tag mutation and tag-conditioned authorization are two user-visible outcomes of the same bounded EKS tagging integration: the resource record is updated, then the IAM condition provider reads that resource's tags.
  • They span several components but not independent functional domains.
  • The separate taggable resource types are implementations of this one EKS tag behavior.
Sources

src/main/java/io/floci/aws/services/eks/EksStoredResourceArns.java[66-75]

    public Map<String, String> storedTags(String arn) {
        if (!AwsArnUtils.isArnFor(arn, NAMESPACE) || arn.indexOf('*') >= 0) {
            return Map.of();
        }
        AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
        String account = regionResolver.getAccountId();
        if (!parsed.accountId().equals(account) || parsed.region().isBlank()) {
            return Map.of();
        }
        return StoredResourceArns.withEmptyValues(eks.tagsInAccount(account, arn));

src/main/java/io/floci/aws/services/eks/EksService.java[1844-1851]

     * access entry ARN; each child ARN names its cluster as the segment after the resource type, and the
     * resource found is the one whose ARN is the whole of {@code resourceArn}. One change at a time, each
     * giving the resource a new map, so a lookup that takes no lock reads one whole set.
     */
    private Map<String, String> retag(String resourceArn, UnaryOperator<Map<String, String>> edit) {
        synchronized (tagLock) {
            return retagHoldingLock(resourceArn, edit);
        }
Behavioral complexity 🔴 High 🧩 Concurrent ordering, Coordinated invariants

  • Before: tag mutation and IAM tag lookup were not connected through the new account-scoped provider and did not have the new shared tag-update serialization protocol.
  • After: tag changes are serialized under tagLock, each mutation publishes a new map, model fields for several resources are volatile, and the IAM provider reads account-scoped records and matches the complete ARN.
  • New correctness conditions are that concurrent tag edits cannot lose one another, readers see a complete map rather than a partial mutation, and the resource selected for IAM conditions is exactly the resource selected by the tag handler across all resource types and accounts.
  • The lock and volatile fields are established mechanisms, but their combination with new cross-component reads creates a new ordering and identity invariant.
Sources

src/main/java/io/floci/aws/services/eks/EksStoredResourceArns.java[66-75]

    public Map<String, String> storedTags(String arn) {
        if (!AwsArnUtils.isArnFor(arn, NAMESPACE) || arn.indexOf('*') >= 0) {
            return Map.of();
        }
        AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
        String account = regionResolver.getAccountId();
        if (!parsed.accountId().equals(account) || parsed.region().isBlank()) {
            return Map.of();
        }
        return StoredResourceArns.withEmptyValues(eks.tagsInAccount(account, arn));

src/main/java/io/floci/aws/services/eks/EksService.java[1844-1851]

     * access entry ARN; each child ARN names its cluster as the segment after the resource type, and the
     * resource found is the one whose ARN is the whole of {@code resourceArn}. One change at a time, each
     * giving the resource a new map, so a lookup that takes no lock reads one whole set.
     */
    private Map<String, String> retag(String resourceArn, UnaryOperator<Map<String, String>> edit) {
        synchronized (tagLock) {
            return retagHoldingLock(resourceArn, edit);
        }

src/main/java/io/floci/aws/services/eks/EksAddonService.java[548-552]

    Optional<Map<String, String>> tagsInAccount(String account, Cluster cluster, String addonName, String addonArn) {
        return AccountAwareStorageBackend.readInAccount(storage, account,
                        prefix(cluster) + addonName.toLowerCase(Locale.ROOT))
                .filter(stored -> addonArn.equals(stored.addon().addonArn()))
                .map(stored -> stored.addon().tags());
Potential damage 🔴 High 🩹 Integrity

  • If a wrong lookup or fallback broadens a resource to a cluster-level or wildcard ARN, a principal may pass IAM authorization for an EKS mutation that should have been denied.
  • Reverting the code restores future authorization decisions, but any unauthorized cluster or child-resource mutation already performed must be separately inspected and repaired; code rollback does not undo external EKS effects.
  • This is a plausible failure of the changed authorization mapping, not a claim that every operation is broadened.
  • Future requests are recoverable by reverting or correcting the table/provider.
  • Already-performed unauthorized EKS changes require resource-specific inspection and manual or API-level compensation.
Assessed commit 96d0a87
Diagram

graph TD
  R["EKS request"] --> B["Resource builder"] --> T["Generated table"] --> L["Stored ARN lookup"] --> S["EKS state"]
  L --> C["Condition context"] --> P["IAM evaluation"]
  B --> P
Loading
High-Level Assessment

Using the existing generated-table and StoredResourceArns extension points is preferable to expanding the EKS-specific builder: it keeps operation-to-resource rules in one place while allowing EKS to supply the stored ARNs and tags the table cannot derive. The documented wildcard targeting for identifiers absent from requests is an important policy-compatibility change to review.

Files changed (16) +389 / -323

Enhancement (4) +117 / -0
EksAccessEntryService.javaExpose account-scoped access-entry tags +20/-0

Expose account-scoped access-entry tags

• Adds a lookup that reads an access entry's tags in the specified account and matches its complete ARN.

src/main/java/io/floci/aws/services/eks/EksAccessEntryService.java

EksAddonService.javaExpose account-scoped add-on tags +11/-0

Expose account-scoped add-on tags

• Adds a stored add-on tag lookup by cluster and name, guarded by an exact ARN match.

src/main/java/io/floci/aws/services/eks/EksAddonService.java

EksPodIdentityAssociationService.javaExpose account-scoped association tags +12/-0

Expose account-scoped association tags

• Adds a stored Pod Identity association tag lookup by ID and complete ARN in the specified account.

src/main/java/io/floci/aws/services/eks/EksPodIdentityAssociationService.java

EksStoredResourceArns.javaConnect EKS resources to IAM's stored-resource interface +74/-0

Connect EKS resources to IAM's stored-resource interface

• Resolves stored node group, add-on, and Fargate profile ARNs by name in the request Region. Supplies account-scoped tags for supported EKS resources to IAM conditions.

src/main/java/io/floci/aws/services/eks/EksStoredResourceArns.java

Bug fix (4) +52 / -8
EksService.javaRead EKS resource tags and serialize tag changes +49/-5

Read EKS resource tags and serialize tag changes

• Adds account-scoped, whole-ARN tag lookups for supported EKS resources. Serializes tag changes and requires an exact cluster ARN before tagging it.

src/main/java/io/floci/aws/services/eks/EksService.java

Cluster.javaPublish cluster tag-map replacements safely +1/-1

Publish cluster tag-map replacements safely

• Makes the cluster's tags field volatile so readers can observe complete replacement maps.

src/main/java/io/floci/aws/services/eks/model/Cluster.java

FargateProfile.javaPublish Fargate profile tag-map replacements safely +1/-1

Publish Fargate profile tag-map replacements safely

• Makes the Fargate profile's tags field volatile for readers of replacement maps.

src/main/java/io/floci/aws/services/eks/model/FargateProfile.java

Nodegroup.javaPublish node group tag-map replacements safely +1/-1

Publish node group tag-map replacements safely

• Makes the node group's tags field volatile for readers of replacement maps.

src/main/java/io/floci/aws/services/eks/model/Nodegroup.java

Refactor (1) +3 / -137
ResourceArnBuilder.javaRemove hand-built EKS authorization targets +3/-137

Remove hand-built EKS authorization targets

• Deletes EKS path-based ARN construction and its direct EKS service dependency. EKS requests now follow the existing generated-table resource path.

src/main/java/io/floci/aws/services/iam/ResourceArnBuilder.java

Tests (3) +110 / -150
RequestResourceMembersTest.javaAccount for measured creates and multi-member lookups +8/-2

Account for measured creates and multi-member lookups

• Adjusts generated-table assertions for CreateCluster's measured resource target and resources whose stored lookup requires multiple request members.

src/test/java/io/floci/aws/core/common/RequestResourceMembersTest.java

IamRestRouteEnforcementIntegrationTest.javaExercise table-driven EKS policy enforcement +53/-24

Exercise table-driven EKS policy enforcement

• Tests EKS resource-tag conditions, wildcard-scoped entries and associations, and updated add-on and update targets. Verifies tagging uses the supplied ARN and rejects tagging a resource through another account's ARN.

src/test/java/io/floci/aws/services/iam/IamRestRouteEnforcementIntegrationTest.java

ResourceArnBuilderTest.javaReplace EKS path-builder tests with table-driven tests +49/-124

Replace EKS path-builder tests with table-driven tests

• Tests cluster and CreateCluster targets, stored node group and add-on ARNs, missing-resource fallback, Region handling, and encoded tagging ARNs through the generated-table path.

src/test/java/io/floci/aws/services/iam/ResourceArnBuilderTest.java

Documentation (2) +22 / -22
iam.mdDocument generated EKS authorization and tag conditions +18/-19

Document generated EKS authorization and tag conditions

• Moves EKS into the documented table-driven services. Explains resource matching, wildcard ARN portions, tagging routes, and EKS resource-tag condition support.

docs/services/iam.md

StoredResourceArns.javaDocument EKS stored-resource tag support +4/-3

Document EKS stored-resource tag support

• Adds EKS resources to the interface documentation for service-specific stored ARN and tag lookups.

src/main/java/io/floci/aws/core/common/StoredResourceArns.java

Other (2) +85 / -6
iam-request-resources.jsonAdd generated resource mappings for EKS operations +74/-4

Add generated resource mappings for EKS operations

• Moves EKS from hand-built to table-covered namespaces and adds resource mappings for its 70 operations. Includes cluster-scoped CreateCluster, stored-resource lookups, wildcard ARN portions, and tagging-route ARN targets.

src/main/resources/aws/iam-request-resources.json

regen_iam_request_resources.pyGenerate EKS mappings and preserve scoped CreateCluster +11/-2

Generate EKS mappings and preserve scoped CreateCluster

• Moves EKS into generated namespaces and removes it from hand-built namespaces. Adds a documented measured CreateCluster mapping because the Service Reference omits its cluster resource type.

tools/aws/regen_iam_request_resources.py

@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Tagged access entries fail policy checks ✗ Dismissed
Description
The new table renders access-entry and Pod Identity association requests with a wildcard in place of
the resource-specific ARN, while storedTags() returns tags only for an ARN matching a stored
record exactly. For an existing entry or association, an aws:ResourceTag/* Allow or Deny condition
on its ordinary API actions therefore receives no resource tags and cannot match.


Remediation recommended

2. Access-entry checks scan every account ✗ Dismissed
Description
EksAccessEntryService.tagsInAccount calls entries.keys() and walks its result to find one ARN,
while that storage method first enumerates keys across every account. IAM requests checked on
access-entry resources now invoke this lookup for resource-tag context, so their work grows with the
entire access-entry store even when the requested account has few entries.

3. Add-on-scoped grants no longer allow updating add-ons ✗ Dismissed
Description
The generated eks:UpdateAddon entry, like eks:DeleteAddon, always adds a
podidentityassociation resource filled only from ClusterName
(podidentityassociation/<cluster>/*), whether or not the request or the add-on involves any Pod
Identity association. IamEnforcementFilter requires every produced resource to be allowed, so a
policy that grants eks:UpdateAddon or eks:DeleteAddon only on addon/<cluster>/* is now denied
for every add-on, including one with no associations; the PR description mentions this for
DeleteAddon only, not UpdateAddon.

4. Tag reads copy the tag writer's lookup ✓ Resolved

Resolving commit: 96d0a87

Resolution reason
The commit introduces a shared private helper taggable(type, clusterKey, name, arn, reads) that
performs the keyed read plus whole-ARN filter for cluster, nodegroup and fargateprofile. Both the
tag writer (retag path, now .map(found -> applyTags(found.tags(), change, found.retag()))) and the
tag reader (tagsInAccount, now .map(Taggable::tags)) call this helper, so the two paths can no
longer diverge. Only the mutation (setTags + storage put) remains in the writer's closure. This
matches the suggested fix's approach, with a TaggableReads record to inject account-aware lookups.
Also adds a '*' guard in EksStoredResourceArns.storedTags.
Description
EksService.tagsInAccount repeats the per-type lookup that retag/retagHoldingLock already
performs for clusters, node groups and Fargate profiles: a keyed storage get followed by a whole-ARN
filter. Because the two copies must agree on which ARN identifies a resource, a later change to one
path, such as the whole-ARN rule added to the cluster case in retag, would silently leave the
other reading tags from a different resource than the one written.

Grey Divider

Context sources
✅ Compliance rules (platform): 21 rules
✅ Web pages:
  +5 more
✅ Cross-repo context — repo relationships
  Explored: repo: floci-io/floci-labs (sha: c6c6bb16) — View relationship
✅ Context preparation
  Past issues: summarized; full text retained for this review
Review mode: Auto: 🧠 Deep: IAM resource mapping spans EKS paths, locks, and tagging semantics.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working eks Amazon Elastic Kubernetes Service (EKS) iam AWS Identity and Access Management (IAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant