Skip to content

feat: AgentCore Workload Gateway integration - #6598

Closed
kyleseaman wants to merge 2 commits into
feat/agentcore-3-awsfrom
cursor/agentcore-4-gateway-1b02
Closed

kyleseaman wants to merge 2 commits into
feat/agentcore-3-awsfrom
cursor/agentcore-4-gateway-1b02

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

PR 4 of 6 in the AgentCore stack. Workload inbound is IAM. kiro-cli cannot SigV4-sign InvokeGateway, so the unsigned Gateway hostname must never reach the agent file or session/new. This is the focused security-review slice.

A wiring gap here is an unsigned Invoke to a customer Gateway, or a bearer stuffed into ~/.kiro/agents/kirocrew.json. That review should not also cover OAuth consent or Settings UI.

What changed

  • Localhost 127.0.0.1 reverse proxy (preferred port 18765). HMAC-bound session token (X-Kirocrew-Proxy-Auth + X-Kirocrew-Proxy-Session); hop-by-hop headers are stripped before AWS.
  • SigV4 upstream is pinned to *.gateway.bedrock-agentcore.<region>.amazonaws.com.
  • Request-time recheck requires agentcore_posture == "workload" (not any AgentCore posture) and evaluates the calling session's profile, not the host profile.
  • Workload gateway_mcp_spec() returns the proxy listen URL, or None if the proxy cannot start. session/new injects only that loopback URL.
  • Default Kiro sessions use AcpRuntime; _mcp_servers_for_session injects the per-session Gateway alongside pooled MCP servers (not only AcpClient).
  • Dashboard inspect routes (/api/agentcore/gateway{,/verify,/sync}) lazy-import agentcore_inspect on first request so gateway boot does not load the optional AgentCore subsystem.

Not in this PR: login inbound sidecars, OAuth consent, Settings identity UI. Dashboard Gateway sync stays in PR 6 and is operator-gated there.

Stacked on #6597.

Tests

  • test_agentcore_sigv4.py: region parse, HMAC bind, upstream pin, test_proxy_recheck_refuses_login_posture, test_proxy_recheck_uses_calling_session_profile
  • test_agentcore_gateway_inject.py: sanitize drops headers; session injects loopback and refuses unsigned https
  • test_agentcore_inspect.py: snapshot codes, owner-only handlers

Related

Stack after #6597. Supersedes the Gateway/SigV4/inspect slice of #6387.

@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: checking Automated validation is still running labels Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

Sound proxy design, but a mutating control-plane route ships inside a PR whose description says sync is deferred to PR 6.

Watch

  • Sync is smuggled into the "read-only" slice. The description's "Not in this PR" says "Dashboard Gateway sync stays in PR 6 and is operator-gated there," and the base commit pinned "Inspect is Get/List/GetTarget — no Synchronize" — yet the diff adds POST /api/agentcore/gateway/sync calling SynchronizeGatewayTargets in a module docstring'd "Read-only AgentCore Gateway catalog" (agentcore_inspect.py:1,194). A security reviewer trusting the stated scope skips the one write verb here, and the launcher IAM story for Synchronize was explicitly left out of this slice. Move /sync to PR 6 or correct the description and module docstring so the write surface is reviewed as one.
  • One process-wide proxy, 16 handler slots, silent drop when full (PROXY_MAX_INFLIGHT, request.close() with no 503). Every session, subagent, and task step shares this listener with 300s socket timeouts; long-lived streamable-HTTP connections count against the cap, so under concurrent sessions Gateway tool calls fail as opaque connection resets with nothing in logs above debug. A 503 response and a cap sized against per-session streams would make the failure diagnosable.

[DESIGN-REVIEWED] 164d6e1

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 164d6e185c1186cc73318dc1f018f80078fc2dc3 — 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.

All evidence is in: contract, intent file, full patch, and repository greps for consumer counts (api/agentcore/gateway: 4 files, all defining sites or docs; KIROCREW_AGENTCORE_PROXY_PORT: 3 files, defining site plus docs). The review follows.

First-Principles-Verdict: CONCERNS

The SigV4 proxy and session-only inject are cause-level and earn their place; the preferred-port machinery and the /verify twin route do not.

What this change ships

Intent: let kiro-cli call an IAM-inbound AgentCore Gateway without the unsigned hostname or a bearer ever reaching the agent. ADDITION (stack slice 4/6).

  1. Sessions reach the Gateway through a localhost SigV4 proxy — justified
  2. Gateway URL travels only via session/new inject; persisted managed-hostname leftover retracted at rebuild — justified (cause-level)
  3. Proxy demands per-session HMAC headers, rechecks profile∩policy after body read — justified (agent-vs-ceiling boundary)
  4. Stable preferred port 18765 + KIROCREW_AGENTCORE_PROXY_PORT env var — unjustified surface
  5. Kiro-only ACP_BACKENDS_AGENTCORE_GATEWAY membership set — justified (harness-parity invariant)
  6. Three owner-only dashboard routes (catalog / verify / sync) — zero consumers; /verify duplicate of GET
  7. All edition extras lose headers/Authorization at agent-file rebuild — undeclared rider
  8. Shared-runtime children inject under their own agent profile — justified
  9. Spec/docs updated same-commit; snapshot registered as redaction sink — mandated

Watch

  • Preferred-port machinery's stated harm cannot occur in this PR's own design. The code comment says the stable port is "so a rebuilt kirocrew.json survives a gateway restart," but this PR guarantees the Gateway "is never written into the agent file," and the per-boot client_token HMAC invalidates every previously injected URL after a restart regardless of port. Ephemeral-only binding is observably identical. Grep KIROCREW_AGENTCORE_PROXY_PORT: 0 consumers beyond the defining site.
  • POST /verify is a second spelling of GET /gateway. Both handlers call inspect_snapshot(include_tools=True) identically; the only delta is the SEL verb. Grep api/agentcore/gateway: 0 callers anywhere (UI is PR 6), so both spellings ship consumer-less and must now be maintained.
  • Undeclared rider: _merge_edition_mcp now strips headers from every edition extra, not just the Gateway; a companion extra that legitimately carries static headers silently breaks at rebuild. The description never mentions this. The security rationale is real (bearer in an agent-readable file), but sibling-extra impact went uncounted.

Subtractions

  • Drop PROXY_PREFERRED_PORT, PROXY_PORT_ENV, preferred_bind_port(), and the _PreferredServer/_EphemeralServer split in agentcore_sigv4.py — always bind ephemeral; session inject already carries the live URL, and the env var is permanent public surface with zero consumers.
  • Drop the POST /api/agentcore/gateway/verify route and api_agentcore_gateway_verify — PR 6's UI can call the identical GET; add the distinct SEL verb only if a consumer materializes needing it.

[FIRST-PRINCIPLES-REVIEWED] 164d6e1

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 164d6e185c1186cc73318dc1f018f80078fc2dc3 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/platform/agentcore_gateway.py:134 -- CloudFormation configures AgentCore via environment variables, so "agentcore_posture(current_context().governance)" returns None and omits the Gateway; the matching proxy recheck would also reject it -> Fix: use the existing effective AgentCore posture and Gateway URL resolvers in both checks. (origin: validation)
[GPT-REVIEWED] 164d6e1

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

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

Both candidates are self-admittedly low-confidence and I could not re-derive a concrete input, call path, and observable wrong outcome for either.

Candidate 1 (_merge_edition_mcp strips headers): On this OSS fork _extra_mcp_servers() returns {} (confirmed — the loop over it is a no-op here), so no edition contributes a headers-bearing or non-dict spec. Stripping headers/Authorization before writing to kirocrew.json is deliberate hardening (the module docstring and the _SECRET_SPEC_KEYS set exist precisely to keep a bearer out of the agent file). No concrete input that occurs in practice; the harm is hypothetical to an unshipped companion. Fails (a). Dropped.

Candidate 2 ("" target-type marked syncable): the "" membership is intentional — _infer_target_type_from_config returns "" when live GetGatewayTarget omits targetType, and the catalog still offers sync so the operator can act; an actually-unsyncable target is rejected by SynchronizeGatewayTargets and mapped to SYNC_NOT_SUPPORTED/aws_error. Outcome is a cosmetic button state on an owner-only debug surface, caught downstream. No data harm; fails (c). Dropped.

Step 2: I examined the security-load-bearing additions — the SigV4 proxy auth token (HMAC-bound to session_key + agent, so a restricted child cannot forge a broader agent), the post-body-read _workload_proxy_still_permitted recheck (fails closed on exception, pins this hop's upstream against the ceiling URL), the loopback/is_agentcore_gateway_url upstream restriction preventing SSRF, and the session/new-only inject that never touches the agent file. Each guard is present and reachable on the changed path; I could not ground a new 80+ finding.

No findings.

[OPUS-REVIEWED] 164d6e1

Verdict parsed from the review's SHA-scoped output markers for commit 164d6e185c1186cc73318dc1f018f80078fc2dc3.

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

@kyleseaman
kyleseaman marked this pull request as ready for review August 28, 2026 18:56
@kyleseaman
kyleseaman requested review from a team and pepmach August 28, 2026 18:56
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from 2c2c666 to 29e0fbc Compare August 28, 2026 19:30
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from 10efeed to bf6e726 Compare August 28, 2026 19:31
@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 Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ⏭️ skipped

Revision 164d6e185c1186cc73318dc1f018f80078fc2dc3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@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 Aug 28, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from 29e0fbc to e36252f Compare August 28, 2026 19:54
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from bf6e726 to c0d6f70 Compare August 28, 2026 19:54
@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 Aug 28, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from e36252f to 18d6580 Compare August 28, 2026 20:21
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from c0d6f70 to 7280f24 Compare August 28, 2026 20:21
@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 Aug 28, 2026
@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: checking Automated validation is still running labels Aug 29, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from 41b841a to bbf8418 Compare August 29, 2026 01:25
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from 5e7df88 to c5a236f Compare August 29, 2026 01:25
@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 Aug 29, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from bbf8418 to d3af616 Compare August 29, 2026 01:44
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from c5a236f to 77b382b Compare August 29, 2026 01:44
@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 Aug 29, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from 77b382b to 485b967 Compare August 29, 2026 01:54
@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 Aug 29, 2026
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-3-aws-1b02 branch from d3af616 to be3b14d Compare August 29, 2026 02:00
@kyleseaman
kyleseaman force-pushed the cursor/agentcore-4-gateway-1b02 branch from 485b967 to 25da68e Compare August 29, 2026 02:00
@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 Aug 29, 2026
Workload inbound is IAM. kiro-cli cannot sign InvokeGateway, so the
adapter rewrites gateway_mcp_spec onto a 127.0.0.1 listener and
session/new injects that live loopback URL. The unsigned hostname
never reaches the agent file. Login sidecars and consent stay out.
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Retrigger pull_request review workflows on 7a15a62 (synchronize dropped after rebase; CI/Build stay ineligible on a stacked base).

Loopback is same-host, so each hop carries an HMAC-bound session
token. Request-time signing requires the calling session's profile
to still permit AgentCore and the composed posture to be workload
— login uses JWT inbound, not instance IAM.
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Superseded by #6828. This PR number stopped dispatching pull_request reviews (same class as #6597 → #6793). Commits are unchanged at 578e37702.

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.

1 participant