Repository navigation
fix(cloud): let the printed launcher policy launch on a fresh account - #15237
Conversation
Design Review (Fable 5) — ✅ human override accepted@iamwhatever overrode this lane for |
GPT 5.6 Review — ✅ human override acceptedHuman judgment by @iamwhatever overrides the GPT 5.6 finding for [GPT-OVERRIDE] a95cbbf This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS PassRole's confused-deputy pin — "Validated live + policy simulator" — is deleted on a launch failure nobody reproduced; no live launch verifies the Goal at all. Not justified as shipped
What this change shipsInventory (10 items) — 8 justifiedIntent: make
[FIRST-PRINCIPLES-REVIEWED] a95cbbf Description read[DESCRIPTION-READ] e2de9cb84435fa86d6162d8fd75074d50cfb55583bbb3fb0e12f34fe07a54652 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review — ✅ human override acceptedReviewed Human judgment by @iamwhatever overrides the Opus 5 finding for [OPUS-OVERRIDE] a95cbbf Verdict recorded from an authorized human decision for commit False positive or not applicable? A repository writer can comment: |
51db929 to
518c9dd
Compare
|
Replies to the blocking findings on 51db929, fixed on 518c9dd. GPT 5.6 F1 / Opus 5 BLOCKING Opus 5 BLOCKING fixture edit — fixed. Opus 5 FINDING stale comments — fixed at Design BLOCK (live launch) — no sandbox AWS account was used for this PR; the Manual verification section says so plainly. A live fresh-account run is being raised with the maintainer separately. |
518c9dd to
869e10a
Compare
|
Dispositions for the findings on 518c9dd; the fix is on 869e10a. GPT 5.6 F2 GPT 5.6 F1 Opus 5 advisory Opus 5 advisory Design (live launch) — unchanged: no sandbox AWS account was used, and the Manual verification section says so. |
|
GPT 5.6 F1 on 869e10a (adjudication: unconditioned |
869e10a to
4e08eb9
Compare
|
Offline evidence for the Design lane (head 4e08eb9). No AWS account, no AWS API calls, no launches.
The schema test evaluates each call with a concrete role ARN under parliament's remaining notes: What offline checks cannot prove: how AWS evaluates the conditions at call time (the path match inside CloudFormation's |
The launcher policy from `kirocrew cloud iam-policy` failed every launch on a fresh AWS account in two places. CloudFormation revokes a new security group's implicit allow-all egress before it applies the template's declared egress, so the tag-gated EC2 mutate statement grants ec2:RevokeSecurityGroupEgress. The PassRole-to-EC2 statement drops its aws:ResourceTag and iam:AssociatedResourceArn conditions. AWS documents that aws:ResourceTag is not reliable for iam:PassRole, and with them the launch failed at the Instance resource. The tag's job moves to an IAM path: the template puts the instance role under /kirocrew-ec2/, and CreateRole, PutRolePolicy, TagRole and PassRole are scoped to that path, so a pre-existing root-path kirocrew-ec2-* role can no longer be passed to EC2. PassRole keeps iam:PassedToService=ec2.amazonaws.com. Role management keeps the root pattern too, so pre-path stacks can still be destroyed. A new test checks every permission the public CloudFormation schemas list for the template's resource types against the printed policy. It found ten reads the policy lacked, so the explicit EC2 Describe list becomes ec2:Describe* (read-only, keeps the policy under the size cap) and the Instance handler's two SSM association reads are granted. The Describe calls that return secrets are denied back out: user data of instances not tagged kirocrew:managed=true, launch-template and Spot user data, and VPN pre-shared keys.
4e08eb9 to
a95cbbf
Compare
|
Dispositions for the findings on 4e08eb9; the fix is on a95cbbf. GPT 5.6 F1 GPT 5.6 F2 Opus 5 on 4e08eb9 — infra: the review step failed ( Design (live launch) — unchanged: no sandbox AWS account was used. |
|
Opus 5 BLOCKING GPT 5.6 on a95cbbf — infra: both review passes did not complete (no |
|
/ai-review override gpt a95cbbf: PassRole scoped to /kirocrew-ec2/ path + PassedToService; placing a role there already needs boundary-gated CreateRole |
|
/ai-review override opus a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR |
|
/ai-review override design a95cbbf: offline evidence only (CFN schema permission test, cfn-lint, parliament); no live launch |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
/ai-review override fable a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR |
|
/ai-review override design a95cbbf: offline evidence only (CFN schema permission test, cfn-lint, parliament); no live launch |
|
AI-review override not recorded. Use |
Human judgment recorded@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
/ai-review override fable a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR |
Human judgment recorded@iamwhatever marked the fable AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
buluoray
left a comment
There was a problem hiding this comment.
LGTM. I checked this at head a95cbbf4aa.
iam:PassRole (src/kiro_crew/cloud/iam.py IamPassRoleToEc2) is scoped to INSTANCE_ROLE_ARN under the /kirocrew-ec2/ path, with iam:PassedToService = ec2.amazonaws.com, and it no longer uses aws:ResourceTag/iam:AssociatedResourceArn. AWS documents that the tag key is unreliable for PassRole, and the ARN key has no instance ARN at AddRoleToInstanceProfile time. CreateRole is path-scoped and keeps its boundary condition. PutRolePolicy/TagRole keep the tag gate. The legacy root-path pattern is left only on non-escalating verbs. No mutating action on * is unconditioned: the EC2 mutate statement is gated on aws:ResourceTag/kirocrew:managed=true, and tag-on-create on ec2:CreateAction.
Mutations against test_cloud_iam.py + test_cloud_iam_cfn_schema.py (baseline 202 passed), each reddening named tests:
- PassRole also on the root ARN ->
test_root_path_role_can_be_neither_created_nor_passed,test_passrole_denied_for_a_root_path_role PassedToServicewildcarded ->test_passrole_scoped_to_role_path_and_ec2DenyForeignUserDataflipped to Allow ->test_user_data_reads_limited_to_managed_instancesaws:ResourceTagre-added to PassRole ->test_passrole_has_no_resource_tag_or_associated_arn_condition- dropping
RevokeSecurityGroupEgress, the templatePath:orDenySecretReadsalso each redden a named test.
Bot dispositions: GPT F1 (path is not ownership) is real and non-blocking (follow-up 2). The override holds for the launcher's own write paths. GPT's unconditioned CreatePolicy on the boundary is real, but it's pre-existing on main (follow-up 3). I agree with the Opus BLOCKING override: StringNotEquals on a present kirocrew:managed tag doesn't deny the managed instance. First Principles' AssociatedResourceArn reasoning is plausible but not proven live. The Design lane's "offline evidence only" is accurate, and the body says so.
Non-blocking follow-ups:
ec2:DescribeVerifiedAccessTrustProvidersfalls underec2:Describe*and isn't inDenySecretReads, and itsOidcOptionsshape has aclientSecret. Confirm AWS redacts it, or add it to the deny.- An untagged, unbounded role that another principal plants at
/kirocrew-ec2/kirocrew-ec2-*is now passable, where main blocked it. It's narrow, but it needs the maintainer decision the PR asks for. - Pre-existing: on a fresh account,
IamInstanceBoundaryCreateOncelets the launcher create its ownkirocrew-ec2-boundary, which weakens every boundary argument. Worth its own issue. - The
iam.py~326-334 comment and thecloud.mdspec say none of the Describe actions take resource-level scoping.DescribeInstanceAttributedoes, andDenyForeignUserDatarelies on that. test_the_only_deny_statement_is_the_start_session_lane_blocknow pins three Deny statements; rename it.- No live launch was run on a fresh account, so the headline goal rests on offline schema checks.
Problem / Motivation
Goal:
kirocrew cloud launchsucceeds on a fresh AWS account when the launch principal holds only the policy thatkirocrew cloud iam-policyprints.Today every launch with that policy fails. It fails first at
InstanceSecurityGroup, and once that is granted it fails atInstance.Why it matters
Every operator who follows the documented setup (paste the printed policy, then launch) hits a failed CloudFormation stack. Only admins who launch with broader credentials get a working instance.
Not a goal
GetPolicy-denial check.iam:GetPolicy.What changed (motivation → approach → change)
InstanceSecurityGroupec2:RevokeSecurityGroupEgressEc2ManagedResourceMutateTagged(same tag gate)Instanceiam:PassRoletag andAssociatedResourceArnconditions never matchec2:Describe*,ssm:DescribeAssociation,ssm:ListAssociationsA new VPC security group comes with an allow-all egress rule. CloudFormation revokes it before it applies the template's declared
SecurityGroupEgress. The policy granted only the ingress revoke, so the group could never be finished.AWS documents that
aws:ResourceTagdoes not give reliable results foriam:PassRole. That tag was what stopped a pre-existing, unboundedkirocrew-ec2-*role from being passed to EC2. An IAM path now does that job.kirocrew-ec2.yamlputs the instance role under/kirocrew-ec2/(ROLE_PATHinsrc/kiro_crew/cloud/iam.py).CreateRole,PutRolePolicy,TagRoleandPassRoleare scoped toarn:aws:iam::*:role/kirocrew-ec2/kirocrew-ec2-*. The launcher's only way to put a role there is the boundary-gatedCreateRole, so a root-pathkirocrew-ec2-*role can be neither passed nor edited.PassRolekeepsiam:PassedToService=ec2.amazonaws.com. The instance profile is not tag-gated: it carries no tags.The public CloudFormation resource schemas list about twenty EC2 Describe calls for these handlers, ten of them missing from the policy. Listing them breaks the 6,144 cap, so the explicit Describe list is one
ec2:Describe*on*. The trade: the launcher can read EC2 metadata across the account, with no added write. Reads that return secrets are denied back out.DenyForeignUserDatablocks instance user data on any instance not taggedkirocrew:managed=true.DenySecretReadsblocks launch-template and Spot user data and VPN pre-shared keys.The read/delete role verbs and the SSM-core attach/detach keep the root-path pattern beside the path, so stacks launched before this change can still be stopped, started and destroyed.
docs/system-specs/modules/cloud.mdand the AgentCore RFC bullet describe the new scope. The compact policy is 6,026 chars, under the 6,044 headroom gate and the 6,144 cap from #13029.Backwards compatibility
Breaking: re-running
kirocrew cloud launchwith the tag of a stack launched before this change fails. CloudFormation must replace the custom-named role to move it to the new path, which it refuses. Destroy that stack and launch again. Writer sweep on origin/main @ 9ac3e7f:ec2.deploy(called fromlaunch_engine.pyandwizard.py) is the only template writer; stop, start, status and destroy do not update the template and keep working through the root-path management pattern.Tests
test/test_cloud_iam.pyassertsec2:RevokeSecurityGroupEgressis in the tag-gated mutate statement, and its exact action-set pin includes it.IamPassRoleToEc2targets exactly the path ARN, has noaws:ResourceTag/*oriam:AssociatedResourceArncondition, and keepsiam:PassedToService.CreateRole,PassRole,PutRolePolicyorTagRolestatement matches the root-path pattern, and another asserts the template'sInstanceRolecarriesPath: /kirocrew-ec2/.test/test_cloud_iam_cfn_schema.pychecks every create/update/delete permission in the pinned schema lists (test/fixtures/cfn_schema_handler_permissions.json) against the printed policy, with the concrete role ARN under/kirocrew-ec2/and each request's condition keys. A permission it does not grant must carry a named reason inNOT_GRANTED. Removingec2:RevokeSecurityGroupEgressmakes it fail, and so does turningDenyForeignUserDatainto an Allow.test/fixtures/cloud_iam_policy_pre_shrink.jsonis unchanged. The fix(cloud): shrink launcher IAM policy under IAM's 6144-char cap #13029 permission test asserts the current policy equals that snapshot with the namedEXPECTED_PERMISSION_DELTA_REMOVED/_ADDEDsets applied, so every tuple is compared and a stale delta entry fails.Manual verification
No live launch was run: no sandbox AWS account was used for this PR. Offline checks: the schema test above;
cfn-lint1.40.0 onkirocrew-ec2.yamlis clean, including the rolePath;parliament1.6.3 finds no unknown action or condition key. Offline checks cannot prove how AWS evaluates conditions at call time, or that CloudFormation calls nothing outside the schema lists.Related Issues
Related: #10229, #13029.
no linked issue: the launch failures are tracked in the requesting session, not a GitHub issue.
Pattern harvest
Rule candidate: review-prompt
Pattern: an
iam:PassRolestatement conditioned onaws:ResourceTag/*, which AWS documents as unreliable for PassRole; scope it by IAM path instead.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)