Skip to content

Fixes #39253: Accept SAML strict-mode sign-ins behind a TLS-terminating proxy - #39255

Merged
mohityadav766 merged 2 commits into
mainfrom
fix/saml-strict-mode-tls-proxy
Nov 30, 2026
Merged

mohityadav766 merged 2 commits into
mainfrom
fix/saml-strict-mode-tls-proxy

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #39253

With Strict Mode on, every SAML sign-in behind a TLS-terminating load balancer or ingress fails, both the live login and Test Login:

The response was received at http://<host>/callback instead of https://<host>/callback

Why: in strict mode java-saml compares the response's Destination, and the Recipient of its bearer SubjectConfirmationData, with HttpServletRequest.getRequestURL(). When TLS ends at the proxy, Jetty sees plain HTTP. useForwardedHeaders is off by default (SERVER_USE_FORWARDED_HEADERS), so it reports http://, while the IdP addresses the response to the configured https:// ACS. Since the settings form shows Want Messages/Assertions Signed only while Strict Mode is on, such a deployment can't require signed responses.

Fix: both paths that hand java-saml a response (the live ACS in SamlAuthServletHandler and Test Login in TestLoginSamlHandler) now have it compare with the configured ACS URL. This uses java-saml's own SamlResponse.setDestinationUrl hook, through the new SamlResponseValidator.atConfiguredAcs. Outside strict mode, SamlResponseValidator.validate already compares Destination with the same configured URL. A response addressed to any other URL is still rejected.

Turning on forwarded headers was not used as the fix. It trusts client-supplied X-Forwarded-* on every request unless the proxy overwrites them, and every deployment would have to know to set it. The rule is recorded in docs/decisions/2026-11-27-saml-strict-mode-checks-the-configured-acs-url.md.

Backports: 2.1 #39256, 2.0 #39257.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Strict Mode on, ACS https://…, and the IdP's post reaches the server as http://…: the live login completes (303 to the completion page), and Test Login passes "Sign-in response validated".
  • In strict mode, a response addressed to another ACS is still rejected.

Unit tests

  • I added unit tests for the new/changed logic.
  • SamlResponseValidatorTest: strictModeComparesDestinationAndRecipientWithTheConfiguredUrl, strictModeStillRejectsAResponseAddressedToAnotherAcs
  • SamlAuthServletHandlerTest#handleCallback_strictModeAcceptsAResponseThatATlsTerminatingProxyForwardedOverHttp
  • TestLoginSamlHandlerTest#strictModeAcceptsAResponseThatATlsTerminatingProxyForwardedOverHttp
  • Both handler tests failed before the fix with the message above and pass after it. All 19 *Saml*Test and TestLogin*Test classes pass locally (242 tests).

Backend integration tests

  • Not applicable (no backend API changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Reproduced with java-saml 2.9.0 and the repo's MockSamlIdp, using settings built the way SamlSettingsHolder.buildSettings builds them:

  1. Strict off, request URL http://: accepted.
  2. Strict on, request URL http://, ACS https://: rejected with the message above.
  3. Strict on, request URL https:// (what forwarded headers would give): accepted.
  4. Strict on, request URL http://, compared with the configured ACS (this fix): accepted.
  5. Same, but the response is addressed to another ACS: rejected.

Not tested against a real identity provider behind a TLS-terminating proxy.

🤖 Generated with Claude Code

…ng proxy

With Strict Mode on, java-saml compares a response's Destination and the
Recipient of its bearer SubjectConfirmationData with the URL the request
arrived on. When TLS ends at a load balancer, the server sees the identity
provider's post to the https ACS arrive over http, so every response was
rejected ("The response was received at http://... instead of
https://..."), on the live login and on Test Login.

Both paths now have java-saml compare with the configured ACS URL, the URL
SamlResponseValidator already compares Destination with outside strict
mode. A response addressed to any other URL is still rejected.

ADR:2026-11-27-saml-strict-mode-checks-the-configured-acs-url
@mohityadav766
mohityadav766 requested a review from a team as a code owner November 30, 2026 09:11
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

mohityadav766 added a commit that referenced this pull request Nov 30, 2026
…ng proxy (backport 2.0 #39255) (#39257)

With Strict Mode on, java-saml compares a response's Destination and the
Recipient of its bearer SubjectConfirmationData with the URL the request
arrived on. When TLS ends at a load balancer, the server sees the identity
provider's post to the https ACS arrive over http, so every response was
rejected ("The response was received at http://... instead of
https://..."), on the live login and on Test Login.

Both paths now have java-saml compare with the configured ACS URL, the URL
SamlResponseValidator already compares Destination with outside strict
mode. A response addressed to any other URL is still rejected.

2.0's Test Login already installs a response factory that checks the
response answers its request, so atConfiguredAcs wraps that factory's
response. The decision record cites #37437 in place of a record 2.0
does not have.

ADR:2026-11-27-saml-strict-mode-checks-the-configured-acs-url
mohityadav766 added a commit that referenced this pull request Nov 30, 2026
…ng proxy (backport 2.1 #39255) (#39256)

With Strict Mode on, java-saml compares a response's Destination and the
Recipient of its bearer SubjectConfirmationData with the URL the request
arrived on. When TLS ends at a load balancer, the server sees the identity
provider's post to the https ACS arrive over http, so every response was
rejected ("The response was received at http://... instead of
https://..."), on the live login and on Test Login.

Both paths now have java-saml compare with the configured ACS URL, the URL
SamlResponseValidator already compares Destination with outside strict
mode. A response addressed to any other URL is still rejected.

ADR:2026-11-27-saml-strict-mode-checks-the-configured-acs-url
@gitar-bot

gitar-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Changing strict-mode SAML Destination and Recipient checks alters the authentication boundary; an incorrect ACS setting could reject legitimate sign-ins.

Makes SAML strict-mode sign-ins work behind a TLS-terminating proxy by comparing the response's Destination and Recipient against the configured ACS URL via java-saml's setDestinationUrl hook, for both live login and Test Login. Responses addressed to other ACS URLs are still rejected. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@mohityadav766
mohityadav766 merged commit 37a75b5 into main Nov 30, 2026
26 of 27 checks passed
@mohityadav766
mohityadav766 deleted the fix/saml-strict-mode-tls-proxy branch November 30, 2026 16:38
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.

SAML Strict Mode rejects every sign-in behind a TLS-terminating proxy

2 participants