Cluster 18 · Session Cookies · RFC 6265bis __Host-

__Host- Session Cookie Flag Tester: Secure, HttpOnly, Path=/ & SameSite Linter

Validate Set-Cookie headers against RFC 6265bis __Host- rules (Secure, Path=/, zero Domain= attribute), HttpOnly XSS defense, SameSite CSRF protection, and bounded Max-Age.

OAuth 2.1 · WebAuthn · Zero Upload · Strict CSP

4. __Host- Cookies, COOP/CSP & Magic-Link DNS

RFC 6265bis · COOP · DMARC
Session Cookie Hardening Score
PASS
Login Route COOP / CSP Clickjacking Shield (login-headers.txt)
# Hardened Auth / Login Edge Headers for acme.example.com (Cloudflare Pages / Workers)
/login
  Cross-Origin-Opener-Policy: same-origin
  Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'; form-action 'self' https://auth.acme.example.com
  X-Frame-Options: DENY
  X-Content-Type-Options: nosniff
  Referrer-Policy: no-referrer
  Cache-Control: no-store, no-cache, must-revalidate
  Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  Set-Cookie: __Host-sid=<CSPRNG_TOKEN>; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
Magic-Link DMARC p=reject & SPF -all Pack
# Magic-Link / OTP Subdomain Anti-Phishing DNS & Policy (auth-mail.acme.example.com)
; 1. Dedicated Auth-Mail Subdomain SPF (HardFail -all, <= 10 DNS lookups)
auth-mail.acme.example.com.   300 IN TXT "v=spf1 include:amazonses.com -all"

; 2. Strict Enforcing DMARC on Auth Subdomain + Root Domain
_dmarc.auth-mail.acme.example.com. 300 IN TXT "v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s; pct=100; rua=mailto:[email protected]"
_dmarc.acme.example.com.             300 IN TXT "v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s; pct=100; rua=mailto:[email protected]"

; 3. Magic-Link Runtime Guardrails
- Token TTL: 10 minutes (single-use atomic consume, SHA-256 hashed at rest)
- Browser Binding: Require original PKCE code_verifier or __Host-magic_bind cookie on callback
AuthPosture · OAuth 2.1 & Passkeys $39 AuthPosture Fix Pack

Verify Live OAuth 2.1, OIDC, Passkey & Cookie Posture ($39 Fix Pack)

Run an automated live authentication probe on AuthPosture (auth.runglab.dev) or integrate fleet checks via RungLab Hub API (hub.runglab.dev) and Official MCP Server dev.runglab/devtools — or ship the $39 AuthPosture Fix Pack (tailored OIDC & PKCE S256 patches, RFC 9728 MCP metadata, /.well-known/passkey-endpoints, __Host- cookie rules, COOP/CSP login headers, magic-link DMARC/SPF, and SOC 2 CC6.1 / NIST 800-63B CI gate). Prefer PayPal invoicing? Email [email protected].

Authentication Security Specification & Baseline

Control / Header Hardened Baseline Security & Compliance Rationale
__Host- Prefix Mandatory for Session & CSRF Cookies Blocks sibling subdomain cookie tossing and origin overwrite attacks (RFC 6265bis §4.1.3.2)
Domain Attribute MUST BE OMITTED for __Host- Any Domain=... attribute causes browsers to silently reject __Host- cookies
Path Attribute Path=/ (Exact Root Path) Required alongside Secure for browsers to accept __Host- cookie prefix
HttpOnly + SameSite HttpOnly; SameSite=Lax (or Strict) Blocks document.cookie XSS exfiltration and cross-site CSRF writes

Hardened __Host- Session & CSRF Set-Cookie Headers

host-session-cookies.http
Set-Cookie: __Host-sid=eyJhbGciOiJFUzI1NiJ9.opaque; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
Set-Cookie: __Host-csrf=9f8a7b6c5d4e3f2a1b0c; Path=/; Secure; HttpOnly; SameSite=Strict; Max-Age=3600

Express / Cloudflare Workers Cookie Options

cookie-config.mjs
export const SESSION_COOKIE_OPTIONS = {
  name: "__Host-sid",
  httpOnly: true,
  secure: true,
  sameSite: "lax",
  path: "/",
  maxAge: 3600 // 1 hour sliding / 12h NIST AAL2 absolute max
  // Note: NEVER set 'domain' on __Host- cookies
};

Implementation Steps & Key Insights

  1. Open Mode 4 ('__Host- Cookies, COOP/CSP & Magic-Link') above and paste your HTTP Set-Cookie response headers.
  2. Rename session cookies from sid/token to __Host-sid and remove any Domain= attribute.
  3. Ensure Path=/, Secure, HttpOnly, and SameSite=Lax (or Strict for pure same-site POST actions) are present.
  4. Audit your live login endpoint headers and cookies on https://auth.runglab.dev.
  • Without the __Host- prefix, a compromised marketing or docs subdomain (e.g. blog.acme.com) can overwrite your app's session cookie via Domain=.acme.com.
  • SameSite=Lax preserves normal top-level GET OAuth callback redirects while blocking cross-site POST CSRF.

Common OAuth, Passkey & Cookie Pitfalls

  • Setting both __Host- prefix and Domain=acme.example.com — browsers silently discard the entire Set-Cookie header.
  • Setting SameSite=Strict on the session cookie when third-party SSO / IdP redirects expect the cookie on top-level GET return.
Verify Live: Audit your live domain at auth.runglab.dev ($39 AuthPosture Fix Pack), automate via hub.runglab.dev, or connect Official MCP Server dev.runglab/devtools.

More OAuth 2.1, Passkey & Session Security Tools

← Back to AuthPosture Hub · AuthPosture ($39 Fix Pack) → · hub.runglab.dev → · dev.runglab/devtools →

Frequently Asked Questions

Why does adding Domain=.example.com break __Host- cookies?

RFC 6265bis strictly forbids the Domain attribute on __Host- cookies so that the cookie is host-locked to the exact origin that set it.

Should session cookies use SameSite=Lax or SameSite=Strict?

Use SameSite=Lax for primary session cookies so OAuth/OIDC top-level GET navigation still works, and SameSite=Strict for sensitive state-changing CSRF or step-up tokens.

How can I check live Set-Cookie headers across my auth flows?

Run a live audit on https://auth.runglab.dev ($39 AuthPosture Fix Pack) or call https://hub.runglab.dev.