Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

SP-initiated and IdP-initiated sign-in

A SAML sign-in can start at the training service, which then knows what it asked for, or at Cedar Inc.'s portal, which sends a response nobody requested. The difference decides what the training service can check, and what an unsolicited response lets an attacker try.

Starting at the application

Avery's manager sends her a link to a fire safety course, https://training.example/courses/fire-safety. She clicks it, signs in at Cedar Inc. and lands on the course. That flow, the one in How SAML sign-in works, is SP-initiated sign-in: the service provider noticed that Avery had no session and started the exchange with an AuthnRequest.

Starting at the application gives the training service two things it will use when the response arrives. It knows what it asked for, because it sent the request, and it knows which browser asked, because it saved a note in that browser's context. Both let it treat the response as the answer to a question it actually put, rather than as a message that simply turned up.

Cedar Inc. checks the request before anyone signs in. The Issuer must be a service provider it has an agreement with, the signature on the query string must verify with that provider's certificate if signed requests are required, and the ACS named in the request must be one the provider registered. A signature authenticates the requester; it does not make every value in the request acceptable.

Keeping the round trip together

When the training service sent the request _a7f3c2e91b0d, it saved a record of it: the request ID, the time, the course Avery wanted, and a reference stored in a cookie on Avery's browser. Cedar Inc. answers with InResponseTo="_a7f3c2e91b0d", and so does the signed SubjectConfirmationData inside the assertion. At the ACS, the training service checks three things together: the ID names a request it sent, that request is still pending and within its deadline, and it belongs to the browser presenting the response.

The last check matters because a valid response is valuable to anyone who can carry it. Suppose two browsers have each started a sign-in:

BrowserPending requestWanted
Avery's laptop_a7f3c2e91b0dThe fire safety course
Another browser_d40b7e26c1f9The finance course

If a response with InResponseTo="_a7f3c2e91b0d" arrives from the other browser, the ID is genuine, but it belongs to a different browser's attempt, and the training service refuses it. Each pending request is also used once and expires after a few minutes, so a response cannot be accepted twice or long after Avery walked away.

The cookie that ties the request to the browser meets a browser rule on the way back. The response arrives as a form post from login.cedar.example, a cross-site request, so the browser leaves out cookies marked SameSite=Lax or Strict. A training service that keeps its pending-request cookie that way will find it missing at the ACS. The usual fix is to give that one short-lived cookie SameSite=None; Secure, while the training service's own session cookie keeps its stricter setting.

RelayState travels alongside the messages and comes back unchanged. The training service can use it to remember that Avery wanted the fire safety course. The safest value is an opaque reference to the saved record, such as c7f2a9, rather than a URL. A service that redirects to whatever URL arrives in RelayState has built an open redirector, which an attacker can use to send people from a trusted address to a malicious one.

Starting at the provider

Many companies also give staff a launcher, a page at the identity provider with a tile for each application. When Avery clicks the training tile, Cedar Inc. already knows who she is, so it builds a response for the training service straight away and posts it to the ACS. No AuthnRequest was ever sent. This is IdP-initiated sign-in, and the response is called unsolicited.

The response looks almost the same as before. It is signed, it has the right Audience, Recipient and validity window, and the training service can check all of that. What is missing is InResponseTo, both on the response and in the SubjectConfirmationData, because there is nothing to respond to. The SAML profile allows this, and the training service must decide in advance whether it accepts unsolicited responses at all.

What an unsolicited response risks

Without a request, the training service loses its link between the response and the browser presenting it. That gap enables an attack called login cross-site request forgery, or login CSRF. An attacker signs in to the training service through Cedar Inc. with their own account, if they have one, and captures the genuine response before it reaches the ACS. They then put that response in a form on a page they control. When Avery visits the page, her browser posts the attacker's response to the training service, which sees a valid, unsolicited assertion and signs Avery's browser in, as the attacker.

Avery may not notice. She keeps working, uploads a document or types notes into what she thinks is her own account, and the attacker later reads them by signing in normally. With a request, this fails: the attacker's response would name a request that Avery's browser never made.

The second risk is replay. A captured unsolicited response stays acceptable at the ACS until its NotOnOrAfter, and with no pending request to consume, the only protection is the training service's memory of assertion IDs it has accepted. That replay cache becomes essential, not optional.

A service that accepts unsolicited responses can reduce both risks: very short assertion lifetimes, a strict replay cache, and a confirmation page after an unsolicited sign-in that shows which account was signed in before anything is done in it. The strongest option removes the gap entirely, as the next section describes.

A solicited response is matched to a pending request in the same browser. An unsolicited response has nothing to match, so the service provider refuses it or turns it into a fresh SP-initiated sign-in.

Choosing the experience deliberately

A launcher tile does not have to send an unsolicited response. Cedar Inc. can point the tile at the training service's own sign-in address, for example https://training.example/saml/login?target=courses. The training service then starts an ordinary SP-initiated exchange, Cedar Inc. sees that Avery already has a session and answers at once, and Avery notices no difference. She still starts from the tile, while the protocol starts at the application, with a pending request, an InResponseTo and full protection against login CSRF.

Some service providers go further and, when an unsolicited response arrives, do not use it at all: they redirect the browser to start an SP-initiated sign-in, which Cedar Inc. completes silently. Either way, which initiation modes are allowed is part of the agreement, and each is tested on its own.

When a sign-in fails, the mode is a good first question. A refused unsolicited response may be the policy working, not a broken certificate. A response with an unknown InResponseTo may mean the pending record expired, or the cookie was dropped on the way back. Turning off request matching to make the error go away would reopen exactly the gap this lesson describes.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

The training service accepts unsolicited responses. An attacker posts their own valid assertion from Avery's browser. What happens if nothing else is checked? 1 of 3

Choose one answer.

Cedar Inc. wants a launcher tile for the training service without the risks of unsolicited responses. What should the tile do? 2 of 3

Choose one answer.

A correctly signed response with InResponseTo="_a7f3c2e91b0d" reaches the training service's ACS, but from a browser that never started that request. What should the service do? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity