fix(auth): preserve secure cookies outside loopback HTTP - #171
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 21, 2026, 8:05 AM ET / 12:05 UTC. ClawSweeper reviewWhat this changesThe PR makes session and OAuth browser-binding cookies unconditionally Secure and removes origin-based cookie-security inference from the API authentication flows. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the hardening removes ClickClack’s documented loopback-HTTP cookie compatibility path, and standard Go cookie jars do not return Secure cookies over HTTP. The PR needs a loopback cookie-jar or Electron round-trip before merge; its MEMBER author also excludes it from automated closure. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherClickClack’s API issues session and OAuth binding cookies after magic-link, SSO, and OAuth flows. Browsers or Electron then return those cookies on later requests to authenticate the user. flowchart LR
A[Login or OAuth callback] --> B[API authentication handler]
B --> C[Cookie producer]
C --> D{Cookie transport policy}
D --> E[Session cookie]
D --> F[OAuth binding cookie]
E --> G[Browser or Electron session]
F --> G
Before merge
Findings
Agent review detailsSecurityNeeds attention: The patch improves non-loopback cookie confidentiality but needs compatibility validation for the supported loopback authentication boundary. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep Secure mandatory for non-loopback deployments while preserving the established local-HTTP exception unless a real Electron and system-browser loopback flow proves it is safe to remove; add a round-trip regression test for that chosen contract. Do we have a high-confidence way to reproduce the issue? Yes, at source level: issue a Secure cookie from a loopback HTTP response and request that origin through Go’s standard cookie jar; its HTTPS-only send condition omits the cookie. The revised tests do not perform this round trip. Is this the best way to solve the issue? No. Unconditional Secure attributes discard the documented loopback HTTP policy without proving compatible client behavior; retain the exception or establish the proposed policy with real Electron/browser evidence and matching documentation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found, but no applicable review policy affected this item. Codex review notes: model internal, reasoning high; reviewed against acf70f8206c5. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
019f46b to
82d0a6d
Compare
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Closes CodeQL alerts 1 and 2 without breaking ClickClack's documented HTTP loopback authentication path.
Why This Change Was Made
The session and OAuth binding cookies already fail closed to
Secureeverywhere except explicit development-mode loopback HTTP. The CodeQL query tracks literal or defaultfalsevalues intohttp.Cookie.Secure; the old helper expressed the intentional loopback exception throughreturn false.The revised helper preserves the same request and configured-origin policy as one positive expression. HTTPS, forwarded HTTPS, configured HTTPS, non-loopback hosts, and disabled development auth remain secure. Only documented development-mode loopback HTTP omits
Secure.No alert is dismissed or suppressed.
User Impact
Local browser and desktop authentication continue to work over HTTP localhost and loopback addresses. Every non-loopback deployment keeps secure session and OAuth binding cookies.
Evidence
go test ./apps/api/internal/httpapinet/http/cookiejarround trip proving both the OAuth binding cookie and resulting session cookie are returned over loopback HTTPgithub/codeqlatgo/ql/lib/semmle/go/security/CookieWithoutSecure.qll