Skip to content

fix(ecs): honor task-set resource tags in IAM - #9086

Merged
pgermosen merged 3 commits into
floci-io:mainfrom
JimmyLiuJia:fix/8818-ecs-taskset-resource-tags
Nov 20, 2026
Merged

pgermosen merged 3 commits into
floci-io:mainfrom
JimmyLiuJia:fix/8818-ecs-taskset-resource-tags

Conversation

@JimmyLiuJia

Copy link
Copy Markdown
Contributor

Summary

Resolve ECS task-set tags from the complete task-set ARN during IAM resource-tag evaluation. Closes #8818.

Type of change

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

AWS Compatibility

CreateTaskSet accepts tags, and DeleteTaskSet is authorized against the named task set. The regression exercises the AWS JSON 1.1 request path and confirms that aws:ResourceTag/team=data permits deletion of that task set while denying deletion of a task set tagged team=web.

Checklist

  • ./mvnw test passes locally (focused IAM integration tests passed; the full suite was not run)

  • New integration test added

  • Commit message follows Conventional Commits

  • No more than 2 open, non-draft pull requests and no more than 4 open pull requests total in this repository

  • Controller return types remain reflection-safe

@qodo-code-review

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

Copy link
Copy Markdown

PR Summary by Qodo

Honor ECS task-set tags in IAM resource-tag conditions

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Resolve ECS task-set tags by full ARN during IAM resource-tag evaluation.
• Verify tagged task-set deletion succeeds while deletion of a differently tagged task set is
 denied.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • Fault-specific containment limits risk to the originating changed behavior.
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before: storedTags handled the existing ECS resource kinds but had no task-set branch.
  • After: it performs the same direct map lookup, exact-ARN filter, and tag extraction pattern for task sets.
  • The new correctness condition is that the requested task-set ARN must retrieve only the matching task set's tags; this is a local direct transformation using existing IAM condition resolution and existing task-set tag storage, with no new state machine, ordering protocol, migration, or coordinated invariant.
Potential damage 🟡 Medium 🩹 Temporary loss

  • Conservative damage bound for the originating changed behavior; downstream capabilities remain contained.
  • If tags are omitted or mismatched, a conditional allow depending on aws:ResourceTag can be denied for an eligible task set, temporarily preventing the supported authorization-controlled operation.
  • A wrong tag could instead affect the authorization decision for that named task set, but the exact-key and exact-ARN checks provide no source-supported path to borrowing another task set's tags.
  • Recovery is retrying after correcting the task-set lookup/state or using an independently authorized policy; reverting code removes the new lookup but does not repair any external authorization decision already made.
  • No persistent ECS state is changed by tag lookup itself.
  • Reversible through a code fix or corrected task-set state followed by a new request.
  • A denied request has no external side effect; if an incorrectly allowed delete were hypothetically caused by a wrong returned tag, the task set would need to be recreated or restored separately, which is not established as reachable by the inspected implementation.
Assessed commit 3673cf5
Diagram

graph TD
  Request["DeleteTaskSet request"] --> Resolver["IAM tag resolver"] --> ECS["ECS storedTags"] --> Store["Task-set map"] --> Check{"Team tag matches?"} -->|yes| Allow["Allow deletion"]
  Check -->|no| Deny["Deny deletion"]
Loading
High-Level Assessment

The targeted lookup fits the existing ECS storedTags dispatch and task-set ARN-keyed map. Reusing the broader resource search would add scanning without improving this IAM lookup.

Files changed (2) +62 / -5

Bug fix (1) +7 / -5
EcsService.javaExpose task-set tags to IAM by full ARN +7/-5

Expose task-set tags to IAM by full ARN

• Adds task sets to storedTags, retrieving the task set by its full ARN and checking that the stored ARN matches before returning its tags. Expands the method documentation to include task sets.

src/main/java/io/floci/aws/services/ecs/EcsService.java

Tests (1) +55 / -0
IamRequestResourceEnforcementIntegrationTest.javaCover tag-conditioned ECS task-set deletion +55/-0

Cover tag-conditioned ECS task-set deletion

• Creates two differently tagged task sets and applies an aws:ResourceTag/team condition to DeleteTaskSet. Exercises the ECS JSON 1.1 request path, asserting that deletion of the matching task set succeeds and deletion of the other is refused.

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

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Task sets cannot be retagged after creation 🐞 Bug ≡ Correctness
Description
The new storedTags branch reads task-set tags, but the sibling findByArn lookup and tag-resource
switches still omit TaskSet. Calling TagResource, UntagResource or ListTagsForResource with
a task-set ARN therefore returns a resource-not-found error, leaving tag-based policies tied to
creation-time values.
Code

src/main/java/io/floci/aws/services/ecs/EcsService.java[R3742-3743]

+            case "task-set" -> Optional.ofNullable(taskSets.get(arn))
+                    .filter(ts -> arn.equals(ts.getTaskSetArn())).map(TaskSet::getTags);
Relevance

●● Moderate

No close precedent for extending TagResource/UntagResource/ListTagsForResource to a new resource
type; a feature gap, not a trivial fix.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR extends one ECS resource-type enumeration to read task-set tags, but the sibling enumeration
used by all three tag APIs does not recognize task sets. The task-set ARN and tags are available
from creation, so this omission is on the same resource path.

src/main/java/io/floci/aws/services/ecs/EcsService.java[3690-3703]
src/main/java/io/floci/aws/services/ecs/EcsService.java[3742-3743]
src/main/java/io/floci/aws/services/ecs/EcsService.java[3764-3787]
src/main/java/io/floci/aws/services/ecs/EcsService.java[3796-3840]
src/main/java/io/floci/aws/services/ecs/EcsService.java[4667-4678]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new task-set tag reader has no matching task-set support in the ECS tag APIs, so tags cannot be changed or listed after creation.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3764-3787]
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3796-3840]
- src/test/java/io/floci/aws/services/iam/IamRequestResourceEnforcementIntegrationTest.java[835-860]
## Recommended Fix
Recognize task-set ARNs in `findByArn` and handle `TaskSet` in the tag getter and setter switches. Add a test that retags a task set through the ECS tag API and checks the resulting IAM resource-tag decision.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational

2. Full task-set ARNs bypass tag-based denies 🐞 Bug ⛨ Security
Description
storedTags looks up the exact task-set ARN, but the IAM resource definitions interpolate an
ARN-valued taskSet as a TaskSetId instead of resolving it to the stored resource. When a caller
supplies a full ARN accepted by the ECS handlers, IAM evaluates a malformed ARN without its tags, so
a conditional explicit Deny does not match and a broad Allow can authorize deletion or updates.
Code

src/main/java/io/floci/aws/services/ecs/EcsService.java[R3742-3743]

+            case "task-set" -> Optional.ofNullable(taskSets.get(arn))
+                    .filter(ts -> arn.equals(ts.getTaskSetArn())).map(TaskSet::getTags);
Relevance

● Weak

Recent dismissals flag the same IAM resource-mapping gap: exact stored-ARN tag lookups miss when the
IAM resource is built wrongly (kinesis consumer, EKS access entry).

PR-#8989
PR-#9070
PR-#8676

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new branch requires an exact map key. The IAM definitions fill TaskSetId from the request
without an arnOf mapping, although the ECS operations accept the full ARN; the resource
constructed for IAM therefore cannot retrieve the task set's tags.

src/main/java/io/floci/aws/services/ecs/EcsService.java[3742-3743]
src/main/resources/aws/iam-request-resources.json[1961-1961]
src/main/resources/aws/iam-request-resources.json[1974-1974]
src/main/resources/aws/iam-request-resources.json[2029-2029]
src/main/java/io/floci/aws/core/common/RequestResourceMembers.java[195-203]
src/main/java/io/floci/aws/services/ecs/EcsService.java[6731-6738]
src/main/java/io/floci/aws/services/ecs/EcsService.java[4849-4855]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
IAM constructs a malformed task-set resource when a request supplies a full task-set ARN, leaving the new tag lookup unable to enforce conditional denies.
## Fix Focus Areas
- src/main/resources/aws/iam-request-resources.json[1961-1961]
- src/main/resources/aws/iam-request-resources.json[1974-1974]
- src/main/resources/aws/iam-request-resources.json[2029-2029]
- src/test/java/io/floci/aws/services/iam/IamRequestResourceEnforcementIntegrationTest.java[852-860]
## Recommended Fix
Add `arnOf` mappings for the `taskSet` and `taskSets[]` members of DeleteTaskSet, UpdateTaskSet and DescribeTaskSets. Extend the IAM integration test to submit full task-set ARNs and verify that a tag-conditioned Deny overrides a broad Allow.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 21 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Security-sensitive IAM authorization fix warrants a careful standard review.

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

Comment on lines +3742 to +3743
case "task-set" -> Optional.ofNullable(taskSets.get(arn))
.filter(ts -> arn.equals(ts.getTaskSetArn())).map(TaskSet::getTags);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Task sets cannot be retagged after creation 🐞 Bug ≡ Correctness

The new storedTags branch reads task-set tags, but the sibling findByArn lookup and tag-resource
switches still omit TaskSet. Calling TagResource, UntagResource or ListTagsForResource with
a task-set ARN therefore returns a resource-not-found error, leaving tag-based policies tied to
creation-time values.
Agent Prompt
## Issue description
The new task-set tag reader has no matching task-set support in the ECS tag APIs, so tags cannot be changed or listed after creation.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3764-3787]
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3796-3840]
- src/test/java/io/floci/aws/services/iam/IamRequestResourceEnforcementIntegrationTest.java[835-860]
## Recommended Fix
Recognize task-set ARNs in `findByArn` and handle `TaskSet` in the tag getter and setter switches. Add a test that retags a task set through the ECS tag API and checks the resulting IAM resource-tag decision.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. I checked the operation-specific ECS references and the pinned botocore 1.43.118 model. TagResource and UntagResource list capacity providers, tasks, services, task definitions, clusters, and container instances; ListTagsForResource also omits task sets, while CreateTaskSet accepts tags. The Service Authorization Reference currently lists task-set for the tagging actions, so AWS's references conflict. I kept #9086 scoped to the creation-time tags used by DeleteTaskSet's aws:ResourceTag condition instead of adding runtime retag/list/untag behavior the operation references do not list.

The focused JDK 25 task-set IAM regression passed 1/1 on this head. I did not run the full suite or live AWS. Current-head CI is 26 passed and 2 skipped; human review is still required.

@pgermosen pgermosen added bug Something isn't working ecs Amazon Elastic Container Service (ECS) iam AWS Identity and Access Management (IAM) labels Nov 20, 2026
@JimmyLiuJia

Copy link
Copy Markdown
Contributor Author

On Qodo finding 2 in the summary above, I added a full-ARN DeleteTaskSet regression in 7b409f8. With a broad Allow and an aws:ResourceTag/team=data explicit Deny, deletion of the tagged task set by full ARN is denied; a differently tagged task set can still be deleted by full ARN under the same policy. RequestResources.fill retains the caller's exact ARN before rendering the generated resource pattern, so the tag lookup sees the stored tags. I did not change the production IAM mapping.

The focused JDK 25 test passed (1/1) and Checkstyle passed. I have not exercised UpdateTaskSet through its public handler or run live AWS. The new head is Verified; CI is still running and human review is pending.

@JimmyLiuJia

Copy link
Copy Markdown
Contributor Author

The new head is blocked by shard 4: SmtpRelayTest.relayRaw_nestingThatParsesButOverflowsTheWriter_isSkippedNotThrown gets a null parsed MIME message before the relay runs. This revision only adds the task-set IAM regression; shard 4 passed on the previous head. The failing SES method passes locally on JDK 25, both alone (1/1) and with its full class (52/52). The test uses a fixed 10,000-layer MIME depth, so the parser/writer boundary appears stack-sensitive across JVMs. Could a maintainer rerun the failed job? CI on this head is still red, and human review is pending.

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JimmyLiuJia thanks, storedTags now answers a task-set ARN with the tags the task set was created with, so an aws:ResourceTag condition on DeleteTaskSet reads them, and the test shows the team=data set deleted and the team=web one refused.

The full-ARN case you added covers the other way in: a task set named by its ARN still has its tags looked up, so the team=data Deny holds and the team=web set can still be deleted.

@pgermosen
pgermosen merged commit 3991e5c into floci-io:main Nov 20, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ecs Amazon Elastic Container Service (ECS) iam AWS Identity and Access Management (IAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] IAM: aws:ResourceTag conditions see no tags on EMR sessions and ECS task sets

2 participants