Repository navigation
fix(agents): keep proxy-unsafe crew names out of every agent route path - #28628
iamwhatever merged 1 commit into
Conversation
Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.
Fixes #20083
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check: the diff only changes the request URLs the dashboard builds. It adds or changes no visible control, string or state, so the missing blind read leaves nothing unreviewed. [UX-REVIEWED] 6a10f8e Description read[DESCRIPTION-READ] 370d8a486b82d4e46e45dd6eb652dd38eb33c9ef6ebba150b1c46c162271a26b That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: each base64url route reuses its existing handler and owner gate, the only change is where the name is read from, nothing is removed, and the routes can be deleted later without migrating anything. Notes
[DESIGN-REVIEWED] 6a10f8e Description read[DESCRIPTION-READ] 360c8256fc0298206a907e05b29a5fcc953b38df4b1d4f2f0517484963314ebb That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This is a fix with a linked issue (#20083) and a written repro. Every new twin route has a caller, and the change fixes the cause: crew names that need encoding no longer go in the URL path. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let someone whose crewmate's name has a space use every crew screen behind a path-normalising proxy. FIX.
[FIRST-PRINCIPLES-REVIEWED] 6a10f8e Description read[DESCRIPTION-READ] 984e7856ec711203320e35d2893a810d1274f7fd8a4e58128234fc9d07df4a52 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Hold at 6a10f8e. This PR targets fix/agent-name-space-502 (stacked on #19981), not main, and it adds ten new /api/agents/b64/{name_b64} routes, which are reserved for human review. I found no defect: each twin reuses its path-form handler, so the owner gate runs first, and a non-canonical segment gets 400 name_segment_invalid ( ).What would clear it:
AI notes I judged non-blocking: the empty-name snapshot lookup before the 400 (nothing is written), the duplicated needs-encoding rule (both sides have unit tests), and the old Save predicate (the extra characters are not decoded by a proxy). — crew-pr-reviewer (r144) |
bolichen97
left a comment
There was a problem hiding this comment.
[operator: bolichen97] Approving at 6a10f8e, reviewed against its base fix/agent-name-space-502.
Each base64url twin route is registered to the same handler as its path-form twin, and the owner gate runs before the name is decoded, so auth is identical. decode_agent_name rejects non-canonical, padded and non-UTF-8 segments with a 400. The twins are strictly deeper paths, so a crew literally named b64 keeps its path-form routes. Avatar files are keyed by a digest of the name, so a decoded name cannot reach the filesystem.
Non-blocking suggestions:
- The
!'()*parity betweenagentPath.tsand the server-side check is a two-language invariant. A shared fixture test would keep the two from drifting. - The
agent_url_pathimports in the change-card catalog modules could move to module scope.
This PR is stacked, so it lands after #19981.
AI-assisted, approved by bolichen97
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
…th (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
* fix(agents): send proxy-unsafe crew names in the request body Fixes #19976 When a crew's config.json key contains a space (e.g. 'My Agent'), saving from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse proxy that normalises percent-encoded paths decodes %20 to a literal space, which is the HTTP request-line delimiter and causes a 502. Fix: add PUT /api/agents (no path variable) that reads the crew name from a 'name' field in the JSON body. The frontend uses this body-form route automatically when encodeURIComponent(name) !== name, so a space-containing key is never placed in a URL path segment a proxy can misinterpret. The existing PUT /api/agents/{name} is unchanged for slug-keyed agents. The api_kirocrew_agent_update handler now serves both routes: it reads the name from the URL path when present, or from the request body when the path-variable route is not matched. The body name is used verbatim (never stripped) so a stored key that differs only by edge whitespace is not silently overwritten. Both forms share all update logic including _require_owner, so auth and owner checks are identical. change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and describe_manual_change so memory events are recorded for body-form saves the same way they are for path-form saves. Security: test_agents_endpoints_owner_auth.py already walks all routes and verifies owner-gating; PUT /api/agents is added to its floor set. test_agent_update_body_form.py pins auth parity between both routes. * docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action * fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 Co-authored-by: Zezhen Xu <zezhexu@amazon.com> --------- Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
* fix(agents): send proxy-unsafe crew names in the request body Fixes #19976 When a crew's config.json key contains a space (e.g. 'My Agent'), saving from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse proxy that normalises percent-encoded paths decodes %20 to a literal space, which is the HTTP request-line delimiter and causes a 502. Fix: add PUT /api/agents (no path variable) that reads the crew name from a 'name' field in the JSON body. The frontend uses this body-form route automatically when encodeURIComponent(name) !== name, so a space-containing key is never placed in a URL path segment a proxy can misinterpret. The existing PUT /api/agents/{name} is unchanged for slug-keyed agents. The api_kirocrew_agent_update handler now serves both routes: it reads the name from the URL path when present, or from the request body when the path-variable route is not matched. The body name is used verbatim (never stripped) so a stored key that differs only by edge whitespace is not silently overwritten. Both forms share all update logic including _require_owner, so auth and owner checks are identical. change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and describe_manual_change so memory events are recorded for body-form saves the same way they are for path-form saves. Security: test_agents_endpoints_owner_auth.py already walks all routes and verifies owner-gating; PUT /api/agents is added to its floor set. test_agent_update_body_form.py pins auth parity between both routes. * docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action * fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 --------- (cherry picked from commit 4d0ae46) Originally authored on main by Zezhen Xu (CrysisDeu); authored here with the public identity because the commit guard accepts only that identity.
* fix(agents): send proxy-unsafe crew names in the request body Fixes #19976 When a crew's config.json key contains a space (e.g. 'My Agent'), saving from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse proxy that normalises percent-encoded paths decodes %20 to a literal space, which is the HTTP request-line delimiter and causes a 502. Fix: add PUT /api/agents (no path variable) that reads the crew name from a 'name' field in the JSON body. The frontend uses this body-form route automatically when encodeURIComponent(name) !== name, so a space-containing key is never placed in a URL path segment a proxy can misinterpret. The existing PUT /api/agents/{name} is unchanged for slug-keyed agents. The api_kirocrew_agent_update handler now serves both routes: it reads the name from the URL path when present, or from the request body when the path-variable route is not matched. The body name is used verbatim (never stripped) so a stored key that differs only by edge whitespace is not silently overwritten. Both forms share all update logic including _require_owner, so auth and owner checks are identical. change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and describe_manual_change so memory events are recorded for body-form saves the same way they are for path-form saves. Security: test_agents_endpoints_owner_auth.py already walks all routes and verifies owner-gating; PUT /api/agents is added to its floor set. test_agent_update_body_form.py pins auth parity between both routes. * docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action * fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628) Every crew route that names the crew in its URL path also answers under /api/agents/b64/{name_b64}..., an unpadded base64url segment, so a path-normalising proxy has no %20 to decode into a bare space (502). The twins reach the same handlers behind the same owner gate. The dashboard (delete, avatar upload and image, capabilities, worker kit) and change-card Apply/Undo steps use the twin or the body-form PUT for such names; the card hook reads a twin as its path-form route. Fixes #20083 --------- (cherry picked from commit 4d0ae46) Originally authored on main by Zezhen Xu (CrysisDeu); authored here with the public identity because the commit guard accepts only that identity.
Problem / Motivation
Goal: A crew whose name has a space (or another character that needs URL encoding) works behind a path-normalising proxy on every crew screen, not only on a plain Save.
Stacked on #19981 (base
fix/agent-name-space-502), which movedPUT /api/agents/{name}to a body form. Every sibling route still puts the encoded name in the URL path:/api/agents/Nova%20Sky/capabilities. A path-normalising proxy decodes%20back to a bare space, the space ends the HTTP request line, and the user sees a 502. #20083 lists them: Delete, the avatar upload (a Save with a new picture) and the avatar image, Approvals (capabilities get/preview/save/detach), the worker kit, and the change-card Apply/Undo steps that call the same routes.Why it matters
Anyone who names a crewmate with a space ("Nova Sky") and reaches the dashboard through such a proxy cannot open its Approvals or worker kit, cannot change its picture, cannot delete it, and cannot apply or undo a crewmate card for it. #19981 alone fixes only the plain Save.
Not a goal
/api/agents/detail/{name}addresses a template,/api/members/{slug}a slug).What changed (motivation → approach → change)
Symptom: 502 on every crew route for a name with a space behind a path-normalising proxy. Root cause: the name rides the URL path percent-encoded, and the proxy decodes it. Change: such a name never rides the path.
/api/agents/b64/{name_b64}.... The segment is unpadded base64url of the UTF-8 name, so it holds only[A-Za-z0-9_-]and a proxy has nothing to decode. Routes:DELETE,GET/POST .../avatar,GET/PUT .../capabilities,POST .../capabilities/preview,POST .../capabilities/detach,GET/PUT .../worker-kit,POST .../worker-kit/preview(src/kiro_crew/dashboard/routes/agents.py).agent_route_nameafter the owner check (dashboard/agent_name_segment.py). A non-canonical segment (padding, spare bits set, not UTF-8) gets400 name_segment_invalid, so one name has exactly one spelling (kiro_crew/agent_url_path.py).b64keeps its own routes. aiohttp tries the longer static prefix first, so this does not rely on registration order; a test pins it.website/src/api/agentPath.ts): delete, avatar upload, avatar image, capabilities and worker kit use the twin for such names. Plain names keep the old path. Both sides use the same "needs encoding" rule (Python'squote(safe=""), so!'()*also take the twin).crewmate.updateApply/Undo usePUT /api/agentswith the name in the body;crewmate.create/importUndo andcrewmate.capabilitiesuse the twin. The hook reads a twin as its path-form template (change_cards.route_key) and decodes the name (route_match_info), so step checks, the memory line and the undo identity guards behave the same. Thecrewmate.updateundo guard now also arms on the body-form path.docs/system-specs/modules/crew-mode.mdsection "Crew names a proxy would mangle"; two feature-map rows.Design choice. #20083's action says GETs use a base64url segment and writes take the name in the body. I used the base64url segment for the writes too:
POST .../avataris multipart, so a body name would need a second parsing path.DELETEbody.PUT /api/agentskeeps the body form #19981 ships. Body-form writes lost on the three points above.Intended? / Repro
Intended? No. #20083 is a deferred finding from #19981's review: the sibling routes were known to share the bug. On
mainthe paths are built withencodeURIComponent/_qand registered with{name}in the path:src/kiro_crew/dashboard/routes/agents.py:47-55,62,65-66website/src/api/crewCapabilities.ts:62,104,website/src/api/client/agents.ts:566,612,website/src/components/CrewAvatar.tsx:425src/kiro_crew/change_card_catalog.py:256,271,src/kiro_crew/change_card_catalog_plans.py:566,1192,1319Repro. Crew named
Nova Sky, dashboard behind a path-normalising proxy (the #19976 setup). Opening the crew's Approvals sendsGET /api/agents/Nova%20Sky/capabilities; the proxy forwardsGET /api/agents/Nova Sky/capabilities HTTP/1.1, the space ends the request line, and the user sees a 502. Same for Delete, a new-avatar Save, the worker kit, and applying or undoing a crewmate card. With this change the request isGET /api/agents/b64/Tm92YSBTa3k/capabilities.Backwards compatibility
Compatible: every path-form route stays registered and unchanged, plain names still use it, and the twins are new paths no client used before.
Removes nothing: only routes and call-site spellings are added; no route, field or record is removed or narrowed.
Tests
test/test_agent_b64_routes.py: encoding round trip and every non-canonical refusal; each twin reaches its path-form handler; no twin can shadow a path-form route, and a crew namedb64resolves to its own routes; non-owner 403 on every twin; owner with a bad segment gets 400; card plans for both name forms; hook aliasing and name decoding.test/test_agents_endpoints_owner_auth.py: the two mutating twins inhandlers.agentsjoin the owner-gate floor.test/test_change_cards_identity.py: thecrewmate.updateundo guard arms on the body-formPUT /api/agents.website/src/api/agentPath.test.ts: path form for plain names; base64url (UTF-8, URL-safe) for others, including!'()*.Proof: not provable -- other: no local test runs on this host; CI runs the suite and each new test asserts the new spelling.
Local static gates: black, isort, flake8, mypy (changed modules), tsc, eslint.
Manual verification
N/A: no proxy setup on this host. The request spelling is pinned by unit tests on both client and server, and the twins reuse the existing handlers unchanged.
Screenshots / video
Why no screenshot: Only the request URLs change; every screen, including the avatar image, renders exactly as before.
Related Issues
Fixes #20083. Stacked on #19981 (fixes #19976).
Sibling sweep
Swept: git grep -nE "/api/agents/['"]? ?+|/api/agents/${|/api/agents/{" -- src website/src
Sibling: website/src/api/crewCapabilities.ts -- changed here
Sibling: website/src/api/client/agents.ts -- changed here
Sibling: website/src/components/CrewAvatar.tsx -- changed here
Sibling: src/kiro_crew/change_card_catalog.py -- changed here
Sibling: src/kiro_crew/change_card_catalog_plans.py -- changed here
Sibling: src/kiro_crew/dashboard/routes/agents.py -- changed here
Pattern harvest
Rule candidate: review-prompt
Pattern: a user-chosen name placed in a URL path segment with encodeURIComponent; use agentPath or a body field instead.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.