Repository navigation
feat: AgentCore identity, inbound inject, and Gateway MCP access - #6387
kyleseaman wants to merge 1 commit into
Conversation
aa4c009 to
ce23e6c
Compare
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/platform/bootstrap.py:192 -- Optional installation blocks gateway readiness (origin: validation)
BLOCKING -- src/kiro_crew/dashboard/handlers/agentcore_identity.py:527 -- Hot apply leaves pre-change Gateway credentials live
BLOCKING -- src/kiro_crew/platform/agentcore_aws.py:131 -- Workload proxy signs requests to arbitrary HTTPS hosts
FINDING -- src/kiro_crew/dashboard/handlers/files.py:842 -- [BLOCK-MERGE] 98508c4 |
UX Review (Fable 5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS Failed connection checks read as passing: affirmative labels with an aria-hidden warn icon, plus raw enum codes appended. Watch
Suggestions
[UX-REVIEWED] 98508c4 |
Design Review (Fable 5) — 🔴 BLOCK (blocking)Design-level review of Design-Verdict: BLOCK The squashed commit was built from a stale tree: merging it silently reverts the last four commits on main alongside the AgentCore work. Blockers
Watch
Suggestions
[DESIGN-REVIEWED] 98508c4 |
First Principles Review (Fable 5) — 🔴 BLOCKPremise-level review of All evidence is in hand. The AgentCore body itself is thoroughly declared and boundary-derived; the fatal problem is that the squash silently reverts four commits that landed on main after the author's working tree was taken, while the description claims the branch sits on current main with riders removed. The screenshots are fine — First-Principles-Verdict: BLOCK The squash silently reverts four shipped main commits — Discord document sends, a lockfile CI gate, and two test-determinism fixes — while claiming to sit on current main. What this change shipsIntent: let a crew that names an AgentCore identity and Gateway URL actually reach that Gateway's MCP tools, visibly to the operator. ADDITION.
BlockersFour main commits are silently reverted by the squash.
One root cause — the squash was built from a pre- Watch
[FIRST-PRINCIPLES-REVIEWED] 98508c4 |
Opus 4.8 Review — 🔴 changes requested (blocking)Reviewed Command injection: the [BLOCK-MERGE] 98508c4 and (line 718) [OPUS-REVIEWED] 98508c4 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
4d1a77f to
4da61df
Compare
73424eb to
e04ce52
Compare
Wire an existing AgentCore Gateway and standalone identity onto a crew from Settings. Workload posture vends a first-party WAT and reaches the Gateway over a localhost SigV4 proxy; login posture injects a per-session sidecar and withholds non-Gateway MCP until the operator signs in.
e04ce52 to
98508c4
Compare
kyleseaman
left a comment
There was a problem hiding this comment.
Security/code review found four blocking trust-boundary issues plus a regression from current main. I left inline details and concrete failure paths. The commit also removes the Discord name-preserving document-send capability that landed in parent commit #6500; that unrelated reversion should be restored along with the Node-floor guard called out inline.
| path.parent.mkdir(parents=True, exist_ok=True) | ||
| payload = json.dumps(data, indent=2, sort_keys=False) + "\n" | ||
| tmp = Path(str(path) + ".tmp") | ||
| tmp.write_text(payload, encoding="utf-8") |
There was a problem hiding this comment.
[P1] Use a non-following atomic temp-file primitive for this keystone write. security_policy.json.tmp is not covered by the sensitive-path floor (is_sensitive_path(.../security_policy.json) is true while the .tmp sibling is false), so a same-UID agent can pre-create it as a symlink. write_text() then follows that link and replace() promotes the symlink itself to security_policy.json; after the operator saves once, the agent can edit the symlink target and weaken the next loaded ceiling. I reproduced that exact sequence locally. Please use the project's exclusive owner-only atomic-write pattern (or mkstemp/O_EXCL plus link checks and replace) and add a regression test with a pre-planted .tmp symlink.
| handler = self._handler_class() | ||
| preferred = preferred_bind_port() | ||
| try: | ||
| httpd = ThreadingHTTPServer((PROXY_HOST, preferred), handler) |
There was a problem hiding this comment.
[P1] Loopback binding is not client authentication. This handler accepts an unauthenticated MCP body from any local process and signs it with the instance-role credentials; the fixed preferred port makes discovery trivial. A prompt-injected agent can call this URL through shell/network tooling and issue tools/call directly, bypassing the MCP PreToolUse/governance/approval path because the request reaches the signer as ordinary HTTP rather than as a governed tool call. This also reintroduces the RFC's stated inability to distinguish Crew from a sibling/compromised local process. Please require a capability/peer credential at the proxy before signing, scoped so arbitrary tool subprocesses cannot use it, and cover rejection of an unauthenticated loopback request.
| systemd ``KIROCREW_AGENTCORE_POSTURE=workload`` cannot hide a | ||
| Settings ``login`` from catalog, probe, and ``gateway_mcp_spec``. | ||
| """ | ||
| authored = authored_posture() |
There was a problem hiding this comment.
[P1] Resolve these values from the selected Level-1 ceiling, not directly from the tier-4 home file. load_security_policy() gives env override / central distribution / bundled policy precedence over home, and GovernanceCeiling already carries agentcore_identity_posture, agentcore_gateway_url, and agentcore_workload_name; this home-first resolver bypasses that ordering after boot. For example, a centrally distributed login policy can still have its JWT sent to a different home-authored Gateway URL, while a central workload policy plus a stale home login value makes gateway_mcp_spec() return the unsigned HTTPS URL instead of the SigV4 proxy. Use the installed ceiling accessors for runtime decisions (with a narrowly defined pre-bootstrap fallback if needed), and refuse/accurately report Settings writes when a higher-precedence ceiling is active.
| ) | ||
| except Exception: | ||
| logger.debug("publish_turn_identity failed for %s", session_key, exc_info=True) | ||
| if surface and raw_id: |
There was a problem hiding this comment.
[P1] The fail-closed principal logic is not wired into the actual non-dashboard turn paths. Every existing channel/cron caller still invokes publish_turn_identity(sessions, session_key) without surface/raw_id, so this branch never runs; cron also calls it after get_or_create, which is too late for session/new. Consequently a workload cron using user/OBO credentials never gets the promised deny sidecar and falls through to _workload_live_proxy_servers(), while Slack/Discord/etc. in login posture never receive a principal or Gateway. inherit_parent_principal() is likewise only referenced by tests, not the subagent path. Please bind ground-truth identities before acquisition on every surface (or centralize it in session acquisition), and test real cron/channel/subagent entry paths rather than only calling the helper directly.
| # exists because that is a property of today's dependency tree, not a guarantee: | ||
| # the next package with an unsatisfiable optional peer reintroduces the whole | ||
| # class, and without a job on the floor nothing would notice. | ||
| lockfile-engines-floor: |
There was a problem hiding this comment.
[P1] Please restore this current-main guard. The PR's parent already contains #6553, but this commit removes both the Node 22 npm ci job and its matching @pierre/theming override/test. That change was added because npm 10 and npm 11 produce different optional-peer trees and the supported Node 22 install had already broken twice while all Node 24 jobs stayed green. Removing the fix and the only floor runner together silently reopens the production install regression; it is unrelated to AgentCore.
|
Superseded by GitHub stack #6601, split by independent security/trust boundaries (not by directory). Each PR is merge-safe and inert by default. The unrelated Node/theming and Discord reversions from this monolith are not in the stack.
Review the stack, not this 111-file PR. |
Review notes
Squashed to one commit on current
main(includes #6264 governance distribution). Security Settings keeps both the central-distribution block and AgentCore Identity.Please review as workload V1 + login attach. An existing AWS_IAM Gateway + standalone AgentCore identity + credentials that can
InvokeGatewaycan be wired from Settings without a restart. Login inbound is wired (companion JWT →Authorization: Bearersidecar; no JWT →oauth_challengesidecar). The remaining live gap is kiro-cli's hosted Authorize hop (_kiro.dev/mcp/oauth_request) — designed and unit-covered, not yet driven against AgentCore.Known documented limits (not this PR):
pip install kirocrew[agentcore](venv extra is fine)gateway/kirocrew-*; Settings customers with their own creds can invoke a pasted existing GatewayGetResourceOauth2Tokenstays out — Gateway already vends outbound OAuthProblem / Motivation
A deployed Crew can have an AgentCore Identity and talk to AgentCore Gateway, but the public default wheel must not import AWS SDKs, persist inbound JWTs in
~/.kiro/agents/kirocrew.json, or treat a companionenabled()flag as permission. Login posture also has to withhold Kiro's default MCP merge until Gateway is attached for that session. A launched box that opted in still needs to actually fetch tokens — including a box that configured identity later, without the CFN--agentcoreflag. The Gateway MCP URL also has to be authorable on that crew, not only as a launch env var. kiro-cli does not SigV4-signInvokeGateway, so a raw Gateway URL on workload posture cannot authenticate. Once wired, an operator debugging a 403, a stale catalog, or a PENDING_AUTH target still had a blank URL box and no way to see what the Gateway actually exposes.Why it matters
Without this path, Settings can name a posture and CFN can create a workload identity, but the agent never actually reaches Gateway MCP tools. Tokens in the agent file would leak into every session and into backups. An expired sidecar without a session recycle would leave kiro-cli presenting a dead JWT until restart. Shipping fetch only in an out-of-tree companion left the IaC path as identity-without-vending. Installing the extra only at launch left Settings-configured crews on the no-op adapter. An env-only Gateway URL left a local/already-running crew unable to point at an existing Gateway. An unsigned workload URL left IAM Gateways returning 403. Without a catalog, the operator cannot tell a posture/authorizer mismatch from a missing target, a stale DEFAULT listing, or a workload name that cannot vend.
What changed (motivation → approach → change)
Single implementation PR, rebased onto
main. The docs-only plan (#6362) is closed as superseded. Spec-builder commits that accidentally rode along are gone.Goal: a Crew that names an identity and a Gateway URL can actually use that Gateway's MCP servers — and the operator can see why it is or is not working. AWS fetch is an opt-in extra installed by IaC or when identity is configured, not a default-wheel import and not a
kirocrew.pluginscompanion (that would flip the enterprise profile).Approach: sidecar path + localhost SigV4 proxy. Crew already writes
0600MCP env sidecars and injects servers onsession/new. Header-proxy MCP is not implemented.agent_identityslot +capabilities.agentcoreposturesAWS::BedrockAgentCore::WorkloadIdentity+ Settings → Security see/configure127.0.0.1SigV4 proxy (platform/agentcore_sigv4.py, servicebedrock-agentcore) so kiro-cli canInvokeGateway. Fail closed if the proxy cannot start. A WAT is never a Gateway bearer0600session sidecar. A companion JWT becomes RFC 6750Authorization: Bearer. Without one, the sidecar is URL-only (oauth_challenge) so kiro-cli can start its MCP OAuth challenge (_kiro.dev/mcp/oauth_request, already surfaced as Authorize). Login attach always writes the https Gateway URL, never the SigV4 proxy, even when leftover env posture is stillworkloadallow_agentcore_consent_url/oauth_endpoints.json) + GET/api/agentcore/consent; unknown hosts 403consent_host_refusedcron:/taskrunner:keys; workload user/OBO withoutvaultedOwnerTokenwrites a deny sidecar (disabled: true)SessionManager.remove, map preserved) before re-attach — not an mcp_gateway blue-green drainkirocrew[agentcore]extra (platform/agentcore_aws.py): lazy boto3GetWorkloadAccessToken/ForJWT. Bootstrap swaps onlyagent_identityon standalone when opted inworkload/login) and standalone boot callensure_extra()sokirocrew[agentcore]lands in the gateway interpreter when the home policy or env posture is already set. GET never pips. Desktop/PEP 668 reportsno_install_channelcapabilities.agentcore.gateway_urlandworkload_nameare policy-only likeposture. Runtime prefers the authored home file over leftover systemd env. Settings-only empty stays unnamed — do not inventkirocrew. Launch env posture without a systemd name still uses the RFC default. PUT posture-on without a name is 400workload_name_required.resolved_posture()is policy-first the same wayis_owner_dashboard_request, same gate as consent GET) reloads the home file onto the running ceiling and AWS adapter (apply_agentcore_runtime) and rebuilds the agent config.restart_requiredstays true only when that apply cannot attach the extratools/liston workload+IAM goes through the same localhost SigV4 proxy kiro-cli uses. A green tools check is no longer a direct signed POST to the Gateway hostname. Proxy start failure isproxy_unavailable.session_gateway_serversinjects the live loopback SigV4 listen URL ontosession/newso kiro-cli outranks a stale agent-file port after a gateway restart. The unsigned https Gateway hostname is never injected. The proxy prefers127.0.0.1:18765(KIROCREW_AGENTCORE_PROXY_PORToverrides; bind failure falls back to ephemeral)identitycheck (service_linked/identity_denied/not_named); login skips that probe. Sync refreshes a DEFAULT listing-mode target. Saving identity invalidates the catalog query so a posture/name change does not leave a stale green snapshot. Owner-onlyGET/POST /api/agentcore/gateway. Instance IAM inspect SID ongateway/*(Invoke stays onkirocrew-*). Cataloginvoke_scopeis credential-proved: green when tools/list just invoked via the SigV4 proxy, so a pasted existing Gateway is not falsely red. Prefix is the unproved fallback; a data-plane 401/403 isinvoke_denied.ListOauth2CredentialProvidersis not on this paneinstall.sh --agentcorewhenAgentCorePosture != none; systemdKIROCREW_AGENTCORE_GATEWAY_URL; CLI--agentcore-gateway-url(https only)Screenshots / video
Captured against the tagged e2e Gateway
kirocrew-e2e-n9pk1rdrea/ standalone identitykirocrew-e2ein account199621702461/us-east-1. Settings → Security → Identity. Files live undertemp-screenshots/agentcore-identity/.Full pane, login vs IAM mismatch, service-linked name, mobile
Saving identity invalidates the catalog query so a posture/name change does not leave a stale green snapshot. Save also hot-applies, so the restart banner is gone on a successful apply.
Tests
test/test_agentcore_inspect.py(URL parse, snapshot codes, mocked control plane, live LambdatargetConfigurationshape, identity check, invoke-scope proved via proxy / prefix fallback /invoke_denied, app-token refuse, no token material),test/test_agentcore_sigv4.py(region parse, localhost proxy forward, https-only ensure),test/test_agentcore_aws.py(mocked boto3 and pip; WAT probe discards the token; Settings-only empty name stays unnamed; hot-apply swaps ceiling+adapter),test/test_agentcore_gateway_inject.py(login URL-only OAuth-challenge sidecar; companion JWT →Bearer),test/test_agentcore_consent.py,test/test_agentcore_unattended.py, plus identity / IAM / principal / CPP / cloud launch coverage. SecurityPanel vitest covers verify, tools list, name-required Save disable, and the service-linked identity hint.Manual verification
Live against account
199621702461/us-east-1using local IAM (trackout-email). Tagged stackkirocrew:e2e=trueleft in-account.kirocrew-e2e-n9pk1rdrea(READY) + standalone identitykirocrew-e2e+ Lambda targetecho-hellokirocrew-*invoke scope, tools/listecho-hello___echo_hellotools/list,tools/call({"message":"hello proxy"})Authorizationboth 401. WAT vends (opaque).vend_gateway_inbound_tokenwithout a user JWT isNonekirocrew-e2e→ok; Gateway-linkedkirocrew-e2e-n9pk1rdrea→service_linked; defaultkirocrew→identity_denied. Token never in the snapshotworkload_name/gateway_url/posturewin over leftover systemd env. Settingsloginagainst this IAM Gateway shows the authorizer mismatch127.0.0.1) and emitsAuthorization: Bearernot_syncable. Target type is inferred frommcp.lambdabecause GetGatewayTarget omitstargetTypeLeftover-validation pass (live): Homebrew Python is PEP 668 (
pip install kirocrew[agentcore]exits 1; venv extra is ok).ListOauth2CredentialProvidersis empty;GetResourceOauth2Tokenagainst a missing provider isValidationException— Phase 5 stays out. Non-kirocrew-*Gatewayexisting-customer-oonks9wcjtis invoke-green under admin via proxy andinvoke_deniedunderkirocrew-e2e-instance. CUSTOM_JWT Gatewaykirocrew-e2e-jwt+ tagged Cognito test IdP: unsigned 401; Cognito IdToken +allowedAudienceinitialize/tools/list200; product login attach writesoauth_challengewithout a JWT andAuthorization: Bearerwith one. kiro-cli's hosted Authorize challenge was not driven.Still open (not v1 blockers): kiro-cli hosted MCP OAuth challenge; MCP initialize on this Gateway does not return
mcp-session-id; Phase 5GetResourceOauth2Token; desktop/PEP 668 extra; widening Invoke togateway/*.Live on this pass (instance-role + MCP_SERVER): assumed-role
kirocrew-e2e-instance(not admin) catalog/WAT/tools/list/Sync all green. MCP_SERVER targetpublic-docs/2L1SFWDBDEis READY, inferred frommcp.mcpServer, syncable, and listspublic-docs___tools next to the Lambda echo tool. FAILED targets now show AWSstatusReasonsin Settings.Live on the agent-path honesty pass: assumed-role
kirocrew-e2e-instancecatalogtools/listreportsvia=proxy,gateway_mcp_spec()ishttp://127.0.0.1:<port>/mcp, andtools/callecho-hello___echo_hellosucceeded through that listener. Isolated rebuild persists the proxy URL.Existing-Gateway honesty pass: catalog
invoke_scopegreens when tools/list succeeded via the SigV4 proxy, even if the Gateway id is notkirocrew-*. Prefix remains the unproved fallback. IAM documents are unchanged. Settings copy is credential-honest (this crew's AWS credentials), not instance-role-only.OOTB session-inject pass:
session/newinjects the live loopback proxy URL on workload (companion https specs still inject[]). Preferred listen port is18765. Isolated kiro-cli 2.20.1 rejected{name, url}(untagged enum McpServer); inject is now{name, type: http, url, headers}and deny uses a disabled HTTP placeholder. IsolatedKIRO_HOMEsession/new overrode the stale agent-file port, launchedagentcore-gatewaythrough the SigV4 proxy, and emitted_kiro.dev/mcp/server_initialized. Did not write~/.kiro/agents.Related Issues
Supersedes #6362
Checklist
bedrock-agentcoreSDK imports; boto3 is lazy inside the opt-in extraSecurity follow-up
Verified the review findings against this branch and closed the ones that still held:
agentcore-inboundis now on_CREW_SECRET_LEAVES(read+write+extract, both home prefixes). Same-UID0600is not a ceiling.reason=attach_failed) + SELagentcore.unattended_deniedso a workload agent-file Gateway cannot stay reachable. Human dashboard turns still do not fail solely because attach raised./api/agentcore/consentand PUT/api/agentcore/identityare owner-dashboard-cookie only (is_owner_dashboard_request); app tokens 403dashboard_owner_required. Catalog/verify/sync use the same owner gate.probe_instance_invoke_gateway()remains a public no-op False (companion override). Comments/docs now say False is "no mismatch detected", not "IAM inbound is impossible."127.0.0.1only; forwards solely to the configured Gateway host+path; never logs Authorization; WAT is still never a Gateway bearer.