Repository navigation
Conversation
|
@vincbeck @o-nikolas - I need your say here. |
1bf4c0a to
b7d1fc3
Compare
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 |
b7d1fc3 to
bc53532
Compare
|
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
bc53532 to
b563510
Compare
|
@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
Those look identical on the wire. There is no field 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:
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 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 One thing worth flagging separately. Wiring up the tests, I found that 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 Rebased on current Drafted-by: Claude Opus 5; reviewed by @potiuk before posting |
|
Superseded by #73698 (same change, squashed into one commit on a renamed branch). Discussion so far stays here for reference. |
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 thatsaml_auth.login()generates, andlogin_callback()calledprocess_response()with norequest_id. python3-samlonly validates
InResponseTowhen it is given that id, so the check was skipped andany 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.
RelayStateonly selected the return mode and arrived in the same form, sothe response could choose that too.
The change
Each login gets a nonce that travels to the IdP in
RelayStateand names, on the wayback, which of this browser's pending logins the response answers. The pending set
lives in a short-lived signed cookie (
HttpOnly,SameSite=Lax,Securebehind TLS,10 minutes, one entry per login). At the callback the response must match one of those
entries, and
InResponseTomust match that entry's AuthnRequest id. The entry isconsumed 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
/loginis refused, which includes clicking the Airflow tile in theAWS 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 toFalse.With it enabled the assertion must still be signed by the configured IdP, and a
response carrying
InResponseTois still refused: an unsolicited assertion answers norequest, 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
TestLoginRouterwas never collected — by anyone, including CI.mock_plugin_manageris a
contextmanager, and aContextDecoratorapplied to a class replaces the classwith 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_urlin the test config, and aSameSitecheck comparing against the wrong case. There are 27 tests in the file now.check_contextmanager_class_decoratorsalready guards this failure mode but did notlist
mock_plugin_manager; it does now, with tests inscripts/tests/ci/prek/test_check_contextmanager_class_decorators.py. This file wasthe only one in the repo affected.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines