Skip to content

fix(api): enforce same-partner ownership on partner-wide script writes (#3262 follow-up) - #3272

Merged
ToddHebebrand merged 1 commit into
mainfrom
fix/3262-followup-partner-ownership
Aug 8, 2026
Merged

fix(api): enforce same-partner ownership on partner-wide script writes (#3262 follow-up)#3272
ToddHebebrand merged 1 commit into
mainfrom
fix/3262-followup-partner-ownership

Conversation

@ToddHebebrand

Copy link
Copy Markdown
Collaborator

Follow-up to #3263, which was merged just before this reviewed hardening commit reached the PR branch (it landed on the fork moments after the squash-merge — see #3263 (comment)).

Same diff as fork commit 1cfe0e8, cherry-picked onto main:

One pre-existing test updated: cross-partner rescope now expects 404 rather than the old 403 "not owned by your partner" (that message was the existence leak).

Verified: scripts.test.ts 47 passed | 2 skipped (two new cross-partner denial tests); tsc --noEmit clean on apps/api.

🤖 Generated with Claude Code

#3262 review)

Review follow-ups on the partner-wide script write gate:

- Defense-in-depth: the PUT/DELETE guards for partner-wide scripts
  (org_id NULL, partner_id set) checked the capability but relied on RLS
  row invisibility alone for cross-partner isolation. Add an explicit
  app-layer same-partner ownership check answering 404 (not 403 — do not
  leak that the script id exists), mirroring the rescope path's
  currentScope.partnerId comparison.
- Extract the duplicated two-guard block from the PUT and DELETE
  handlers into one partnerWideScriptWriteError helper (with the
  ownership check inside) so the rules can never drift between routes.
- RescopeAuth.partnerOrgAccess: make the key required (value may still
  be undefined) so future resolveRescopeTarget callers are forced by the
  compiler to thread the partner-wide capability through.

The cross-partner rescope test now expects 404/"Script not found"
instead of the previous existence-leaking 403; new tests prove the app
layer alone rejects cross-partner PUT and DELETE with 404.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploying breeze with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9e987d6
Status: ✅  Deploy successful!
Preview URL: https://9b201278.breeze-9te.pages.dev
Branch Preview URL: https://fix-3262-followup-partner-ow.breeze-9te.pages.dev

View logs

@ToddHebebrand
ToddHebebrand merged commit b016819 into main Aug 8, 2026
55 checks passed
@ToddHebebrand
ToddHebebrand deleted the fix/3262-followup-partner-ownership branch August 8, 2026 15:26
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.

1 participant