Skip to content

fix(cloud): deny ec2:DescribeTags in the launcher IAM policy - #16276

Merged
iamwhatever merged 1 commit into
mainfrom
fix/cloud-deny-describetags
Oct 3, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/cloud-deny-describetags

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A leaked EC2 launcher credential can no longer read the free-text tag values of every resource in the account.

policy_document() in src/kiro_crew/cloud/iam.py grants ec2:Describe* on * and then cuts the secret-bearing Describe calls back out (DenyForeignUserData, DenySecretReads). ec2:DescribeTags is in neither, so the launcher policy allows an account-wide read of every EC2 resource's tag keys and values, which are free text and can hold anything an operator typed.

Why it matters

The launcher policy is what operators attach to the credential that runs kirocrew cloud. If that credential leaks, DescribeTags hands out tag values across the whole account with no resource scoping. An independent audit rated this MEDIUM.

Not a goal

  • Denying ec2:DescribeInstances: it also returns tags, but the launcher and CloudFormation need it.
  • Any change to IamInstanceBoundaryCreateOnce, PassRole scoping, or any other statement.
  • Re-shaping the policy to win back size headroom.

What changed (motivation → approach → change)

  • Symptom: ec2:DescribeTags is allowed account-wide by the ec2:Describe* wildcard.
  • Root cause: DenySecretReads enumerates the secret-bearing Describe calls, and DescribeTags was not on the list.
  • Does the product need it? No. There is no describe_tags / describe-tags / DescribeTags anywhere in the repo. The cloud code drives the AWS CLI through cloud.aws.run_aws (no boto3); instance discovery uses resourcegroupstaggingapi get-resources (tag:GetResources) and ec2 describe-instances. The pinned CloudFormation handler-permission schema (test/fixtures/cfn_schema_handler_permissions.json, covering every resource type in the template) lists no ec2:DescribeTags.
  • Change: add ec2:DescribeTags to the EXISTING DenySecretReads action list. No new statement. The comments beside the Deny and beside ec2:Describe*, and docs/system-specs/modules/cloud.md, now name it.
  • Size: the action costs 19 chars, which would put the compact policy at 6,045, 1 over the 6,044 headroom gate. The gate is not loosened. The room comes from two Sids that no test, doc or code names: SsmSessionControlAndRead → SsmStatusRead and SsmAmiParameter → SsmAmi. A Sid carries no permission, and the permission-set test ignores Sids. The compact policy is 6,025 chars, 1 under its size before this PR.

Backwards compatibility

Compatible: no CLI path or CloudFormation handler calls ec2:DescribeTags, so every launch, list and teardown that works today keeps working.

The diff tightens a permission, so its readers:

Reader: src/kiro_crew/cloud/ec2.py:list_instances -- entry: chat|cron|release (kirocrew cloud list) -- uses tag:GetResources and is unaffected by an ec2 Deny
Reader: src/kiro_crew/cloud/ec2.py:_instance_state -- entry: chat|release (kirocrew cloud status) -- uses ec2:DescribeInstances, still allowed; test_account_wide_tag_reads_denied_but_instance_reads_allowed
Reader: CloudFormation EC2 handlers (AWS::EC2::Instance, SecurityGroup, SecurityGroupIngress) -- entry: release (kirocrew cloud launch) -- schema lists no DescribeTags; test/test_cloud_iam_cfn_schema.py checks every listed permission against the policy

Tests

  • test/test_cloud_iam_cfn_schema.py::test_account_wide_tag_reads_denied_but_instance_reads_allowed (new): pins ec2:DescribeTags denied AND ec2:DescribeInstances still allowed, through the module's IAM evaluator. Revert-verified: with src/kiro_crew/cloud/iam.py restored to origin/main and the test kept, it fails (assert not True); with the patch it passes.
  • test/test_cloud_iam.py: EXPECTED_PERMISSION_DELTA_ADDED gains the new Deny tuple; the 6,044 headroom gate and 6,144 cap are unchanged and pass.
  • python3 -m pytest test/test_cloud_iam.py test/test_cloud_iam_cfn_schema.py: 203 passed. black (py310) and flake8 clean on the three Python files.

Manual verification

N/A — no AWS API was called. The policy is a static document; the unit tests evaluate it in-process and pin its size and its effective permission set.

Related Issues

N/A — from an internal security audit.

Pattern harvest

Rule candidate: review-prompt
Pattern: an Allow on a service Describe* / Get* / List* wildcard must be checked against every action that wildcard covers which returns free text or secrets, not only the ones already known; each such action needs an explicit Deny.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@iamwhatever
iamwhatever requested a review from a team as a code owner October 2, 2026 21:53
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify one live kirocrew cloud launch/teardown before the next release — the Deny's compatibility rests on the pinned CFN handler schemas being complete.

[DESIGN-REVIEWED] 6dca330

Description read

[DESCRIPTION-READ] b428d70f62706b5c8c8d13c13b2aeb0a54ccc1ae9cdcf8b4e4504b673244ed41

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Run one real kirocrew cloud launch: "handlers don't call DescribeTags" rests on the published CFN schema fixture; no AWS API was exercised.

Not justified as shipped

  • Item 2 — rides along: Sid SsmSessionControlAndRead → SsmStatusRead is not the fix; it buys the 19 chars back under the pinned 6,044 gate (test_cloud_iam.py:630) without loosening it. Grepped SsmSessionControlAndRead|SsmAmiParameter: only the pre-shrink snapshot fixture names them, and the permission-set test flattens without Sids, so nothing consumes the old names.
  • Item 3 — rides along: Sid SsmAmiParameter → SsmAmi, same size-gate reason, same zero consumers.

What this change ships

Inventory (5 items) — 3 justified

Intent: a leaked launcher credential can no longer dump every EC2 resource's free-text tag values — a FIX (the new test fails on base: ec2:Describe* allows DescribeTags with no deny).

  1. Launcher policy now denies ec2:DescribeTags account-wide — justified
  2. Printed policy's SSM status statement renamed SsmStatusRead — rides along (size-gate headroom)
  3. Printed policy's AMI-parameter statement renamed SsmAmi — rides along (size-gate headroom)
  4. New test pins DescribeTags denied while DescribeInstances stays allowed — justified
  5. cloud.md and in-policy comments name the new deny — justified

Grepped describe_tags|describe-tags|DescribeTags: zero runtime consumers (hits only in the policy, docs and tests this diff touches). Residual tag reads via DescribeInstances are declared under ## Not a goal.

[FIRST-PRINCIPLES-REVIEWED] 6dca330

Description read

[DESCRIPTION-READ] a03f47737cefb2bd4c7e3cb6405620375ac7249848e6bfdb3de8c1d56fad4fec

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6dca330

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6dca330

Verdict parsed from the review's SHA-scoped output markers for commit 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 6dca3308dad7f13c3ea2094daf1b8b7f26ba6f20: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the fix/cloud-deny-describetags branch from 50c7937 to b7bcf33 Compare October 2, 2026 22:11
The launcher policy grants ec2:Describe* account-wide and cuts the
secret-bearing Describe calls back out in DenySecretReads. DescribeTags
was not among them, so a leaked launcher credential could list the
free-text tag values of every resource in the account.

Neither the CLI nor the CloudFormation handlers call DescribeTags:
instance discovery uses tag:GetResources and DescribeInstances, and the
pinned CFN handler-permission schema lists no DescribeTags. Add it to the
existing DenySecretReads action list (no new statement).

The action costs 19 chars. The 6,044 headroom gate stays as it is; the
room comes from two Sids no test or doc names: SsmSessionControlAndRead
becomes SsmStatusRead and SsmAmiParameter becomes SsmAmi. A Sid carries
no permission. The compact policy is 6,025 chars.
@iamwhatever
iamwhatever force-pushed the fix/cloud-deny-describetags branch from b7bcf33 to 6dca330 Compare October 2, 2026 22:15
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition for the Opus 5 advisory finding on 50c7937d48 (no [BLOCK-MERGE]): acknowledged, not changed in this PR.

The finding is correct that tags stay readable through two other grants: tag:GetResources on * (which kirocrew cloud list uses to discover instances) and ec2:DescribeInstances (which status and CloudFormation need). This PR's goal is narrower: close the one EC2 call that lists tag values for every EC2 resource type with no use by the product. Neither of the other two is in scope here, and narrowing tag:GetResources would need its own design because the discovery path depends on it.

The comment beside DenySecretReads describes what DescribeTags returns; it does not claim tag values become unreadable account-wide. If a maintainer wants the tag:GetResources exposure tracked, it belongs in a separate issue.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 2, 2026
@iamwhatever
iamwhatever enabled auto-merge October 2, 2026 23:55

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Adds ec2:DescribeTags to the existing DenySecretReads Deny in the launcher policy (src/kiro_crew/cloud/iam.py:886-894). This closes the account-wide tag-value read that the ec2:Describe* on * Allow had been granting. Two Sids are renamed (SsmSessionControlAndRead → SsmStatusRead, SsmAmiParameter → SsmAmi) to stay under the 6,044-char headroom gate. The spec docs/system-specs/modules/cloud.md:485 is updated in the same commit.

Verified (head 6dca330)

  • Deny shape. Effect: Deny, Action includes ec2:DescribeTags, Resource: "*", and there is no Condition. It is unconditional, and an explicit Deny cannot be overridden by the ec2:Describe* Allow. The new test test_account_wide_tag_reads_denied_but_instance_reads_allowed runs the module's IAM evaluator and confirms DescribeTags is denied while DescribeInstances is still allowed.
  • No caller needs DescribeTags. A case-insensitive grep for describe[-_]?tags across the worktree finds only the policy, the spec and the tests. The agent CLI allowlist (src/kiro_crew/cloud/aws.py:100-106) has no describe-tags. The ec2 calls in cloud/ec2.py, wizard.py and iam.py are describe-vpcs, describe-subnets, describe-route-tables, describe-instances, and start/stop. The pinned CFN handler-permission fixture (test/fixtures/cfn_schema_handler_permissions.json) has no DescribeTags for any template resource type.
  • No widening. The only permission change in the diff is the added Deny action. The Sid renames carry no IAM semantics. src/ never looks up those two Sids, and no test does either. They appear only in test/fixtures/cloud_iam_policy_pre_shrink.json, which is a historical snapshot. The permission-set comparison ignores Sids. EXPECTED_PERMISSION_DELTA_ADDED gains exactly one tuple, the new Deny.
  • Fail-open vs fail-closed. There is no new error path. If the Deny turned out to be wrong, the effect would be fail-closed: an AccessDenied on a DescribeTags call, and no caller makes one.
  • Mutation check. I removed the "ec2:DescribeTags", line. Two tests went red: test_cloud_iam_cfn_schema.py::test_account_wide_tag_reads_denied_but_instance_reads_allowed and test_cloud_iam.py::TestPolicyDocument::test_shrink_preserved_the_permission_set_byte_for_byte. With the line restored, both files pass (203 passed). git status --short is clean afterwards.
  • CI at head. 83 success, 13 skipped, 6 cancelled. Each of the 6 cancelled runs (PR Hygiene, Inclusive Language, Semgrep, Automated Rule Check, GPT 5.6 Review, Screenshot Evidence) was superseded by a later successful run of the same check on this SHA. Auto-merge is enabled (merge). There are no human reviews yet.
  • Locally I ran only test/test_cloud_iam.py and test/test_cloud_iam_cfn_schema.py. I did not run the full suite, and I made no live AWS call.

Bot claims disposition

  • Design Review (PASS) and First Principles (PASS) both recommend one live cloud launch/teardown, because CFN compatibility rests on the pinned schema fixture. The claim is real but does not block: the gap is in evidence, not logic. A failure would be fail-closed, and the fixture covers every resource type in the template.
  • First Principles: the Sid renames "ride along". Real, and justified. They exist only to buy back the size budget, and I grepped and confirmed that nothing consumes the old names.
  • Earlier Opus advisory (at 50c7937): tags are still readable via tag:GetResources and ec2:DescribeInstances. Real, and out of scope. The author scopes it out explicitly under "Not a goal", and the new Deny comment does not claim account-wide unreadability.
  • GPT 5.6 and Opus 5 at head: no findings.

Follow-ups (non-blocking)

  • Before the next release, run one real kirocrew cloud launch + teardown against the tightened policy.
  • If wanted, track the residual tag exposure through tag:GetResources on * in a separate issue.

@iamwhatever
iamwhatever merged commit ea1ce1f into main Oct 3, 2026
99 of 106 checks passed
@iamwhatever
iamwhatever deleted the fix/cloud-deny-describetags branch October 3, 2026 06:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Post-merge note: the PR says no live AWS call was made. This adds an explicit Deny (ec2:DescribeTags) to the launcher policy. Recent P0s (#15232, #16072) were new refusals that broke every real run. Please run one real kirocrew cloud launch + teardown on this policy and post the result, so we know CloudFormation and the CLI never call DescribeTags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants