promote(GRO-2586): dev → uat — CORS origin allowlist enforcement #220
Reference in New Issue
Block a user
Delete Branch "promote/GRO-2586-cors-to-uat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
GRO-2586 — CORS origin reflection fix
Promotes the fix for HIGH-severity pre-existing CORS misconfiguration to UAT for regression testing.
What changed
Better Auth was reflecting the request
Originunconditionally intoAccess-Control-Allow-OriginwithAccess-Control-Allow-Credentials: true, allowing any attacker-controlled page to read/api/auth/sign-in/socialresponse bodies via XHR. The fix enforces theCORS_ORIGINallowlist at the handler level by wrapping Better Auth's raw response.Files
src/lib/auth-cors.ts— newenforceAuthCors()helpersrc/index.ts— auth handler callsenforceAuthCors()before returningsrc/__tests__/authCors.test.ts— 6 regression tests (all pass)UAT_PLAYBOOK.md§4.1 — TC-API-1.29/1.30/1.31 addedUAT test cases
Origin: https://evil.example.com→ noAccess-Control-Allow-OriginheaderOrigin: https://uat.groombook.dev→ACAO: https://uat.groombook.dev+ACAC: trueACAOreflectedRelated: GRO-2586 | GRO-2585
QA code review approved — promote(GRO-2586) dev → uat.
Scope: Exactly the 4 ticketed files; no unscoped dev work carried into the promotion.
CI: All green — Test, Lint & Typecheck, Build & Push. No conflicts.
Correctness:
enforceAuthCors()allows trusted origins (ACAO + ACAC: true), strips CORS headers for untrusted/undefined/empty origins, and preserves status/body/non-CORS headers. It correctly closes the gap left by the globalcors()middleware, which 403s untrusted origins but does not delete theAccess-Control-Allow-Originheader Better Auth reflects onto its raw Response.Tests: 6 regression tests in
authCors.test.tscover trusted, attacker, undefined, empty-string, second-trusted, and header/status preservation — all pass per CI.UAT_PLAYBOOK.md: §4.1 updated with TC-API-1.29/1.30/1.31. ✓
LGTM — Engineer to self-merge per SDLC.