security: forwarded headers only from trusted proxies; Secure cookies behind TLS proxies (#874, v0.6.328) #877

Merged
Cordy merged 3 commits from fix-874 into main 2026-10-12 11:48:32 +00:00
Owner

Closes #874.

  • Share-link limiter. It no longer trusts the left-most X-Forwarded-For from any peer, which was a bypass of the password limit. It is now keyed by auth.ClientAddr (trusted proxies, read from the right), with IPv6 grouped by /64.
  • auth.RequestScheme. X-Forwarded-Proto is honoured only from trusted proxies (last value, case-insensitive). It is used for the OIDC sign-out origin and the share-link base URL. A host configured as https (oidcRedirectUrl, shares.baseUrl) keeps https, so sign-out doesn't regress behind a proxy that isn't trusted yet.
  • Cookies. The session cookie, its clear, and cairn_share are now Secure over TLS or a trusted https proxy. LAN http stays non-Secure.
  • Guard test. Walks the whole module and catches concatenated literals. No X-Forwarded-*, Forwarded or X-Real-IP reader is allowed outside internal/auth.
  • Docs. The unsafe 10.42.0.0/16 example is gone from deployment.md. CHANGELOG ## v0.6.328 has a Security section and upgrade notes.

Review. Opus security review: 3 Important findings (sign-out origin, guard breadth, upgrade note), all fixed. go vet, go test ./..., -race on auth/share/api/cmd, gofmt and the web tests are all green.

Closes #874. - **Share-link limiter.** It no longer trusts the left-most X-Forwarded-For from any peer, which was a bypass of the password limit. It is now keyed by `auth.ClientAddr` (trusted proxies, read from the right), with IPv6 grouped by /64. - **`auth.RequestScheme`.** X-Forwarded-Proto is honoured only from trusted proxies (last value, case-insensitive). It is used for the OIDC sign-out origin and the share-link base URL. A host configured as https (`oidcRedirectUrl`, `shares.baseUrl`) keeps https, so sign-out doesn't regress behind a proxy that isn't trusted yet. - **Cookies.** The session cookie, its clear, and `cairn_share` are now `Secure` over TLS or a trusted https proxy. LAN http stays non-Secure. - **Guard test.** Walks the whole module and catches concatenated literals. No `X-Forwarded-*`, `Forwarded` or `X-Real-IP` reader is allowed outside `internal/auth`. - **Docs.** The unsafe `10.42.0.0/16` example is gone from deployment.md. CHANGELOG `## v0.6.328` has a Security section and upgrade notes. **Review.** Opus security review: 3 Important findings (sign-out origin, guard breadth, upgrade note), all fixed. `go vet`, `go test ./...`, `-race` on auth/share/api/cmd, `gofmt` and the web tests are all green.
security: #874 review fixes
All checks were successful
ci / test-and-build (pull_request) Successful in 2m54s
95f9890da0
- OIDC sign-out {origin} keeps https for a host configured as https
  (auth.oidcRedirectUrl, shares.baseUrl) behind a not-yet-trusted proxy.
- Guard test: whole module, Forwarded and X-Real-IP, literal concatenation.
- main: auth.trustedProxies parse error is checked, not discarded.
- CHANGELOG/deployment.md: sign-out origin upgrade note, unread headers.
Cordy merged commit 4e4a6bfdf5 into main 2026-10-12 11:48:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#877
No description provided.