fix(execute): block cross-origin session-authenticated workflow runs#5062
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview New helper Coverage: 8 unit tests for the helper and a route test asserting cross-site session POSTs fail without calling authorize or enqueue. Reviewed by Cursor Bugbot for commit 80c0ebf. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryAdds a Fetch Metadata–based CSRF guard to
Confidence Score: 5/5Safe to merge — the CSRF guard is correctly scoped to session auth, cannot block legitimate API-key or internal callers, and the fail-open behavior for header-less requests is intentional and documented in the code. The guard logic, its tests, and the route integration are all consistent and correct. The only finding is a PR description that contradicts the actual behavior on two points (same-site and no-headers), which does not affect runtime behaviour. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser as Browser (same-origin)
participant Attacker as Attacker Site (CSRF)
participant Script as Non-browser Client
participant Route as POST /api/workflows/[id]/execute
participant Auth as checkHybridAuth
participant Guard as isCrossOriginSessionRequest
participant Perm as authorizeWorkflow
Browser->>Route: POST (Sec-Fetch-Site: same-origin, session cookie)
Route->>Auth: checkHybridAuth → SESSION
Route->>Guard: "secFetchSite === same-origin → false"
Route->>Perm: proceed normally
Perm-->>Browser: 200 OK
Attacker->>Route: POST (Sec-Fetch-Site: cross-site, borrowed cookie)
Route->>Auth: checkHybridAuth → SESSION
Route->>Guard: "secFetchSite !== same-origin → true"
Route-->>Attacker: 403 Access denied
Script->>Route: POST (no Sec-Fetch-Site, no Origin, session cookie)
Route->>Auth: checkHybridAuth → SESSION
Route->>Guard: no headers → false (fail-open)
Route->>Perm: proceed normally
Perm-->>Script: 200 OK
Note over Route,Guard: API-key / internal-JWT callers skip guard entirely
Reviews (2): Last reviewed commit: "fix(execute): scope session origin guard..." | Re-trigger Greptile |
Address review on #5062: - Reject session-cookie execution only when provably cross-origin (Sec-Fetch-Site cross-site/same-site/none, or a mismatched Origin) instead of failing closed on absent headers. Fixes route tests that 403'd on header-less session requests, and reflects that this is CSRF protection, not anti-cookie-replay. - Drop same-site from the trusted set: only same-origin is our front-end. - Guard the Origin fallback in try/catch so a getBaseUrl() throw can't escape. - Add a route-level cross-origin rejection test.
|
@greptile review |
Summary
POST /api/workflows/[id]/execute, scoped strictly to session-cookie auth: reject requests that are provably cross-origin (Sec-Fetch-Siteanything other thansame-origin, or a mismatchedOrigin)Access denied403 so the rejection is indistinguishable from a normal authorization failureScope / what this is not
Type of Change
Testing
bun run check:api-validation:strictpassedtsc --noEmitclean; biome clean on changed filesChecklist