Notes
The model
Single sign-on has two main roles. The identity provider, or IdP, is where you actually log in; it holds the accounts and enforces MFA. The service provider, or SP, is the application you want to use. The SP trusts the IdP to vouch for who you are. So you log in once at the identity provider, and every service provider accepts its word. Common identity providers are Okta, Microsoft Entra, Google Workspace, Ping and self-hosted Keycloak. This central trust is the whole idea, and also the whole risk.
- identity provider (IdP): where you actually log in, holds the accounts and MFA
- service provider (SP): the app you want to use
- the SP trusts the IdP to say who you are log in once at the IdP; every SP accepts its word
- IdPs: Okta, Entra ID, Google, Ping, Keycloak
SAML
SAML, security assertion markup language, is the older enterprise standard. You visit the service provider, which redirects you to the identity provider. You authenticate there. It sends back a signed XML document, an assertion, stating who you are and your attributes, such as groups. The service provider validates the signature and logs you in. The assertion is the heart of it: an identity plus attributes, signed by the identity provider so the service provider can trust it.
- you visit the SP
- SP redirects you to the IdP with a request
- you authenticate at the IdP
- IdP sends back a signed XML "assertion" saying who you are
- SP validates the signature and logs you in assertion = identity + attributes + signature
SAML vs OIDC
SAML and OpenID Connect do the same job, and you choose by context. SAML uses XML, is older, and is deeply embedded in enterprise and on-premises applications. OpenID Connect, which we covered last episode, uses JSON and JWTs and was built for mobile apps, single-page apps and APIs. Both provide single sign-on and federation across organisations. For a new integration, prefer OpenID Connect. But many enterprise applications only speak SAML, so you will meet both, and most identity providers support both at once.
- SAML: XML, older, deeply embedded in enterprise and on-prem apps
- OIDC: JSON/JWT, modern, built for mobile, SPAs and APIs
- both do SSO and federation
- new integrations: prefer OIDC
- existing enterprise apps: often SAML only many IdPs support both
What holds it together
The security of SSO lives in how carefully the service provider validates the assertion. Check the signature is valid and from the expected identity provider key. Confirm the assertion itself is signed, not just the surrounding message. Check the audience, that it was issued for this service provider and no other. Check the time window, so expired assertions are rejected. And prevent replay by tracking assertion identifiers. Miss any and the trust breaks.
- signature: valid, from the expected IdP key
- what is signed: the assertion itself, not just the wrapper
- audience: this assertion is for THIS SP
- time: not expired, not used before its valid window
- replay: each assertion used once (track the ID)
Classic SAML bugs
SAML has a famous family of vulnerabilities, because validating signed XML correctly is hard. In signature wrapping, an attacker adds a second, unsigned assertion positioned so the signature check validates the real one but the application reads the attacker's. XML external entity flaws leak files. Some bugs let a comment inside a username change which user the application saw. The lesson: use a hardened, current SAML library and never parse or validate the XML yourself.
- signature wrapping (XSW): an unsigned assertion the app reads but validation ignores
- XXE in the parser
- comment-injection in how libraries read NameID
- accepting unsigned assertions
- fix: a hardened SAML library; never DIY XML
Concentrated risk
Single sign-on is a trade. It concentrates risk: compromise the identity provider, or one of its admins, and you reach every connected app at once. This is why phishing an identity provider session or its MFA is now the primary attack path in many breaches. So the identity provider is protected hardest of all: phishing-resistant MFA, tight admin restrictions, heavy logging. The flip side is a benefit, deprovisioning: disable someone once and their access disappears everywhere.
- compromise the IdP or an admin, and you reach every connected app
- phishing the IdP session or its MFA is the main path
- protect it hardest: phishing- resistant MFA, admin limits, logging
- disable once = access gone everywhere
Provisioning and logout
SSO is more than login. Provisioning matters too: the SCIM standard lets the identity provider automatically create, update and disable accounts in connected apps, so a leaver is removed everywhere. Just-in-time provisioning creates the account on first login instead. Single logout aims to end app sessions when the identity provider session ends, though it is hard to make reliable. And the identity provider session lifetime governs real exposure, because a long-lived one is a long-lived key to everything.
- SCIM: automatically create, update and disable accounts in apps from the IdP
- JIT provisioning: create the account on first login
- single logout: ending the IdP session should end app sessions (hard in practice)
- session length at the IdP governs real exposure
Common mistakes
Mistakes. Hand-rolling SAML XML validation instead of using a hardened library. Accepting unsigned assertions, or checking only the wrapper signature and falling to signature wrapping. Not checking the audience, expiry or replay of an assertion. Leaving XML external entities enabled in the parser. Weak MFA on the identity provider itself, which undermines everything downstream. And no automated deprovisioning, so people who leave keep access to applications long after their accounts should be gone.
- hand-rolling SAML XML validation
- accepting unsigned or wrapper-only signatures
- not checking audience, expiry or replay
- XXE left enabled in the parser
- weak MFA on the IdP itself
- no automated deprovisioning (leavers keep access)
Say it like this
In the interview: the service provider redirects the user to the identity provider, which authenticates them and returns a signed XML assertion. The service provider validates the signature against the identity provider's key, checks the audience, time window and replay, then logs the user in. I stress using a vetted SAML library, not hand-parsed XML, because of signature wrapping. And because SSO concentrates risk, I protect the identity provider with phishing-resistant MFA and automate provisioning with SCIM.
- "The SP redirects the user to the IdP, which authenticates
- them and returns a signed XML
- assertion. The SP validates
- the signature, audience, time
- and replay, then logs them
- in. I use a vetted library, never custom XML, protect the IdP with phishing-resistant
- MFA, and automate deprovisioning."