Skip to content

608 trust the ingress forwarded headers and make every cookie secure - #631

Merged
paulc1983 merged 5 commits into
mainfrom
608-trust-the-ingress-forwarded-headers-and-make-every-cookie-secure
Oct 19, 2026
Merged

paulc1983 merged 5 commits into
mainfrom
608-trust-the-ingress-forwarded-headers-and-make-every-cookie-secure

Conversation

@paulc1983

Copy link
Copy Markdown
Contributor

No description provided.

Pods sit behind Front Door -> nginx ingress, but ForwardedHeadersMiddleware only stops honouring X-Forwarded-* when BOTH KnownProxies AND KnownNetworks are empty, and only KnownProxies was cleared. The loopback KnownNetworks default therefore survived, so the edge's X-Forwarded-Proto was discarded, Request.IsHttps stayed false inside the pod, OIDC built http:// redirect URIs, cookies were never Secure, and app-level HSTS never fired.

Two ordered changes: (1) trust the edge - clear KnownNetworks beside KnownProxies and record why in a comment, since the pod is reachable only through the ingress and that must be revisited if a route bypassing the edge is ever added; (2) make every cookie Secure outside Development - apply IsDevelopment() ? SameAsRequest : Always to the antiforgery cookie and to the auth cookie and the OIDC Correlation/Nonce cookies (AddDfeSignInAuthentication now takes IHostEnvironment).

The order matters: DefaultAntiforgery.CheckSSLConfig throws when the policy is Always and the request is not HTTPS, so trusting X-Forwarded-Proto has to land first or every page with a form would 500.

Unit 7142/7142, integration 1070/1070, E2E 301 passed / 52 skipped / 0 failed against the local Development stack, which keeps SameAsRequest so forms and the browser suite are unaffected. Review-app evidence and the DfE Sign-in https:// callback registration are still outstanding before this ships.

Refs #608
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review app for PR 631 was deleted

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

E2E smoke tests passed

57 passed, 0 failed, 0 skipped in 2 min 28 s

Commit e863b2f against https://check-performance-data-pr-631.test.teacherservices.cloud (run)

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

E2E tests passed

358 passed, 0 failed, 4 skipped in 17 min 17 s

Commit e863b2f against https://check-performance-data-pr-631.test.teacherservices.cloud (run)

@paulc1983
paulc1983 marked this pull request as ready for review October 19, 2026 13:02
ajs-uk-dev
ajs-uk-dev previously approved these changes Oct 19, 2026
Update code and tests to use the renamed property KnownIPNetworks. In CoreWebExtensions.cs replace options.KnownNetworks.Clear() with options.KnownIPNetworks.Clear(). In ForwardedHeadersTrustTests.cs update the assertion to Assert.Empty(options.KnownIPNetworks). Aligns code/tests with the upstream API rename and preserves behavior.
@paulc1983
paulc1983 merged commit fb9b25c into main Oct 19, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
review — e863b2f9 Deployed Oct 19, 2026 by paulc1983 via Delete Review App 631 #342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trust the ingress forwarded headers, and make every cookie Secure

2 participants