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 maintainer review before merge. Reviewed August 23, 2026, 5:08 AM ET / 09:08 UTC. ClawSweeper reviewWhat this changesThe branch rewrites the session and OAuth cookie-security predicate to preserve the documented loopback-HTTP exception without a literal false return path. Merge readinessKeep open for normal maintainer review. The member-authored draft resolves the prior loopback-cookie concern while preserving the current default branch’s policy; current main and v0.3.1 still use the alert-triggering predicate form. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherClickClack’s API authentication flow issues session and OAuth browser-binding cookies. The shared cookie predicate combines configured public origins and request transport details to decide whether those cookies require HTTPS. flowchart LR
A[Browser or desktop request] --> B[API authentication flow]
B --> C[Cookie security policy]
C --> D{Documented loopback HTTP?}
D -->|yes| E[Local HTTP cookies]
D -->|no| F[Secure cookies]
E --> G[Browser cookie jar]
F --> G
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Land the focused predicate rewrite after normal member-PR review, retaining the documented loopback-only exception and the existing secure-cookie policy matrix. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main contains the literal loopback false branch, while the branch adds a real net/http cookie-jar round trip that exercises both issued cookies over loopback HTTP. Is this the best way to solve the issue? Yes. The shared predicate is the narrowest maintainable place to preserve the established local-HTTP contract while retaining Secure cookies for every other origin. AGENTS.md: found, but no applicable review policy affected this item. Codex review notes: model internal, reasoning high; reviewed against e617cb5f1842. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
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