Skip to content

fix(shared-crew): keep the portability export and import the owner's - #38294

Open
KiroCrewCaptain wants to merge 1 commit into
mainfrom
fix/portability-owner-only-for-teammates
Open

KiroCrewCaptain wants to merge 1 commit into
mainfrom
fix/portability-owner-only-for-teammates

Conversation

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Problem / Motivation

Goal: A Shared Crew teammate can no longer download the owner's raw config through the portability export, or overwrite it through the import, as on main before #38209.

Since #38209 the owner gate (source_providers.is_owner_dashboard_request) admits a Shared Crew teammate on every route that shared_crew.teammate_access.is_owner_only_for_teammates does not list, and /api/portability is in none of its entries. So a teammate gets GET /api/portability/export, whose archive carries config.json and the settings documents raw, and POST /api/portability/import, which rewrites them.

Why it matters

The export carries the owner's raw config, which can hold channel bot tokens and agent env secrets, and a teammate keeps that download after the owner revokes their access. The import, in replace mode, lets a teammate overwrite the owner's config and settings. Every owner who shares a Crew through an SSM invite, a team Crew relay or a Tailscale path is exposed. On main before #38209 both routes refused every teammate.

Not a goal

  • Narrowing any other route a teammate reaches since fix: let every shared crew teammate act as the owner inside the crew #38209. Any other owner-gated route that needs a change for teammates gets its own change.
  • Changing what a relayed remote caller gets: kiro_relay.limits.remote_route_limit and is_local_credential_path are untouched.
  • Redacting the export for a teammate, or offering a teammate a narrower export. The routes go back to owner-only, as before.
  • The import preview, which reads only the uploaded archive and asks no owner gate.

What changed (motivation → approach → change)

  • Symptom: a teammate passes the owner gate on the portability export and import.
  • Root cause: fix: let every shared crew teammate act as the owner inside the crew #38209 made the owner gate admit a teammate on every route its owner-only table does not list, and that table had no entry for portability. The table already holds the other credentials that outlive a teammate's access (CRON_SECRET_GRANTS, CHANNEL_CONNECTION_WRITES, and the relay's path table).
  • Change: teammate_access.PORTABILITY_ROUTES matches /api/portability and every route under it, and is_owner_only_for_teammates returns true for it, so both handlers' existing require_owner_dashboard_request answers a teammate 403 owner_only. The entry sits in the teammate table, not in the relay's remote_route_limit, so a relayed remote caller's boundary does not move. The module docstring and docs/system-specs/modules/shared-crew.md ("What a teammate may do") now say why portability stays the owner's.

Backwards compatibility

Breaking: a Shared Crew teammate's GET /api/portability/export and POST /api/portability/import answer 403 owner_only again, as they did before #38209. Writer sweep on origin/main @ ed37d89: git grep -n "api/portability" finds one client, the dashboard's Portability card, which shows a 403 inline; the CLI and the snapshot code call the portability module in process and never reach the route; an app token never passed the owner gate.

Reader: website/src/pages/overview/PortabilityTab.tsx:PortabilityTab -- crew page -- a teammate's export or import shows the 403 inline, as before #38209; PortabilityTab.staleOwner.test.tsx "leaves a 403 owner_only denial to the inline error alone"
Reader: src/kiro_crew/dashboard/handlers/portability.py:api_portability_export -- crew page -- the machine owner still gets past the gate; test_the_owner_still_reaches_the_portability_export_and_import
Reader: src/kiro_crew/dashboard/handlers/portability.py:api_portability_import -- crew page -- the machine owner still gets past the gate; test_the_owner_still_reaches_the_portability_export_and_import
Reader: src/kiro_crew/dashboard/handlers/portability.py:api_portability_preview -- crew page -- asks no owner gate, so nothing changes for anyone; test_api_portability.py
Reader: src/kiro_crew/dashboard/kiro_relay/limits.py:remote_route_limit -- release -- not edited, so a relayed remote caller's route boundary is unchanged; test_kiro_relay_caller_identity.py

Tests

  • test_the_portability_export_and_import_stay_the_owners: for an SSM invite guest, a Tailscale collaborator and a relay teammate, GET /api/portability/export (with and without a query, and with a trailing slash) and POST /api/portability/import (merge and mode=replace) are owner-only, the owner gate refuses them, and the machine owner still passes.
  • test_a_teammate_is_refused_the_portability_export_and_import: through the real handlers, each teammate gets 403 owner_only from both routes and never reaches the export planner or the upload reader.
  • test_the_owner_still_reaches_the_portability_export_and_import: the machine owner gets past the gate into both handlers (control; passes with and without the fix).
  • With the teammate_access.py change reverted, the 18 teammate cases fail and the owner control passes.
  • Related suites: every test/test_shared_crew_*.py, every test/test_*portability*.py, test_kiro_relay_caller_identity.py, test_members_roster_relay_teammate.py, test_multipart_routes_wrong_body.py and test_snapshot_memory_stores.py (103 files): 2466 passed, 9 skipped.

Proof: PROVEN test/test_shared_crew_teammate_owner_access.py::test_the_portability_export_and_import_stay_the_owners[ssm-GET-/api/portability/export], test/test_shared_crew_teammate_owner_access.py::test_the_portability_export_and_import_stay_the_owners[ssm-GET-/api/portability/export?include_sessions=true], test/test_shared_crew_teammate_owner_access.py::test_the_portability_export_and_import_stay_the_owners[ssm-GET-/api/portability/export/], test/test_shared_crew_teammate_owner_access.py::test_the_portability_export_and_import_stay_the_owners[ssm-POST-/api/portability/import], test/test_shared_crew_teammate_owner_access.py::test_the_portability_export_and_import_stay_the_owners[ssm-POST-/api/portability/import?mode=replace] (head e824484)

Manual verification

N/A: unit coverage drives the real owner gate and both real handlers for each teammate shape and for the owner; the change is one table entry read by that gate.

Screenshots / video

N/A: the diff touches no frontend file.

Related Issues

Part of #38188

Sibling sweep

Swept: git grep -nE "require_owner_dashboard_request|require_owner_for_dashboard_caller|is_owner_dashboard_request|_authorize_owner_request" -- src/ (the routes that hand back stored config or secret values)
Sibling: src/kiro_crew/dashboard/handlers/core_config_view.py:128 -- not affected -- GET /api/config/kirocrew masks every sensitive value for every reader, the owner included
Sibling: src/kiro_crew/dashboard/messaging_api/slack_settings.py:103 -- not affected -- a channel config read returns masked token previews, and its writes are already in CHANNEL_CONNECTION_WRITES
Sibling: src/kiro_crew/crewmate_bundle_export.py:219 -- not affected -- the member export replaces every MCP env, headers and clientSecret value with a placeholder
Sibling: src/kiro_crew/dashboard/kiro_relay/limits.py:120 -- not affected -- the vault, local tokens and app secrets are already owner-only for teammates through remote_route_limit

Pattern harvest

Rule candidate: review-prompt
Pattern: a gate that widens from an allow-list to "everything except a deny-list" must sweep every route the old gate held for raw credential reads and ceiling writes, and add each to the deny-list in the same change.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@KiroCrewCaptain
KiroCrewCaptain requested a review from a team as a code owner November 17, 2026 06:34
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7b14c64f7b5f1808f236554423092157ca2c1a4e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7b14c64f7b5f1808f236554423092157ca2c1a4e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. One entry in the existing teammate deny-list puts portability back behind the owner gate, it is the one place that gate reads, and the relay's limit is unchanged.

Notes

  • PORTABILITY_ROUTES also matches the preview route. That changes nothing today because the preview asks no owner gate. If the preview ever gains one, teammates will be refused it without anyone choosing that.

[DESIGN-REVIEWED] 7b14c64

Description read

[DESCRIPTION-READ] a963b14a14d52e2a07a11c7bddd59d2ce6b0c237c36af58a6389fe9f3fa44ddf

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7b14c64f7b5f1808f236554423092157ca2c1a4e — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. One regex entry in the existing teammate owner-only table puts back the portability refusal that #38209 dropped. Before #38209 the base already refused teammates on these routes, so this is a restore and not a new shape.

What this change ships

Inventory (4 items) — 4 justified

Intent: the owner's raw config can no longer be downloaded or overwritten by a Shared Crew teammate through portability export/import. This is a FIX.

  1. A teammate gets 403 owner_only on GET /api/portability/export. — justified
  2. A teammate gets 403 owner_only on POST /api/portability/import (merge and replace). — justified
  3. A new exported symbol, teammate_access.PORTABILITY_ROUTES, has one consumer, is_owner_only_for_teammates. Its siblings CRON_SECRET_GRANTS and the others are exported the same way. — justified
  4. The spec in shared-crew.md and the module docstring now say why portability stays the owner's. — justified

[FIRST-PRINCIPLES-REVIEWED] 7b14c64

Description read

[DESCRIPTION-READ] e60af208a075bade176343c5b17b4bfd952168494fb973c9d4ad1b28b3d3fb12

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 Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7b14c64

Verdict parsed from the review's SHA-scoped output markers for commit 7b14c64f7b5f1808f236554423092157ca2c1a4e.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7b14c64f7b5f1808f236554423092157ca2c1a4e false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7b14c64f7b5f1808f236554423092157ca2c1a4e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7b14c64

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7b14c64f7b5f1808f236554423092157ca2c1a4e false-positive: <reason, 20 to 500 characters>

@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 Nov 17, 2026
Since #38209 the owner gate admits a Shared Crew teammate on every
route the owner-only table in shared_crew.teammate_access does not
list, and /api/portability was in none of its entries. The export
writes config.json and the settings documents, config.local.json
among them, raw into the archive, so a channel bot token or an agent
env secret a teammate downloaded would outlive their access. The
import, with mode=replace, overwrites the owner's config.

Add PORTABILITY_ROUTES to that table, so is_owner_only_for_teammates
keeps every /api/portability route the machine owner's and the export
and import refuse a teammate 403 owner_only. This restores main's
behaviour from before #38209, when both routes refused every teammate.
The relay's remote_route_limit is unchanged, so what a relayed remote
caller gets does not move, and the preview, which asks no owner gate,
is unaffected.
@KiroCrewCaptain
KiroCrewCaptain force-pushed the fix/portability-owner-only-for-teammates branch from e824484 to 7b14c64 Compare November 17, 2026 08:03
@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 Nov 17, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator Author

The review found nothing blocking on this head. This change narrows who can use an owner gate, so a maintainer gives the final approval.

What the review checked on 7b14c64:

  • PORTABILITY_ROUTES feeds into is_owner_only_for_teammates. Both portability handlers already call require_owner_dashboard_request before doing any work, so every teammate shape (SSM guest, Tailscale collaborator, relay teammate) gets 403 owner_only on export and import again. The machine owner still gets through.
  • With the production line reverted, the 18 teammate cases fail and the owner control passes, as the body says. Narrowing or deleting the regex also turns tests red.
  • The added tests bind port 0, do not sleep, and stub the planner, the upload reader and the audit log write through monkeypatch.

Security: the change only tightens access. It brings back owner-only export and import as they were before #38209, and #38209 is not in any release. The relay's remote_route_limit boundary does not move. The preview route behaves the same as before.

Done well: the fix lives in the one table the shared owner gate reads, so no handler needed an edit. The end-to-end tests prove a teammate never reaches the export planner or the upload reader.

Optional:

  • The prefix regex also matches /api/portability/preview, but the spec says the preview asks for no owner gate. You could anchor the regex to export and import, or say in the spec that the table covers the whole prefix.
  • test_the_portability_export_and_import_stay_the_owners repeats the shape of test_a_credential_that_outlives_access_stays_the_owners. You could add the five portability rows to the existing list instead.
  • The Proof line in the body names e824484. The patch on 7b14c64 is identical, so you could update the SHA.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants