Another common complaint regarding IdP-Initiated SSO is that it can overwrite existing sessions within an SP. However, this is more often an implementation detail rather than a limitation in the protocol’s approach.
Modern IdP-Initiated SSO
We can try and mitigate some of the flaws in this flow using the following techniques:
Follow the Specification
Section 4.1.5 (Unsolicited Responses) of the SAML 2.0 profiles specification states that an SP must ensure that any unsolicited SAML responses received do not contain an InResponseTo
value. This prevents responses generated using SP-Initiated SSO from being stolen and re-used.
Use the Minimum Possible Response Trust Length
When validating SAML responses and assertions, you validate when they were issued and when they expire. The IdP can state when to no longer trust it, but the SP also gets a say. So, make sure that’s as low as possible. After all, the response will probably be generated by the IdP and immediately sent across to the SP. That shouldn’t take more than a few seconds.
Unfortunately, clock skew between the IdP and SP can be an issue with this validation (it is for many of our customers), so you’ll need to find an acceptable middle ground.
Replay Detection
To try and prevent responses/assertions from being re-used, a replay detection mechanism could be implemented. By remembering what responses have already been seen, we can at least stop a stolen message from being reused. However, this approach does not prevent the response from being stolen and then used, or another response from being injected.
Rock Solid Knowledge SAML Implementation
Our SAML component supports SP-initiated and IdP-initiated SSO for both Service Provider and Identity Provider implementations.
To detect replayed SAML responses during the IdP-initiated SSO, our SAML Service Provider component uses your implementation of IDistributedCache
to remember SAML response IDs that it has previously received. By default, IDistributedCache
falls back to an in-memory implementation. For production scenarios, we recommend using a non-volatile cache such as Redis or SQL Server.
IdP-initiated SSO is disabled by default, and you will need to switch it on explicitly. Check out our SAML documentation for enabling IdP-initiated SSO in your SAML Service Provider and SAML Identity Provider.
Conclusion
SAML IdP-initiated SSO definitely has its flaws; however, by taking lessons learned from modern applications and protocols, we can try and mitigate some of these concerns. Unfortunately, we cannot prevent assertion theft and injection, but we can at least stop replay attacks.
These mitigations do push yet more complexity onto the service provider to combat the limitations of the IdP. I’ve seen some articles advocate IdP-initiated SSO due to the fact that an SP might not be capable of creating requests, but now instead, they must start caring about replay attacks. In my opinion, this is more complex to do in a load balanced environment than simply remembering a relay state in the context of the browser.
Check out our SAML component page for more information.