Repository navigation
fix(code-review-sage): require the dashboard owner for review writes - #15988
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS A future mutating route added to this module ships ungated silently — Suggestions
[DESIGN-REVIEWED] 991da10 Description read[DESCRIPTION-READ] 7f2039b85f8126813be55a01ed29f6d6a24e67ff2635eba354be9d6ecc5972c7 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 |
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 no out-of-repo caller (an operator's script, a non-owner's curl workflow) drives these write routes; every in-repo caller is the owner's dashboard page — I re-ran the sweep. The defect's provenance is readable in the diff itself (handlers reaching bodies and seams with no gate), the fix reuses the one existing mechanism ( What this change shipsInventory (5 items) — 5 justifiedIntent: FIX — only the dashboard owner can start, post, cancel, or delete Code Review Sage reviews or change its settings; non-owners previously acted as the owner.
[FIRST-PRINCIPLES-REVIEWED] 991da10 Description read[DESCRIPTION-READ] 5e97627633d7d2f14036fcebc4d697f07d8b23da9f5e3f976cb81d3a4ad18b31 That sha256 names the PR description this verdict read. Recompute it with |
|
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNothing blocks — the gate is correctly placed on every mutating sage route; one parallel write path to the same state stays ungated. FINDING — src/kiro_crew/apps/builtins/code_review_sage/backend/routes.py:1755 — the new [OPUS-REVIEWED] 991da10 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
|
aee458a to
6f811ba
Compare
|
|
|
UX Review (Fable 5) — ⏭️ skippedRevision |
|
|
|
|
36404c3 to
7bfb9eb
Compare
|
|
|
Every mutating code-review-sage route now calls the shared require_owner_dashboard_request before its first branch, so a non-owner dashboard subject or any app token gets the standard owner_only 403. GET routes are unchanged. The sage suites' fake requests carry the owner's real identity through one shared fixture, so the gate runs unpatched.
7bfb9eb to
991da10
Compare
|
|
|
Reported an advertised MCP contract regression after this owner gate: #16775 . code_review_sage_api still exposes POST /review, but internal MCP authentication does not satisfy is_owner_dashboard_request, so initiation returns owner_only even from an operator dashboard session. The issue includes source evidence and a proposed narrowly scoped owner-authorized delegation path, with explicit protection against implicit publication through review.auto_post. The owner gate should remain intact; the agent initiation contract needs reconciliation. |
Problem / Motivation
Goal: Only the dashboard owner can change Code Review Sage state or start, post, or delete its reviews.
The Code Review Sage write routes had no owner check. Any signed-in dashboard user who is not the owner could start a review, post its comments, cancel or delete runs, and change settings, namespaces and pinned repos. Reviews run with the owner's
ghlogin, so that work happens as the owner.Why it matters
A shared gateway can admit users who are not the owner. They should be able to read what the owner allows. They should not act as the owner on GitHub or change the owner's review setup.
Not a goal
What changed (motivation → approach → change)
Symptom: a non-owner reached every write route. Cause: the module never called the owner gate the other builtin apps use. Change: each write route now calls
require_owner_dashboard_requestfirst and returns itsowner_only403.Each refusal also writes the shared gate's SEL
deniedaudit event. App tokens are refused too, this app's own included. No product code calls these routes with an app token. The page sends the session cookie, and the skills and backend helpers never call these routes.Files:
src/kiro_crew/apps/builtins/code_review_sage/backend/routes.py: the gate on all 14 write route and method pairs.src/kiro_crew/apps/builtins/code_review_sage/tests/test_owner_gate.py: new tests.src/kiro_crew/apps/builtins/code_review_sage/tests/fixtures.py: one sharedOwnerRequestfake carrying the owner's real identity.src/kiro_crew/apps/builtins/code_review_sage/tests/test_backend_routes.py,test_consolidate.py,test_paste_pr_link.py,test_post_comments.py,test_run_endpoints.py, andtest/test_sage_backend_routes_coverage.py: their fake requests build on that shared fake.Backwards compatibility
Breaking: a non-owner dashboard user or an app token now gets a 403
owner_onlyon these 14 write routes. Writer sweep on origin/main @ 5a70ce7: the only caller is the dashboard page (website/src/apps/code-review-sage/api.ts), which sends the owner's session cookie and still passes. No MCP tool, skill, cron, hook or backend helper calls these routes.Tests
test_non_owner_dashboard_subject_refused[...]: every write route answers a non-owner with 403owner_onlyand reaches no side-effect seam.test_own_app_token_refused[...]: the same for this app's own token.test_owner_passes_gate[...]: the owner reaches each handler's own validation.test_non_owner_get_routes_unchanged[...]: GET settings, namespaces and repos still answer 200.With the routes change reverted, the 26 refusal rows fail and the owner and GET rows pass. With it applied, all pass.
Pre-existing:
tests/test_store_ancestor_chain.py::TestTheWindowBetweenTheRefusalAndTheWalk::test_a_link_planted_inside_the_window_is_followed_outside_every_rootfails on clean main too. This PR does not touch it.Manual verification
N/A — the tests drive the real handlers through a real aiohttp app with the auth middleware's identity keys.
Related Issues
N/A
Pattern harvest
Rule candidate: review-prompt
Pattern: a builtin app's mutating route that never calls
require_owner_dashboard_request. Some builtin apps call the shared gate and some do not; this PR fixes only Code Review Sage.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)