Skip to content

Use host-prefixed session cookies for HTTPS - #544

Merged
linkdata merged 7 commits into
mainfrom
codex/host-session-cookie
Nov 9, 2026
Merged

linkdata merged 7 commits into
mainfrom
codex/host-session-cookie

Conversation

@linkdata

@linkdata linkdata commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Treat CookieName as an unprefixed base name. On recognized HTTPS, use __Host-<CookieName> with Secure, Path=/, and no Domain.
  • Keep the existing unprefixed cookie name for plain HTTP. HTTP and HTTPS sessions are separate; lookup and replacement cannot cross that boundary, even if a client copies a valid ID under the other cookie name.
  • Update the tracked JaWS AI guidance: jawsauth keeps sessions on login and logout by default; applications need no cookie monitoring; login rotation is an explicit setting for a concrete fixation path.

Browsers that enforce the __Host- prefix reject attempts by sibling domains or plaintext HTTP responses to set the HTTPS session cookie. Rotation is useful only if an attacker can make a victim use a known pre-login cookie, share the effective client IP JaWS sees, and cannot obtain the later cookie. linkdata/jawsauth#23 makes rotation opt-in.

Compatibility

  • Merge jawsauth add Jaws.ServeHTTP() #23 first: the JaWS AI guidance in this PR describes its new default and RotateSessionOnLogin setting.
  • Plain HTTP sessions continue working with CookieName; they do not share sessions with HTTPS.
  • Existing HTTPS cookies with the old unprefixed name are ignored. Users with those cookies sign in again.
  • Behind a trusted TLS-terminating proxy, enable TrustForwardedHeaders and have the proxy replace client-supplied forwarding headers so JaWS sees the actual scheme and client IP.

Verification

  • go generate ./...
  • go vet ./...
  • go build ./...
  • go test -race ./... (full module)
  • go test ./...
  • staticcheck ./..., golangci-lint run, gosec ./...
  • gofmt -l . and gofumpt -l on changed Go files
  • git diff --check

@linkdata
linkdata merged commit bf4aafb into main Nov 9, 2026
7 checks passed
@linkdata
linkdata deleted the codex/host-session-cookie branch November 9, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant