Skip to content

fix(cloud): let the printed launcher policy launch on a fresh account - #15237

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/cloud-iam-launch-policy
Sep 30, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/cloud-iam-launch-policy

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: kirocrew cloud launch succeeds on a fresh AWS account when the launch principal holds only the policy that kirocrew cloud iam-policy prints.

Today every launch with that policy fails. It fails first at InstanceSecurityGroup, and once that is granted it fails at Instance.

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

  • The permissions-boundary GetPolicy-denial check.
  • The cloud doc advice about dropping iam:GetPolicy.
  • The remote-crew iframe origin.

What changed (motivation → approach → change)

failing step cause change
InstanceSecurityGroup CloudFormation calls ec2:RevokeSecurityGroupEgress granted in Ec2ManagedResourceMutateTagged (same tag gate)
Instance iam:PassRole tag and AssociatedResourceArn conditions never match dropped; PassRole scoped by IAM path instead
any EC2 step handlers call Describe and SSM association reads the policy lacked ec2:Describe*, ssm:DescribeAssociation, ssm:ListAssociations

A 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:ResourceTag does not give reliable results for iam:PassRole. That tag was what stopped a pre-existing, unbounded kirocrew-ec2-* role from being passed to EC2. An IAM path now does that job. kirocrew-ec2.yaml puts the instance role under /kirocrew-ec2/ (ROLE_PATH in src/kiro_crew/cloud/iam.py). CreateRole, PutRolePolicy, TagRole and PassRole are scoped to arn:aws:iam::*:role/kirocrew-ec2/kirocrew-ec2-*. The launcher's only way to put a role there is the boundary-gated CreateRole, so a root-path kirocrew-ec2-* role can be neither passed nor edited. PassRole keeps iam: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. DenyForeignUserData blocks instance user data on any instance not tagged kirocrew:managed=true. DenySecretReads blocks 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.md and 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 launch with 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 from launch_engine.py and wizard.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.py asserts ec2:RevokeSecurityGroupEgress is in the tag-gated mutate statement, and its exact action-set pin includes it.
  • It asserts IamPassRoleToEc2 targets exactly the path ARN, has no aws:ResourceTag/* or iam:AssociatedResourceArn condition, and keeps iam:PassedToService.
  • A new test asserts no CreateRole, PassRole, PutRolePolicy or TagRole statement matches the root-path pattern, and another asserts the template's InstanceRole carries Path: /kirocrew-ec2/.
  • test/test_cloud_iam_cfn_schema.py checks 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 in NOT_GRANTED. Removing ec2:RevokeSecurityGroupEgress makes it fail, and so does turning DenyForeignUserData into an Allow.
  • test/fixtures/cloud_iam_policy_pre_shrink.json is 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 named EXPECTED_PERMISSION_DELTA_REMOVED / _ADDED sets 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-lint 1.40.0 on kirocrew-ec2.yaml is clean, including the role Path; parliament 1.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:PassRole statement conditioned on aws:ResourceTag/*, which AWS documents as unreliable for PassRole; scope it by IAM path instead.

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

@iamwhatever
iamwhatever requested a review from a team as a code owner September 30, 2026 01:57
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ human override accepted

@iamwhatever overrode this lane for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @iamwhatever overrides the GPT 5.6 finding for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77; the recorded reason is authoritative for this commit.

[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:
/ai-review override gpt a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77 — 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: 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

  • Item 3 — inherited: the deleted pin reads "iam:AssociatedResourceArn fully satisfies the confused-deputy rule (CWE-269) … (Validated live + policy simulator.)"; the ResourceTag drop has AWS-doc cover, but this key's drop rests only on the asserted failure, and "No live launch was run: no sandbox AWS account was used for this PR." deploy/iam.py:670,752 keeps the same key on 2 PassRole statements (grep AssociatedResourceArn) where it evidently works.
    Clears when: a live launch confirms iam:PassRole with the iam:AssociatedResourceArn condition is denied at Instance, or an AWS doc names that key unreliable for this call path.
  • Item 6 — inherited: the Goal ("launch succeeds on a fresh AWS account") plus 15 _PROPERTY_UNUSED withholdings of schema-listed Instance-handler actions rest on "Offline checks cannot prove how AWS evaluates conditions at call time"; one unconditionally-called withheld action fails the exact launch this PR exists to fix, and the defect itself has "no linked issue."
    Clears when: one live kirocrew cloud launch succeeds on a fresh account whose principal holds only the printed policy.

What this change ships

Inventory (10 items) — 8 justified

Intent: make kirocrew cloud launch succeed with only the printed IAM policy — a FIX.

  1. Launch no longer denied at InstanceSecurityGroup (ec2:RevokeSecurityGroupEgress, tag-gated) — justified
  2. PassRole/CreateRole/PutRolePolicy/TagRole re-scoped from name-prefix+tag to IAM path — justified
  3. PassRole loses its iam:AssociatedResourceArn confused-deputy condition — inherited (pin reversed on an unverified failure claim)
  4. Instance role moves under /kirocrew-ec2/; re-launching a pre-path stack fails (declared breaking) — justified
  5. Launcher can now read all EC2 metadata (ec2:Describe* on *) — justified (6,144-char cap, fix(cloud): shrink launcher IAM policy under IAM's 6144-char cap #13029)
  6. Secret-bearing reads denied back out (DenyForeignUserData, DenySecretReads); 15 handler actions withheld as _PROPERTY_UNUSED — inherited (untested handler-behavior premise)
  7. ssm:DescribeAssociation / ListAssociations granted — justified
  8. Legacy root-path pattern kept on management verbs so old stacks still stop/start/destroy — justified
  9. New schema-conformance test + pinned CFN schema fixture (the cause-level guard) — justified
  10. cloud.md and AgentCore RFC bullet updated in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] a95cbbf

Description read

[DESCRIPTION-READ] e2de9cb84435fa86d6162d8fd75074d50cfb55583bbb3fb0e12f34fe07a54652

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ human override accepted

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

Human judgment by @iamwhatever overrides the Opus 5 finding for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77; the recorded reason is authoritative for this commit.

[OPUS-OVERRIDE] a95cbbf

Verdict recorded from an authorized human decision for commit a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77.

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

@iamwhatever
iamwhatever force-pushed the fix/cloud-iam-launch-policy branch from 51db929 to 518c9dd Compare September 30, 2026 02:29
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Replies to the blocking findings on 51db929, fixed on 518c9dd.

GPT 5.6 F1 / Opus 5 BLOCKING iam.py:647 (PassRole can reach a foreign privileged role) — fixed. The escalation was real. PassRole is now scoped by IAM path, a key that does not rely on tags: the template puts the instance role under /kirocrew-ec2/, and CreateRole, PutRolePolicy, TagRole and PassRole all target arn:aws:iam::*:role/kirocrew-ec2/kirocrew-ec2-*. The launcher's only way to create a role there is the boundary-gated CreateRole, so a pre-existing root-path kirocrew-ec2-* role no longer matches PassRole. iam:PassedToService=ec2.amazonaws.com stays. The instance profile is not tag-gated, as suggested: AWS::IAM::InstanceProfile in the template carries no tags, so that condition would deny every launch. test_root_path_role_can_be_neither_created_nor_passed fails if any of those four verbs matches the root-path pattern again.

Opus 5 BLOCKING fixture edit — fixed. test/fixtures/cloud_iam_policy_pre_shrink.json is back to its origin/main content. The neutrality test subtracts named EXPECTED_PERMISSION_DELTA_REMOVED / EXPECTED_PERMISSION_DELTA_ADDED sets and asserts each entry really exists on its side.

Opus 5 FINDING stale comments — fixed at iam.py (TagRole comments), test_cloud_iam.py and the AgentCore RFC bullet.

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.

@iamwhatever
iamwhatever force-pushed the fix/cloud-iam-launch-policy branch from 518c9dd to 869e10a Compare September 30, 2026 02:52
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for the findings on 518c9dd; the fix is on 869e10a.

GPT 5.6 F2 test/test_cloud_iam.py:664 (ratchet weakened by exemption sets) — fixed. The test no longer subtracts anything from the current policy. It asserts flatten(policy) == (flatten(snapshot) - REMOVED) | ADDED, so every current tuple is compared, and a later widening of a delta tuple fails. It also asserts each REMOVED tuple is really in the snapshot and no ADDED tuple already was.

GPT 5.6 F1 iam.py:659 (IAM path is not ownership) — needs-a-decision. This is the scope the conductor chose: the aws:ResourceTag and iam:AssociatedResourceArn conditions that proved ownership are the ones that deny CloudFormation's RunInstances. The launcher's only writer into /kirocrew-ec2/ is the boundary-gated CreateRole. A foreign role there has to be planted by another principal with IAM write access. Clearing this security-fenced finding is a maintainer override decision.

Opus 5 advisory kirocrew-ec2.yaml:161 (re-launching a pre-path stack fails with a bare already exists) — accepted, no commit here. ## Backwards compatibility states it as Breaking with the destroy-and-relaunch remedy. Mapping the CloudFormation error to that message is a change to cloud/ec2.py, which this diff does not touch.

Opus 5 advisory iam.py:431 (revoke-security-group-egress has no shell deny rule) — rebutted as out of scope. ec2:RevokeSecurityGroupIngress is already granted on main and is not in denied_rules.py either, so the shell deny gap exists for both verbs and predates this PR. It belongs to the agent shell policy, not the launcher IAM policy.

Design (live launch) — unchanged: no sandbox AWS account was used, and the Manual verification section says so.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

GPT 5.6 F1 on 869e10a (adjudication: unconditioned iam:CreatePolicy on kirocrew-ec2-boundary) — needs-a-decision, with one fact for the maintainer. The chain the adjudicator describes does not depend on this PR's PassRole scope: on origin/main, a launcher-credential holder on a fresh account can create a permissive kirocrew-ec2-boundary, then CreateRole with it. The holder can tag that role kirocrew:managed=true inside the same CreateRole call (the TagRole gate allows tags being applied at create), so main's tag-gated PassRole passes it too. The boundary's create-once content is the control that decides this, and it is outside this PR's goal. F2 is cleared on this head.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@iamwhatever
iamwhatever force-pushed the fix/cloud-iam-launch-policy branch from 869e10a to 4e08eb9 Compare September 30, 2026 06:13
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Offline evidence for the Design lane (head 4e08eb9). No AWS account, no AWS API calls, no launches.

Check Tool Result
Every CloudFormation handler permission for the template's 7 resource types vs the printed policy test/test_cloud_iam_cfn_schema.py over schema lists pinned from CloudformationSchema.zip (sha256 de2a6c94…c3198, fetched 2026-09-30) 133 cases pass. It found 10 reads the policy lacked (8 EC2 Describe, ssm:DescribeAssociation, ssm:ListAssociations); now granted. Removing ec2:RevokeSecurityGroupEgress makes 3 cases fail
Template, incl. InstanceRole.Path cfn-lint 1.40.0 0 findings
Action names and condition keys parliament 1.6.3 0 unknown actions, 0 unsupported condition keys

The schema test evaluates each call with a concrete role ARN under /kirocrew-ec2/, the request's tags, iam:PermissionsBoundary, iam:PolicyARN and iam:PassedToService. Permissions it does not grant each carry a named reason in NOT_GRANTED: update-only calls for properties the template never sets, iam:UntagRole, and three trust/boundary rewrites withheld on purpose.

parliament's remaining notes: RESOURCE_STAR on the tag-gated mutate statement (gated by aws:ResourceTag, by design) and on ec2:Describe* (15 Describe actions there could be resource-scoped; the wildcard is the size-cap trade in the body). RESOURCE_MISMATCH flags statements split by resource type (RunInstances, CreateSecurityGroup) and AWS-owned ARNs with no account ID; none of those lines changed in this PR.

What offline checks cannot prove: how AWS evaluates the conditions at call time (the path match inside CloudFormation's RunInstances, tag keys present in each request), and that CloudFormation calls nothing outside the schema lists. Only a live launch proves those.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 30, 2026
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.
@iamwhatever
iamwhatever force-pushed the fix/cloud-iam-launch-policy branch from 4e08eb9 to a95cbbf Compare September 30, 2026 07:03
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dispositions for the findings on 4e08eb9; the fix is on a95cbbf.

GPT 5.6 F1 iam.py:340 (ec2:Describe* exposes other instances' user data) — fixed. Two explicit Denies cut the secret-bearing reads back out of the wildcard. DenyForeignUserData denies ec2:DescribeInstanceAttribute unless the instance carries kirocrew:managed=true (the action supports aws:ResourceTag on the instance resource), so CloudFormation's Instance handler can still read its own instance. DenySecretReads denies DescribeLaunchTemplateVersions, DescribeSpot*Requests and DescribeVpnConnections outright; the template uses none of them. test_user_data_reads_limited_to_managed_instances fails if the first Deny becomes an Allow. Policy is 6,026 chars, under the 6,044 gate.

GPT 5.6 F2 iam.py:661 (IAM path does not prove the role is boundary-capped) — needs-a-decision, unchanged. Security-fenced; only a maintainer override clears it.

Opus 5 on 4e08eb9 — infra: the review step failed (outcome=failure, "Failing closed") and posted no verdict for this head. This push reruns it.

Design (live launch) — unchanged: no sandbox AWS account was used.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Opus 5 BLOCKING iam.py:872 on a95cbbf (DenyForeignUserData denies every instance, because DescribeInstanceAttribute has no resource-level permission) — rebutted as not-a-defect. The premise does not match AWS's own published data. The AWS service reference for EC2 (servicereference.us-east-1.amazonaws.com/v1/ec2/ec2.json, read 2026-09-30) lists DescribeInstanceAttribute with resource type instance, and the instance resource supports aws:ResourceTag/${TagKey}. So the request carries the instance's tags, kirocrew:managed=true matches on the stack's own instance, and the Deny applies only to other instances. By contrast, DescribeInstances, DescribeLaunchTemplateVersions, DescribeSpot*Requests and DescribeVpnConnections list no resource type, which is why DenySecretReads carries no condition. parliament 1.6.3's IAM dataset agrees (instance* with aws:ResourceTag/${TagKey}). The ec2:Describe* comment says the reads take no resource scoping as a group; that holds for the list the wildcard replaced, not for every action under it. Only a live call proves how AWS evaluates it; no sandbox account was used.

GPT 5.6 on a95cbbf — infra: both review passes did not complete (no [GPT-REVIEWED] marker for this head). The whole run is rerun.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt a95cbbf: PassRole scoped to /kirocrew-ec2/ path + PassedToService; placing a role there already needs boundary-gated CreateRole

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override opus a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override design a95cbbf: offline evidence only (CFN schema permission test, cfn-lint, parliament); no live launch

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77.

PassRole scoped to /kirocrew-ec2/ path + PassedToService; placing a role there already needs boundary-gated CreateRole

This decision applies only to this commit. A new push requires a new judgment.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override fable a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override design a95cbbf: offline evidence only (CFN schema permission test, cfn-lint, parliament); no live launch

@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded. Use /ai-review override <fable|gpt|design|ux|first-principles|scope|all> <current-sha>: <one-sentence reason>.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77.

offline evidence only (CFN schema permission test, cfn-lint, parliament); no live launch

This decision applies only to this commit. A new push requires a new judgment.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override fable a95cbbf: DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the fable AI finding as false positive, not applicable, or explicitly accepted for a95cbbf4aa9ecdcd3aecc94115c8960e4eb20d77.

DescribeInstanceAttribute supports the instance resource and aws:ResourceTag per the AWS service reference; rebuttal posted on the PR

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 30, 2026

@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.

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
  • PassedToService wildcarded -> test_passrole_scoped_to_role_path_and_ec2
  • DenyForeignUserData flipped to Allow -> test_user_data_reads_limited_to_managed_instances
  • aws:ResourceTag re-added to PassRole -> test_passrole_has_no_resource_tag_or_associated_arn_condition
  • dropping RevokeSecurityGroupEgress, the template Path: or DenySecretReads also 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:

  1. ec2:DescribeVerifiedAccessTrustProviders falls under ec2:Describe* and isn't in DenySecretReads, and its OidcOptions shape has a clientSecret. Confirm AWS redacts it, or add it to the deny.
  2. 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.
  3. Pre-existing: on a fresh account, IamInstanceBoundaryCreateOnce lets the launcher create its own kirocrew-ec2-boundary, which weakens every boundary argument. Worth its own issue.
  4. The iam.py ~326-334 comment and the cloud.md spec say none of the Describe actions take resource-level scoping. DescribeInstanceAttribute does, and DenyForeignUserData relies on that.
  5. test_the_only_deny_statement_is_the_start_session_lane_block now pins three Deny statements; rename it.
  6. No live launch was run on a fresh account, so the headline goal rests on offline schema checks.

@chenmingwei23
chenmingwei23 merged commit 5cd5ee6 into main Sep 30, 2026
101 of 110 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/cloud-iam-launch-policy branch September 30, 2026 23:22
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 30, 2026
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