Skip to content

Bind the AWS auth manager SAML response to the browser that started the login - #72647

Closed
potiuk wants to merge 2 commits into
apache:mainfrom
potiuk:security/aws-saml-inresponseto
Closed

potiuk wants to merge 2 commits into
apache:mainfrom
potiuk:security/aws-saml-inresponseto

Conversation

@potiuk

@potiuk potiuk commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

The AWS auth manager's SAML login flow did not bind the authentication response to
the browser that started it.

login() discarded the AuthnRequest id that saml_auth.login() generates, and
login_callback() called process_response() with no request_id. python3-saml
only validates InResponseTo when it is given that id, so the check was skipped and
any assertion the IdP had signed was accepted.

A signed assertion authenticates the identity in the response; it does not
establish which browser asked. An attacker could therefore complete a login in a
victim's browser using their own assertion, silently logging the victim into the
attacker's account — any work the victim then did landed in a session the attacker
controls. RelayState only selected the return mode and arrived in the same form, so
the response could choose that too.

The change

Each login gets a nonce that travels to the IdP in RelayState and names, on the way
back, which of this browser's pending logins the response answers. The pending set
lives in a short-lived signed cookie (HttpOnly, SameSite=Lax, Secure behind TLS,
10 minutes, one entry per login). At the callback the response must match one of those
entries, and InResponseTo must match that entry's AuthnRequest id. The entry is
consumed on use — on both the redirect and the token paths — so a request id cannot
answer a second response, and logins started in other tabs are left alone.

IdP-initiated SSO

Binding the response to an SP-initiated request means a SAML POST that did not start
at this browser's /login is refused, which includes clicking the Airflow tile in the
AWS Identity Center access portal. Per the discussion below, that flow is kept
available behind an opt-in rather than broken — [aws_auth_manager] allow_idp_initiated_login, defaulting to False.

With it enabled the assertion must still be signed by the configured IdP, and a
response carrying InResponseTo is still refused: an unsolicited assertion answers no
request, so one naming a request is a solicited assertion being replayed. What it
gives up is the guarantee that the browser receiving the response is the one that
asked for it. Documented in
providers/amazon/docs/auth-manager/setup/identity-center.rst.

Test collection fix

TestLoginRouter was never collected — by anyone, including CI. mock_plugin_manager
is a contextmanager, and a ContextDecorator applied to a class replaces the class
with a function, so pytest found nothing and reported success. It is now an autouse
fixture, which ran the module's tests for the first time and surfaced two assertions
that had never executed: a missing [api] base_url in the test config, and a
SameSite check comparing against the wrong case. There are 27 tests in the file now.

check_contextmanager_class_decorators already guards this failure mode but did not
list mock_plugin_manager; it does now, with tests in
scripts/tests/ci/prek/test_check_contextmanager_class_decorators.py. This file was
the only one in the repo affected.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines

@boring-cyborg boring-cyborg Bot added area:providers provider:amazon AWS/Amazon - related issues labels Sep 7, 2026
@potiuk

potiuk commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@vincbeck @o-nikolas - I need your say here.

@potiuk
potiuk force-pushed the security/aws-saml-inresponseto branch from 1bf4c0a to b7d1fc3 Compare September 7, 2026 18:24
vincbeck
vincbeck previously approved these changes Sep 9, 2026

@vincbeck vincbeck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me

@o-nikolas

Copy link
Copy Markdown
Contributor

but it means a SAML POST that did not start at this browser's /login is refused. That
includes clicking the Airflow tile in the AWS Identity Center access portal,
which is a normal way to use it.

I'm not sure how often this way of logging in is used. @vincbeck Do you have a stakeholder we can contact internally to find out?

@vincbeck

Copy link
Copy Markdown
Contributor

but it means a SAML POST that did not start at this browser's /login is refused. That
includes clicking the Airflow tile in the AWS Identity Center access portal,
which is a normal way to use it.

I'm not sure how often this way of logging in is used. @vincbeck Do you have a stakeholder we can contact internally to find out?

No but I can say this is probably something used to authenticate. Which makes me wonder, is that really an issue then?

@o-nikolas

Copy link
Copy Markdown
Contributor

but it means a SAML POST that did not start at this browser's /login is refused. That
includes clicking the Airflow tile in the AWS Identity Center access portal,
which is a normal way to use it.

I'm not sure how often this way of logging in is used. @vincbeck Do you have a stakeholder we can contact internally to find out?

No but I can say this is probably something used to authenticate. Which makes me wonder, is that really an issue then?

It's not my area of expertise, but I'm certainly suspicious that this would shut down a currently used way of logging in

@vincbeck
vincbeck dismissed their stale review September 15, 2026 12:34

Second thought

@potiuk
potiuk force-pushed the security/aws-saml-inresponseto branch from b7d1fc3 to bc53532 Compare September 18, 2026 10:26
@vincbeck

Copy link
Copy Markdown
Contributor

Do we want to move forward with this one? I think we should close it and consider it a non issue

…he login

The login handler discarded the AuthnRequest id that saml_auth.login() generates,
and the callback called process_response() with no request_id. python3-saml only
validates InResponseTo when it is given that id, so the check was skipped and any
assertion the identity provider had signed was accepted.

A signed assertion authenticates the identity in the response; it does not
establish which browser asked. An attacker could therefore complete a login in a
victim's browser using their own assertion, silently logging the victim into the
attacker's account, with any work the victim then did landing in a session the
attacker controls. RelayState only selects the return mode and is supplied in the
same form, so it could be chosen by the response as well.

Remember the AuthnRequest id and the return mode in a short-lived cookie when the
flow starts -- HttpOnly, SameSite=Lax, Secure behind TLS, ten minutes -- and at
the callback require InResponseTo to match it and the RelayState to be the one
the browser asked for. The cookie is cleared once consumed so a request id cannot
be used for a second response.

A browser that started no login is refused rather than authenticated.

Note the residual: an attacker able to write cookies for the Airflow origin (for
example from a sibling subdomain) can plant a state cookie matching their own
assertion. That is the accepted limit of session-bound CSRF defence and applies
equally to the session cookie itself; it is not reachable from an unrelated
origin, which is the attack this closes.
Adds ``[aws_auth_manager] allow_idp_initiated_login`` so deployments that need the
Identity Center access portal tile can accept unsolicited assertions, while the
browser binding stays the default. With the option on, a response carrying
``InResponseTo`` is still refused: an unsolicited assertion answers no request, so
one naming a request is a solicited assertion being replayed, and python3-saml
skips that comparison entirely when it is handed no request id.

The login state moves from a single ``request_id:relay_state`` cookie value to a
signed, multi-entry one. Each login gets a nonce that travels in ``RelayState`` and
names which pending login a response answers, so two tabs no longer overwrite each
other, the matched entry is consumed on use, and an entry cannot be forged.

``TestLoginRouter`` was never collected. ``mock_plugin_manager`` is a
``contextmanager``, and a ``ContextDecorator`` applied to a class replaces the class
with a function, so pytest found nothing and reported success. Moving it to an
autouse fixture ran this module's tests for the first time, which surfaced two
assertions that had never executed: a missing ``[api] base_url`` in the test config,
and a ``SameSite`` check that compared against the wrong case.
``check_contextmanager_class_decorators`` already guards this failure mode but did
not list ``mock_plugin_manager``; it does now, with tests.

Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the security/aws-saml-inresponseto branch from bc53532 to b563510 Compare September 21, 2026 21:41
@potiuk

potiuk commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

@vincbeck @o-nikolas — answering the "is that really an issue then?" directly, because I think two separate claims are getting merged.

"IdP-initiated SSO is used" and "accepting unsolicited assertions is safe" are different statements. The first is true and I'm not disputing it. The problem is that without InResponseTo, the SP cannot tell apart:

  • a genuine access-portal login, and
  • an attacker POSTing their own legitimately-obtained, correctly-signed assertion into a victim's browser.

Those look identical on the wire. There is no field login_callback() could consult to distinguish them. Nothing is forged, and signature validation works exactly as intended — the assertion authenticates the identity in the response, it just never establishes which browser asked.

The consequence is a forced login: the victim lands in the attacker's Airflow session, and whatever they do next — edit a connection, paste a token, upload something — goes somewhere the attacker can read later.

So I don't think it's a non-issue. But the usability objection is right, and it killed option 1. I've dropped it and implemented option 2, now pushed:

  • the default binds the response to the login this browser started;
  • [aws_auth_manager] allow_idp_initiated_login (default False) accepts unsolicited assertions for deployments that need the access portal tile.

Deployments that never use IdP-initiated SSO get the fix for free; the ones that do keep working after a one-line config change, having made that choice knowingly. With the option on, a response carrying InResponseTo is still refused — an unsolicited assertion answers no request, so one naming a request is a solicited assertion being replayed, and python3-saml skips that comparison entirely when handed no request id.

Correcting something I wrote in the description. I said the state should move server-side keyed by an opaque nonce, and that this would close the cookie-injection path where signing would not. That's wrong: an attacker who can write cookies for this origin can start a real login, obtain genuine server-side state, and plant that nonce just as easily. Cookie-write access defeats both — it's a different threat. What server-side state actually buys is single-use enforcement and concurrent logins, and neither needs a store.

So the state is now a signed, multi-entry cookie: each login gets a nonce that rides in RelayState and names which pending login a response answers. Two tabs no longer overwrite each other, the matched entry is consumed on use, and entries can't be forged. That also keeps shared mutable state out of the API server, which has nowhere to put it — [api] workers defaults to 1 and HA is documented as multiple API servers, so an in-process store would have been wrong.

One thing worth flagging separately. Wiring up the tests, I found that TestLoginRouter has never been collected — by anyone, including CI. mock_plugin_manager is a contextmanager, and a ContextDecorator applied to a class replaces the class with a function, so pytest found nothing and reported success. That is what the "collects zero items" note in the description was; it wasn't my environment.

Moving it to an autouse fixture ran the module for the first time and immediately turned up two assertions that had never executed: a missing [api] base_url, and a SameSite check comparing against the wrong case. There are 27 tests in the file now and they pass. check_contextmanager_class_decorators already exists for exactly this failure mode but didn't list mock_plugin_manager — it does now, with tests. This file was the only one in the repo affected.

Rebased on current main, static checks green. I'll take it out of draft once you're happy with option 2 as the shape. If you'd still rather close it, I'll close it — but I'd want that recorded as a deliberate accept of the risk rather than "not an issue".


Drafted-by: Claude Opus 5; reviewed by @potiuk before posting

@potiuk
potiuk marked this pull request as ready for review September 21, 2026 21:45
@potiuk potiuk closed this Sep 24, 2026
@potiuk
potiuk deleted the security/aws-saml-inresponseto branch September 24, 2026 21:40
@potiuk

potiuk commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

Superseded by #73698 (same change, squashed into one commit on a renamed branch). Discussion so far stays here for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants