Skip to content

fix(apps): require the dashboard owner to enable an app - #14948

Merged
bolichen97 merged 2 commits into
mainfrom
fix/owner-gate-round12-enable
Sep 29, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
fix/owner-gate-round12-enable

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Only the dashboard owner can enable an app.

POST /api/apps/{name}/enable (handle_enable_app in src/kiro_crew/apps/routes.py) refused app tokens. It checked the owner only when the body carried sessionApprovalConsent. So a signed-in dashboard user who is not the owner could turn an owner-disabled app back on.

Why it matters

Enable is not a flag flip. It registers the app's agents, skills, MCP servers and crons. It starts the app's backend. It runs the app's onEnable script. A channel user who may chat should not be able to start that code. Disable and uninstall in the same file already require the owner.

Not a goal

  • No change to the gate itself, the token middleware, or the app manager.
  • The app-token refusal stays first and keeps its app_token_forbidden code.
  • The consent branch stays as it is.
  • POST /api/apps/{name}/open, POST /api/apps/{name}/dev and DELETE /api/apps/{name}/migrate-cleanup are not touched.

What changed (motivation → approach → change)

Enable skipped the owner check that disable runs. It read the app and the body before it checked who was calling.

The handler now calls require_owner_dashboard_request(request, "app_enable") right after the app-token refusal. This is the same call disable uses. It runs before the app lookup and before the body is read. A non-owner gets 403 owner_only, and the gate writes the denial to the audit log.

Every real caller still works. The dashboard Library, the Mochi and crew-companion pages, and kirocrew app enable all send the owner's credential. The CLI sends the same credential for enable and disable, and disable is already gated.

Backwards compatibility

Breaking: a non-owner dashboard subject calling enable now gets 403 instead of enabling the app. Writer sweep on origin/main @ 3b0f4ad: website/src/api/client/apps.ts, website/src/apps/mochi/api.ts, website/src/apps/crew-companion/constants.ts and src/kiro_crew/app_lifecycle_client.py all send the owner's credential. No other in-tree code calls the route.

Tests

  • test/test_apps_routes_coverage.py::TestEnableRefusesAppTokens::test_non_owner_dashboard_user_cannot_enable is new. A non-owner posts enable with no consent body. It asserts 403 owner_only, no backend start, no onEnable, and the app still disabled. It fails with 200 when the gate is removed.
  • Tests that enable as a caller with no identity now act as the owner. Only the identity changed: test_app_execution.py, test_apps_routes_coverage.py, test_enable_deps_resolution.py, test_lifecycle_hooks.py.
  • Two hook tests in test_apps_routes_coverage.py also set broadcast_ws on the test state. They used to run with no state at all. The owner gate needs a state, and the hook wiring then reads broadcast_ws from it.
  • test_enable_does_not_re_register_after_the_backend_starts now asserts the 200 status. Without it, a refused enable would pass the test without testing anything.
  • Targeted run: the 7 app enable test files, 420 passed.

Manual verification

N/A. Unit coverage is enough because the route is exercised through the real route table with the real gate.

Related Issues

N/A

Pattern harvest

Not generalizable: this is the same missing-owner-gate shape the earlier rounds fixed in this file, and the fix reuses the shared gate.

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

@iamwhatever
iamwhatever requested a review from a team as a code owner September 29, 2026 06:11
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify the release PR's changelog names the breaking 403 for non-owner dashboard callers of enable, since the writer sweep covered in-tree callers only.

[DESIGN-REVIEWED] 165c3e3

Description read

[DESCRIPTION-READ] 83f2e6bf9b05f5503e4ad9ab2d67613514ac3a5aae752a50beea5df0a846a72f

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 165c3e36b263eba2c263ada8b248eb05b470b6ed and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 165c3e3

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 165c3e36b263eba2c263ada8b248eb05b470b6ed — 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.

First-Principles-Verdict: CONCERNS

The new gate deadens the consent-branch owner check at routes.py:1931-1938 — the same predicate re-run on the same request can never deny again.

Not justified as shipped

  • Item 4 — duplicate of src/kiro_crew/apps/routes.py:1910: "The consent branch stays as it is" keeps a second require_owner_dashboard_request call that the new unconditional call renders unreachable-as-a-denial; its app_enable_session_consent audit can no longer fire, so it is a dead second spelling this PR itself creates.
    Subtraction: delete the consent-branch gate (routes.py:1931-1938, the comment, the local import and the denied check); the outer gate at line 1910 is the whole control.
    Clears when: the inner gate is deleted, or a denial it can still produce is demonstrated.

What this change ships

Inventory (6 items) — 5 justified

Intent: stop a signed-in non-owner dashboard user from enabling (and thereby starting) an app the owner disabled — a FIX.

  1. A non-owner dashboard user posting enable now gets 403 owner_only instead of the app starting — justified
  2. That refusal is written to the audit log — justified
  3. Owner check now runs before the app lookup, so a non-owner sees 403 instead of 404 for unknown app names — justified
  4. The consent-branch owner gate can no longer deny anything — duplicate of src/kiro_crew/apps/routes.py:1910 (see above)
  5. New test pins the 403, no backend start, no onEnable — justified
  6. Existing enable tests now call as the owner (plus broadcast_ws on the test state, a 200 assert) — justified

[FIRST-PRINCIPLES-REVIEWED] 165c3e3

Description read

[DESCRIPTION-READ] 4d1f8cfd0c220746697cddbf66776af99e9359ba6901d03f6c08728cfa31d6e4

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 165c3e36b263eba2c263ada8b248eb05b470b6ed — this comment is updated in place on each push.

Review details

No findings that block; one advisory below.

FINDING — src/kiro_crew/apps/routes.py:1936 — the new gate at :1910 runs the identical is_owner_dashboard_request predicate over request["user"]/request["app"]/state.owner_id, none of which the intervening lines (get_app, request.json()) mutate, so require_owner_dashboard_request(request, "app_enable_session_consent") can now only ever return None: a non-owner consent POST is refused by the outer gate and its SEL denial row is written with operation="app_enable", losing the distinction between "tried to enable an app" and "tried to hand an app control of the owner's sessions" → Fix: parse sessionApprovalConsent before the single gate and pass the label into it ("app_enable_session_consent" if session_approval_consent else "app_enable"), deleting the now-unreachable block at 1931–1938.

[OPUS-REVIEWED] 165c3e3

Verdict parsed from the review's SHA-scoped output markers for commit 165c3e36b263eba2c263ada8b248eb05b470b6ed.

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=dad9cf90636a, the consent gate is now redundant with the new enable gate).

The redundancy is accepted on purpose, as the clearing condition allows. The fix brief for this finding said to keep the consent branch as it is.
Keeping it holds this security fix to one added call on one handler.
The inner gate is the same predicate on the same request, so no caller sees a different outcome: a non-owner gets 403 either way.
It also stays correct if the outer gate ever moves. Removing it is a cleanup, not a defect fix.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=63305eadfce3, the inner consent gate can no longer deny).

Kept on purpose: the fix brief for this finding said to keep the consent branch as it is, so the security change stays one call.
No caller sees a different outcome. A non-owner is refused with the same 403 by the outer gate.
The only difference is the audit label on a refused consent attempt: it now reads app_enable. The denial is still audited.
Folding the consent label into the single gate is a cleanup, not a defect fix.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: fixed (span=2fd62d7a9875, two hook tests passed on an AttributeError).

Fixed in ea4fecc. The shared _make_app owner state now carries broadcast_ws, and the two ad-hoc lines are gone.
test_hook_failure_becomes_a_warning_not_a_failure now logs its own hook exploded error, so it drives the hook it names.
The 8 app enable test files pass: 420 passed.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ⏭️ skipped

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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=964b43bc928c, the retained consent gate can no longer deny).

Kept on purpose: the fix brief for this finding said to keep the consent branch as it is, so this security fix adds one call and removes nothing.
The inner gate is the same predicate on the same request, so no caller sees a different outcome: a non-owner gets 403 either way.
Deleting it is a cleanup with no behaviour change. It belongs in its own PR, not in the security fix.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=63305eadfce3, the inner consent gate can no longer deny).

Kept on purpose: the fix brief for this finding said to keep the consent branch as it is.
No caller sees a different outcome. A non-owner is refused with the same 403 by the outer gate, and the denial is still audited under app_enable.
Folding the consent label into the single gate is a cleanup for its own PR.

@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 Sep 29, 2026
zejiangg added 2 commits September 29, 2026 09:29
POST /api/apps/{name}/enable refused app tokens but let any other
dashboard subject re-enable an app, which registers its agents, skills,
MCP servers and crons, starts its backend and runs onEnable. Gate it with
require_owner_dashboard_request, the same call disable and uninstall use.

Existing enable tests now act as the owner, and a new test pins the
non-owner refusal.
The enable hook wiring reads broadcast_ws from the dashboard state. The
owner test state had none, so two hook tests passed on an AttributeError
instead of on the hook they drive. Put the attribute on the shared
helper state.
@iamwhatever
iamwhatever force-pushed the fix/owner-gate-round12-enable branch from ea4fecc to 165c3e3 Compare September 29, 2026 09:29
@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 Sep 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=81fccdf51ff5, the retained consent gate can no longer deny).

Kept on purpose: the fix brief for this finding said to keep the consent branch as it is, so this security fix adds one call and removes nothing.
The inner gate is the same predicate on the same request, so no caller sees a different outcome: a non-owner gets 403 either way.
Deleting it is a cleanup with no behaviour change. It belongs in its own PR, not in the security fix.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Disposition: rebutted (span=63305eadfce3, the inner consent gate can no longer deny).

Kept on purpose: the fix brief for this finding said to keep the consent branch as it is.
No caller sees a different outcome. A non-owner is refused with the same 403 by the outer gate, and the denial is still audited under app_enable.
Folding the consent label into the single gate is a cleanup for its own PR.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 29, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 29, 2026 16:29

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed on behalf of the maintainers (sweep 2026-09-29): readiness passed, required checks green on 165c3e3, no blocking review threads. Owner-only gate on app enable is the same accepted owner-gate class as #14300/#14341. Approving and merging.

@bolichen97
bolichen97 merged commit 41de374 into main Sep 29, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/owner-gate-round12-enable branch September 29, 2026 17:00
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 29, 2026
bolichen97 pushed a commit that referenced this pull request Oct 1, 2026
…0.8.0

Backport of #14658, #14652, #14650, #14775, #14656, #14900, #14898, #14894, #14891, #14948, #15046, #15332, #15333, #15331 to release/0.8.0, cherry-picked in main's merge order.

* fix(dashboard): owner-gate the host-file reader routes (#14658)
  (cherry picked from commit 778b51a)
* fix(auto-improvement): owner-gate the routes that drive agents or publish (#14652)
  (cherry picked from commit 59f0d89)
* fix(dashboard): owner-gate POST /api/memory/enable-embeddings (#14650)
  (cherry picked from commit bd2a9c0)
* fix(dashboard): owner-gate GET /api/file-search (#14775)
  (cherry picked from commit a0b9de6)
* fix(apps): owner-gate app install, update and registry-write routes (#14656)
  (cherry picked from commit 4f5cb65)
* fix(meetings): owner-only meeting write routes (#14900)
  (cherry picked from commit 6b9a56c)
* fix(auto-improvement): owner-gate forget, purge, stop, session links and PR status (#14898)
  (cherry picked from commit ee051d9)
* fix(apps): require the dashboard owner for app register, uninstall, disable (#14894)
  (cherry picked from commit 42894c3)
* fix(dashboard): require the owner for cron job update, run, enable and delete (#14891)
  (cherry picked from commit ccb78e6)
* fix(apps): require the dashboard owner to enable an app (#14948)
  (cherry picked from commit 41de374)
* fix(dashboard): let an app token manage only its own cron jobs (#15046)
  (cherry picked from commit 95a78b1)
* fix(issue-radar): owner gate on every forge-write route (#15332)
  (cherry picked from commit 4b6ab60)
* fix(ops-mission-control): owner-gate provider secret save and revoke (#15333)
  (cherry picked from commit e5f61b2)
* fix(meetings): owner-gate dictionary add and remove (#15331)
  (cherry picked from commit e5ba84e)

Co-authored-by: Joe Guo <zejiangg@amazon.com>
Co-authored-by: zejiangg <zejiangg@amazon.com>
bolichen97 added a commit that referenced this pull request Oct 1, 2026
…0.8.0 (#15621)

Backport of #14658, #14652, #14650, #14775, #14656, #14900, #14898, #14894, #14891, #14948, #15046, #15332, #15333, #15331 to release/0.8.0, cherry-picked in main's merge order.

* fix(dashboard): owner-gate the host-file reader routes (#14658)
  (cherry picked from commit 778b51a)
* fix(auto-improvement): owner-gate the routes that drive agents or publish (#14652)
  (cherry picked from commit 59f0d89)
* fix(dashboard): owner-gate POST /api/memory/enable-embeddings (#14650)
  (cherry picked from commit bd2a9c0)
* fix(dashboard): owner-gate GET /api/file-search (#14775)
  (cherry picked from commit a0b9de6)
* fix(apps): owner-gate app install, update and registry-write routes (#14656)
  (cherry picked from commit 4f5cb65)
* fix(meetings): owner-only meeting write routes (#14900)
  (cherry picked from commit 6b9a56c)
* fix(auto-improvement): owner-gate forget, purge, stop, session links and PR status (#14898)
  (cherry picked from commit ee051d9)
* fix(apps): require the dashboard owner for app register, uninstall, disable (#14894)
  (cherry picked from commit 42894c3)
* fix(dashboard): require the owner for cron job update, run, enable and delete (#14891)
  (cherry picked from commit ccb78e6)
* fix(apps): require the dashboard owner to enable an app (#14948)
  (cherry picked from commit 41de374)
* fix(dashboard): let an app token manage only its own cron jobs (#15046)
  (cherry picked from commit 95a78b1)
* fix(issue-radar): owner gate on every forge-write route (#15332)
  (cherry picked from commit 4b6ab60)
* fix(ops-mission-control): owner-gate provider secret save and revoke (#15333)
  (cherry picked from commit e5f61b2)
* fix(meetings): owner-gate dictionary add and remove (#15331)
  (cherry picked from commit e5ba84e)

Co-authored-by: Joe Guo <zejiang.guo@gmail.com>
Co-authored-by: Joe Guo <zejiangg@amazon.com>
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.

2 participants