Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion deploy/k8s/identity-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ data:
error_shape = "aws"
pass_headers = ["tokentype"]

[[route]]
name = "kiro-cps"
# Host observed by DNS/SNI only (kiro-cli 3.3.0, no real request): docs/recipes/kiro-cli.md.
# pass_headers = ["tokentype"] follows kiro-krs. Whether the cps service needs or sends
# tokentype, and its error shape, are NOT measured.
host = "management.us-east-1.kiro.dev"
error_shape = "aws"
pass_headers = ["tokentype"]

[[credential]]
id = "kiro"
source = "k8s:auth-proxy-kiro:api_key"
routes = ["kiro-krs"]
routes = ["kiro-cps", "kiro-krs"]

[[grant]]
identity = "pty-team-a"
Expand All @@ -39,5 +48,14 @@ data:
paths = ["/"]
aws_targets = ["AmazonCodeWhispererStreamingService.GenerateAssistantResponse"]

# No aws_targets here: the cps targets seen on the wire (GetProfile, ListAvailableModels) came
# from a capture against a local listener, not from the real host.
[[grant]]
identity = "pty-team-a"
credential = "kiro"
route = "kiro-cps"
methods = ["POST"]
paths = ["/"]

[egress]
allow = ["github.com:443", "registry.npmjs.org:443"]
4 changes: 3 additions & 1 deletion docs/design/phase1.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ Follow-ups attached to the decision:
- `ap-egress` connects to the exact address it validated and never resolves the name a second
time (DNS rebinding).
- The platform sets `NO_PROXY=127.0.0.1,localhost` next to `HTTPS_PROXY`.
- A test confirms that kiro-cli sends `X-Amz-Target` before any grant relies on `aws_targets`.
- [x] A test confirms that kiro-cli sends `X-Amz-Target` before any grant relies on `aws_targets`.
Done for kiro-cli 3.3.0, one call each, no real request [M, `docs/evidence/xamz-target.md`].
Re-check after a kiro-cli upgrade.
- The combined Option A rule set is measured in one pod before release.

Remaining risk, accepted: the agent can still send data to allowlisted hosts such as github.com,
Expand Down
39 changes: 39 additions & 0 deletions docs/evidence/xamz-target.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# kiro-cli `X-Amz-Target` measurement

Result: kiro-cli 3.3.0 sends exactly one `X-Amz-Target` header on every call captured. The model call carries `AmazonCodeWhispererStreamingService.GenerateAssistantResponse`.

- Real requests to the live service: **0**. No real credential was used or read.
- Host: one macOS laptop, `kiro-cli 3.3.0`.

## How it was captured

1. A throwaway HOME and working directory under `/tmp`.
2. A local capture listener on `127.0.0.1` (plain HTTP). It logged the method, path, header names, the `X-Amz-Target` value and the body length, and no other header value. It answered every request with a 400 AWS-shaped error.
3. The four service endpoints were pointed at the listener with `kiro-cli settings api.{codewhisperer,krs,cps,q}.service '{"endpoint":"http://127.0.0.1:<port>/tag-<key>","region":"us-east-1"}'`.
4. `KIRO_API_KEY` was a random surrogate (`aps_` plus 32 hex). `HTTPS_PROXY` unset, telemetry and auto-update off.
5. One run: `kiro-cli chat --no-interactive --trust-tools= "say hi"`.

## Evidence (7 captured requests, all `POST /`)

| Endpoint key | `X-Amz-Target` (header count) | Calls |
|---|---|---|
| `api.krs.service` | `AmazonCodeWhispererStreamingService.GenerateAssistantResponse` (1) | 1 |
| `api.cps.service` | `AmazonCodeWhispererService.GetProfile` (1) | 1 |
| `api.cps.service` | `KiroControlPlaneBearerService.ListAvailableModels` (1) | 4 (retries after the 400) |
| `api.codewhisperer.service` | `AmazonCodeWhispererService.SendTelemetryEvent` (1) | 1 |

Header names on every request: accept, accept-encoding, amz-sdk-invocation-id, amz-sdk-request, authorization, content-length, content-type, host, tokentype, user-agent, x-amz-target, x-amz-user-agent, x-amzn-codewhisperer-optout. The model call also sent `x-amzn-kiro-attempt`. Its body was 28843 bytes.

## Consequence for `aws_targets`

- The header is present and single-valued on all captured calls, so a "zero or two headers means deny" rule does not trip on kiro-cli traffic.
- A grant on the krs route that lists only `GenerateAssistantResponse` matches the observed model call.
- kiro-cli also calls other targets on other routes (`GetProfile`, `ListAvailableModels` on cps; `SendTelemetryEvent` on codewhisperer). Those routes need their own `aws_targets` list or none.
- No shipped policy uses `aws_targets` for the cps or codewhisperer routes.

## Not verified

- Only one `chat` run on one version (3.3.0) and one host.
- The model call was answered with an error, so only the first attempt on the krs route was seen. Tool-use and resumed turns were not exercised.
- The cps and codewhisperer targets were seen against a local listener, not the real hosts.
- Re-check after a kiro-cli upgrade.
25 changes: 18 additions & 7 deletions docs/recipes/kiro-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@ Each of the four kiro-cli services points at one route. The base URL is

| cli.json key | Route (path segment) |
|---|---|
| `api.cps.service` | `kiro-cps` |
| `api.krs.service` | `kiro-krs` |
| `api.cps.service` | `kiro-cps` (host `management.us-east-1.kiro.dev`) |
| `api.krs.service` | `kiro-krs` (host `runtime.us-east-1.kiro.dev`) |
| `api.codewhisperer.service` | `kiro-cw` |
| `api.q.service` | `kiro-q` |

Each entry also sets `"region": "us-east-1"`. The file is an object of the form
`{"api.cps.service": {"endpoint": "...", "region": "us-east-1"}, ...}`.

**The shipped identity file defines one route only.** `deploy/k8s/identity-configmap.yaml` defines
`kiro-krs` and its grant. Before the other three services work, add the `kiro-cps`, `kiro-cw` and
`kiro-q` routes, with a credential grant for each, to `identity.toml`. Until then the proxy answers
those routes with `404 route_unknown`.
**The shipped identity file defines two routes.** `deploy/k8s/identity-configmap.yaml` defines
`kiro-krs` and `kiro-cps`, each with a grant. Before `api.codewhisperer.service` and `api.q.service`
work, add the `kiro-cw` and `kiro-q` routes, with a credential grant for each, to `identity.toml`.
Until then the proxy answers those routes with `404 route_unknown`.

**Not measured for `kiro-cps`.** The host `management.us-east-1.kiro.dev` was observed by DNS/SNI
only (kiro-cli 3.3.0, no real request, no real credential). Whether the cps service needs the
`tokentype` header and what its error body looks like are unmeasured. The route uses
`pass_headers = ["tokentype"]` and `error_shape = "aws"` because `kiro-krs` does; both are
assumptions until a real first response is checked. kiro-cli also probes `management.*` hosts in
other regions, which the shipped route does not cover.

The proxy listens on plain `http://` on loopback, which kiro-cli accepts. The hop from the agent to
the proxy never leaves the pod.
Expand Down Expand Up @@ -83,5 +90,9 @@ of these two options:

## 6. Checks before you rely on this recipe

- Confirm that kiro-cli sends `X-Amz-Target` before any grant uses `aws_targets`.
- kiro-cli 3.3.0 sends one `X-Amz-Target` per call [M, `docs/evidence/xamz-target.md`]. Re-check
after a kiro-cli upgrade. Other targets exist on `cps` (`GetProfile`, `ListAvailableModels`) and
`codewhisperer` (`SendTelemetryEvent`), seen only against a local capture listener. A grant on
those routes needs its own `aws_targets` list or none. No shipped policy uses `aws_targets` for
them.
- Run the Phase 1 Kubernetes test, which applies the combined rule set in one pod.
Loading