fix(security): enforce workspace scope on workflow middleware and validate shopify shop domain#4535
Conversation
…idate shopify shop domain
- validateWorkflowAccess now rejects workspace-scoped API keys whose
workspaceId doesn't match the workflow's workspace, closing a boundary
leak across /api/workflows/[id]/{log,paused,status} and
/api/resume/[workflowId]/[executionId]/[contextId]
- shopify authorize route now validates the resolved shop domain against
shopifyShopDomainSchema before proceeding
- adds middleware tests covering workspace/personal/session auth paths
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Hardens the Shopify OAuth authorize endpoint by validating the normalized Adds Vitest coverage for the new workflow middleware behavior across workspace-key mismatch/match, personal API keys, and session auth flows. Reviewed by Cursor Bugbot for commit 00a5e08. Configure here. |
Greptile SummaryThis PR closes a workspace-scope boundary gap in
Confidence Score: 5/5Targeted security hardening with no behavioural changes to existing authorised callers; safe to merge. Both changes are narrowly scoped: the middleware check is fail-closed (undefined workspaceId on a workspace key is rejected), the Shopify validation fires after full normalisation so no valid domain is incorrectly blocked, and the tests cover all four auth branches introduced by the fix. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Request arrives] --> B[getWorkflowById]
B --> C{workflow found?}
C -- No --> D[404 Not Found]
C -- Yes --> E[checkHybridAuth]
E --> F{auth success?}
F -- No --> G[401 Unauthorized]
F -- Yes --> H{workspace API key?}
H -- No --> J[authorizeWorkflowByWorkspacePermission]
H -- Yes --> I{Key scope matches workflow?}
I -- No --> K[403 Key not authorized for workspace]
I -- Yes --> J
J --> L{access granted?}
L -- No --> M[403 Access Denied]
L -- Yes --> N[Return workflow and auth]
Reviews (3): Last reviewed commit: "fix(security): widen shopify subdomain r..." | Re-trigger Greptile |
|
Thanks @greptile-apps — tightened the regex in ec2c02b to require the subdomain label to end in an alphanumeric (no trailing hyphen), matching RFC 1123. |
|
The updated regex looks correct:
Solid fix — this now properly enforces RFC 1123 label rules. LGTM. |
… lowercase, no edge hyphens)
|
@greptile |
|
@cursor review |
Shopify and RFC 1123 allow labels up to 63 chars; the previous
{1,58} quantifier capped the subdomain at 60 chars and rejected
valid 61–63 char shops with a 400.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 00a5e08. Configure here.
Summary
validateWorkflowAccessnow rejects workspace-scoped API keys whoseworkspaceIddoesn't match the workflow's workspace, closing a boundary leak across/api/workflows/[id]/{log,paused,status}and/api/resume/[workflowId]/[executionId]/[contextId]shopifyShopDomainSchemabefore initiating OAuthType of Change
Testing
bun run vitest run app/api/workflows/middleware.test.ts— 5/5 passingChecklist