Skip to content

fix(papyrus): refuse every route to anyone but the dashboard owner - #15966

Merged
bolichen97 merged 2 commits into
mainfrom
fix/owner-gate-round14-papyrus
Oct 2, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
fix/owner-gate-round14-papyrus

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Only the dashboard owner can use Papyrus.

Every Papyrus route checked one thing: is the app on? It never checked who was asking. So a signed-in dashboard user who is not the owner, or any app token, could do all of this:

  • read, change and delete the owner's papers
  • make the host clone any allowed git URL
  • commit and push with the owner's own git keys

Why it matters

Papers are private drafts. The push route runs git with the owner's own keys. Anyone a link lets into the dashboard could leak or overwrite the owner's work, and push in the owner's name.

Not a goal

  • No change to git, LaTeX or path checks (gitops.py, latex.py, store.py). They were reviewed and are sound.
  • No new owner predicate. This reuses the shared gate.
  • No change to how the co-author agent edits files. It uses its own file tools, not these routes.

What changed (motivation → approach → change)

Symptom: a non-owner gets 200 on every Papyrus route. Cause: _require_enabled in src/kiro_crew/apps/builtins/papyrus/backend/routes.py is the one wrapper on all 19 routes, and it only checked that the app was on.

Fix: that same wrapper now calls the shared require_owner_dashboard_request once the enabled check passes. Everyone but the owner gets its 403 owner_only, with the usual SEL audit. A disabled app still answers app_disabled first. One wrapper means a new route cannot miss the gate. meetings and aws_control gate the same way.

Caller Before After
owner (dashboard cookie) 200 200
non-owner dashboard user 200 403 owner_only
papyrus app token 200 403 owner_only
other app token 200 403 owner_only
internal call, no app claim 200 403 owner_only

The spec docs/system-specs/modules/papyrus.md now states this rule, in a new Caller authorization section of its Security model.

Own-app tokens are refused too, because nothing uses one. The page (website/src/apps/papyrus/api.ts) fetches with the owner's session cookie. The papyrus-writing skill edits files directly. No other module calls /api/apps/papyrus.

Backwards compatibility

Compatible: the owner's page sends the owner's cookie (app=="", user==owner), so everything it does still works. Writer sweep on origin/main @ 4224aa2: the only caller of these routes is website/src/apps/papyrus/api.ts, a cookie fetch. No app token, MCP tool or agent calls them.

Tests

In test/test_papyrus_routes.py, new TestOwnerGate:

  • test_every_route_refuses_a_non_owner_caller: walks all 19 registered routes for 4 callers (non-owner, own-app token, other app token, internal with no app claim). Each must get 403 owner_only.
  • test_owner_reaches_every_route: the owner reaches all 19.
  • test_registered_push_and_commit_never_reach_git_for_a_non_owner: mocked gitops.push, commit and clone are never called.
  • test_disabled_check_still_answers_first: a disabled app still says app_disabled.

TestRequireEnabled::test_allows_the_route_when_enabled now sends the owner's identity.

Fails before: with the routes.py change reversed, the 5 refusal tests fail and the controls pass. With it applied, all pass (255 papyrus route and store tests).

Manual verification

N/A — unit coverage is enough. The tests drive the real registered handlers through the real shared gate.

Related Issues

N/A — found in an internal security review.

Pattern harvest

Rule candidate: review-prompt
Pattern: an app route wrapper that checks only that the app is enabled and never calls the shared owner 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

Contribution License Agreement

N/A — placeholder pending OSPO wording.

Papyrus routes were gated only on the app being enabled, so a non-owner dashboard subject or any app token could read, edit and delete the owner's papers, clone a remote onto the host, and commit and push with the owner's git credentials. The shared enabled wrapper now also runs require_owner_dashboard_request, so all 19 routes answer 403 owner_only to anyone but the owner. The page fetches with the owner's session cookie and the co-author agent uses file tools, so no app-token caller exists.
@iamwhatever
iamwhatever requested a review from a team as a code owner October 1, 2026 19:01
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Confirm in a live co-author session that the agent never hits these routes with an app token — the sweep backing own-app-token refusal was static.

[DESIGN-REVIEWED] 8414c33

Description read

[DESCRIPTION-READ] ad3e5b908cf0d3a67e795207b9233d74169128ad23297bd8be4a77efb1641f4d

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 Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 8414c337642e721fc2c0b0e66635f462cffd9eca and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8414c33

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 8414c337642e721fc2c0b0e66635f462cffd9eca — 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 papyrus wrapper is fixed, but the author's own harvested pattern — enabled-only wrappers with no owner gate — survives in 7 sibling builtin apps, unlisted.

Not justified as shipped

  • Item 1 — symptom-level (point patch): the fix is cause-level for papyrus (one wrapper, all 19 routes), but grepping require_owner|owner_only under src/kiro_crew/apps/builtins/*/backend shows 7 builtin backends never reference the owner gate while their _require_enabled checks only enabled: spec_builder, design_critique, crew_companion, code_review_sage, personal_shopper, mochi, pptx_maker (issue_radar and ops_mission_control gate only some routes per-handler). The "Pattern harvest" line names the pattern, but the description never says these siblings are left, and "meetings and aws_control gate the same way" reads as if papyrus were the last gap. Deferring the general fix is legitimate; the papyrus-frozen Goal licenses it.
    Clears when: a linked issue (or maintainer note on this PR) records which sibling apps deliberately serve non-owners and tracks the rest.

What this change ships

Inventory (5 items) — 4 justified

Intent: keep anyone but the dashboard owner out of every Papyrus route — a FIX. (The patch's ~140 non-papyrus files match base commits #13236/#15924/#15900 already on main — test-merge drift, excluded from this inventory.)

  1. Non-owner dashboard users now get 403 owner_only on all 19 papyrus routes — symptom-level (point patch; 7 sibling app backends counted above never owner-gate)
  2. App tokens, papyrus's own included, and claim-less internal callers are refused — justified (zero app-token consumers verified: only caller is website/src/apps/papyrus/api.ts, a cookie fetch)
  3. Refusals write a SEL denial record named papyrus.<route> — justified
  4. A disabled app still answers app_disabled before the owner check — justified
  5. papyrus.md spec gains a Caller authorization section — justified

[FIRST-PRINCIPLES-REVIEWED] 8414c33

Description read

[DESCRIPTION-READ] 5e63285d3c8135b3a6a4092c55625a6ad82105cf8456d8960f0a0f1d6e31bcf5

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 Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 8414c337642e721fc2c0b0e66635f462cffd9eca — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8414c33

Verdict parsed from the review's SHA-scoped output markers for commit 8414c337642e721fc2c0b0e66635f462cffd9eca.

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

@iamwhatever

iamwhatever commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=b4065e1e9eed sibling app wrappers gate on enabled only
    Disposition: rebutted (scope split, maintainer ruling)

The count holds, and the Pattern harvest line in the description is corrected.
The maintainer ruled not to widen this PR. Each sibling app with a confirmed gap has its own fix PR: spec_builder in #15969, crew_companion in #15982, code_review_sage in #15988.
The remaining builtin apps with an enabled-only wrapper are tracked privately for the next security audit round, not in a public issue.
This PR closes the papyrus gap alone, cause-level: one wrapper covers all 19 papyrus routes.

@iamwhatever

iamwhatever commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=fa465cee1ed6 papyrus spec not updated
    Disposition: fixed in 8414c33

docs/system-specs/modules/papyrus.md Routes now says _require_enabled answers app_disabled, then owner_only to anyone but the owner.
Security model gains a Caller authorization (owner only) section: the caller table, why app tokens are refused, and the TestOwnerGate pin.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

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

UX-Verdict: PASS

Verify a refused non-owner sees a legible error on the Papyrus page — api.ts has no handling for the new 403 owner_only path.

[UX-REVIEWED] 8414c33

Description read

[DESCRIPTION-READ] 1a17d26d32bb421fb5332438826d4ee2f2094be87c4c7b3ea1e0aaf26a1785a1

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 .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.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=7b9935c4154d sibling app backends never reference the owner gate
    Disposition: rebutted (scope split, maintainer ruling)

Same item as the prior head's record: the count holds, and the maintainer ruled not to widen this PR.
Sibling apps with a confirmed gap each have their own fix PR: spec_builder in #15969, crew_companion in #15982, code_review_sage in #15988.
The remaining builtin apps with no owner-gate reference are tracked privately for the next security audit round, which decides per app whether it serves non-owners by design.
This PR closes the papyrus gap alone, cause-level: one wrapper covers all 19 papyrus routes.

@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 Oct 1, 2026

@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.

Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.

@bolichen97
bolichen97 merged commit 1e81520 into main Oct 2, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/owner-gate-round14-papyrus branch October 2, 2026 05:03
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 2, 2026
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