Repository navigation
fix(cloud): deny ec2:DescribeTags in the launcher IAM policy - #16276
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify one live [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 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Run one real Not justified as shipped
What this change shipsInventory (5 items) — 3 justifiedIntent: a leaked launcher credential can no longer dump every EC2 resource's free-text tag values — a FIX (the new test fails on base:
Grepped [FIRST-PRINCIPLES-REVIEWED] 6dca330 Description read[DESCRIPTION-READ] a03f47737cefb2bd4c7e3cb6405620375ac7249848e6bfdb3de8c1d56fad4fec That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
50c7937 to
b7bcf33
Compare
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.
b7bcf33 to
6dca330
Compare
|
Disposition for the Opus 5 advisory finding on The finding is correct that tags stay readable through two other grants: The comment beside |
buluoray
left a comment
There was a problem hiding this comment.
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,Actionincludesec2:DescribeTags,Resource: "*", and there is noCondition. It is unconditional, and an explicit Deny cannot be overridden by theec2:Describe*Allow. The new testtest_account_wide_tag_reads_denied_but_instance_reads_allowedruns 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[-_]?tagsacross the worktree finds only the policy, the spec and the tests. The agent CLI allowlist (src/kiro_crew/cloud/aws.py:100-106) has nodescribe-tags. Theec2calls incloud/ec2.py,wizard.pyandiam.pyare 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 noDescribeTagsfor 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 intest/fixtures/cloud_iam_policy_pre_shrink.json, which is a historical snapshot. The permission-set comparison ignores Sids.EXPECTED_PERMISSION_DELTA_ADDEDgains 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
AccessDeniedon 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_allowedandtest_cloud_iam.py::TestPolicyDocument::test_shrink_preserved_the_permission_set_byte_for_byte. With the line restored, both files pass (203 passed).git status --shortis 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.pyandtest/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:GetResourcesandec2: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:GetResourceson*in a separate issue.
|
Post-merge note: the PR says no live AWS call was made. This adds an explicit Deny ( |
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()insrc/kiro_crew/cloud/iam.pygrantsec2:Describe*on*and then cuts the secret-bearing Describe calls back out (DenyForeignUserData,DenySecretReads).ec2:DescribeTagsis 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,DescribeTagshands out tag values across the whole account with no resource scoping. An independent audit rated this MEDIUM.Not a goal
ec2:DescribeInstances: it also returns tags, but the launcher and CloudFormation need it.IamInstanceBoundaryCreateOnce, PassRole scoping, or any other statement.What changed (motivation → approach → change)
ec2:DescribeTagsis allowed account-wide by theec2:Describe*wildcard.DenySecretReadsenumerates the secret-bearing Describe calls, andDescribeTagswas not on the list.describe_tags/describe-tags/DescribeTagsanywhere in the repo. The cloud code drives the AWS CLI throughcloud.aws.run_aws(no boto3); instance discovery usesresourcegroupstaggingapi get-resources(tag:GetResources) andec2 describe-instances. The pinned CloudFormation handler-permission schema (test/fixtures/cfn_schema_handler_permissions.json, covering every resource type in the template) lists noec2:DescribeTags.ec2:DescribeTagsto the EXISTINGDenySecretReadsaction list. No new statement. The comments beside the Deny and besideec2:Describe*, anddocs/system-specs/modules/cloud.md, now name it.SsmSessionControlAndRead→SsmStatusReadandSsmAmiParameter→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) -- usestag:GetResourcesand is unaffected by an ec2 DenyReader: src/kiro_crew/cloud/ec2.py:_instance_state -- entry: chat|release (
kirocrew cloud status) -- usesec2:DescribeInstances, still allowed; test_account_wide_tag_reads_denied_but_instance_reads_allowedReader: 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 policyTests
test/test_cloud_iam_cfn_schema.py::test_account_wide_tag_reads_denied_but_instance_reads_allowed(new): pinsec2:DescribeTagsdenied ANDec2:DescribeInstancesstill allowed, through the module's IAM evaluator. Revert-verified: withsrc/kiro_crew/cloud/iam.pyrestored 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_ADDEDgains 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
Allowon a serviceDescribe*/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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement