Repository navigation
fix(auto-improvement): owner-gate the routes that drive agents or publish - #14652
Conversation
…lish Seven auto-improvement routes were wrapped only in _require_enabled, so any dashboard token could reach them. A non-owner could clone a repository of their choice, grant the unsandboxed-agent consent flags, start a run or a calibration, start a PR watcher, push a one-click commit with the owner's git credentials, or open a draft PR under the owner's GitHub identity. Each handler now calls require_owner_dashboard_request first, the same shape as _handle_deps_install: app tokens are refused too, since no app-token caller exists. Allowed decisions are recorded in SEL off the event loop; refusals are audited by the gate itself.
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the rfc-perpetual-agent draft→accepted flip and the two macOS test hunks are base-drift from #14662/#14651 — not decisions this PR is silently recording. Not justified as shipped
What this change shipsInventory (6 items) — 3 justifiedIntent: only the dashboard owner can drive Auto-Improvement's agents or publish under the owner's name — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6ade123 |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. Owner gate reuses the shared [DESIGN-REVIEWED] 6ade123 |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNo blocking issues. FINDING — docs/system-specs/modules/auto-improvement.md:31 — the owning spec still states the route table's only authorization as "Every handler is wrapped in [OPUS-REVIEWED] 6ade123 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
|
…atchers
GET /watchers runs a reconcile sweep. With watcherAutoStart on it starts
watcher agents, and with autoPublish on it marks the owner's draft PRs ready.
A non-owner could reach both through this read, around the new gate on
POST /watchers/{fp}/start. The handler now takes the same owner gate first;
no dashboard page or agent calls this route.
|
|
|
|
|
…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>
…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>
Problem / Motivation
Goal: Only the dashboard owner can make Auto-Improvement drive the owner's agents or publish under the owner's name.
Seven Auto-Improvement routes checked only that the app is on. They never checked who was calling. Any dashboard token reached them. That includes a channel user on the allow list, who is not the owner.
POST setup-clonePUT configacceptUnsandboxedAgentRiskandwatcherAcceptEgressRiskPOST run,POST calibratePOST watchers/{fp}/startPOST findings/{fp}/commitPOST draft-pr/{fp}Why it matters
A non-owner could run the owner's agents on any repo. They could turn off the sandbox consent for those agents. They could publish code as the owner.
Not a goal
POST findings/{fp}/forget,POST findings/{fp}/purgeandPOST findings/purge-dead. These change or delete the local findings ledger.PUT sessions/{key}andDELETE sessions/{key}. These link or unlink a chat slot.POST run/stopandPOST watchers/{fp}/stop.What changed (motivation → approach → change)
The symptom: a non-owner could reach all seven routes above. The cause:
register_routeswraps them only in_require_enabled, and that wrapper checks the app switch, not the caller.GET /watchershas the same hole. Its reconcile sweep starts watcher agents whenwatcherAutoStartis on, and marks drafts ready whenautoPublishis on.The fix follows
_handle_deps_installin the same file. Each of these eight handlers insrc/kiro_crew/apps/builtins/auto_improvement/backend/routes.pynow callsrequire_owner_dashboard_requestfirst. It does this before reading the body or the fingerprint. App tokens are refused too, because no app-token caller exists. The page in the dashboard runs as the owner, so it still works. The loop, the watchers and the MCP server do not go through these routes, so they are not touched.The gate already logs each refusal to SEL. A new
_audit_owner_route_allowedlogs each allowed call. It runs off the event loop, in the same shape as_audit_deps_install_allowed.Backwards compatibility
Breaking: non-owner dashboard tokens and app tokens now get 403 on the eight routes (the seven above plus
GET /watchers). Writer sweep on origin/main @ 631f8e6: the only callers are the owner's dashboard page (SetupPanel.tsx,AutoImprovementPage.tsx), which sends the owner's token and keeps working. No page, skill, agent or MCP tool callsGET /watchers,POST calibrate,POST draft-prorPOST watchers/{fp}/start.Tests
test/test_auto_improvement_owner_gate.py(new) tests all eight handlers. The owner reaches the body and one allowed call is logged. A non-owner withapp == ""gets 403. An app token gets 403. For both refusals the body never runs and nothing is logged as allowed. Removing any one gate makes its refusal rows fail.test/test_ai_backend_routes_coverage.py:_request()now carries the owner's identity. No assertion changed.src/kiro_crew/apps/builtins/auto_improvement/tests/test_finding_detail.py:_client()now stamps the owner's identity. No assertion changed.mypy test/test_ai_backend_routes_coverage.pyreports 2func-returns-valueerrors (lambdas usinglist.append). They are on untouched lines and appear the same on origin/main (lines 1503 and 1558 there). CI's mypy gate coverssrc/kiro_crew/only.Manual verification
N/A. Unit tests cover it: the gate is one call, and the tests drive the real handlers for all three kinds of caller.
Related Issues
Security audit round 11, findings F85 and F86.
Pattern harvest
Rule candidate: review-prompt
Pattern: a mutating app route wrapped only in
_require_enabled, with no owner gate.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)