Domain tracks · L2Enterprise SSO and SCIM

Enterprise SSO and SCIM

Let each customer's own identity provider log people in and remove them, and check every answer it sends you.

L2 SeniorDomain tracks20 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 10 Nov 2026 · How we check content
Section 1 of 8

What broke

On 12 March 2025, GitHub's security lab published a write-up called "Sign in as anyone". It described critical bugs in ruby-saml, a Ruby library that apps use to accept SAML logins. 1

The library used two different XML parsers while it checked a signature. An attacker could build a document that the two parsers read differently. One parser found one signature. The other parser found a different one. So the check passed on content that was never really signed. 1

The attacker needed one valid signature from the target company's identity provider. That could come from an ordinary user's login response. In some cases, it could come from the provider's public metadata. With it, they could forge an assertion for any user and log in as that user. 1

The researchers found a working instance in GitLab. GitLab released a critical patch on 12 March 2025. That was the same day as the write-up. On a GitLab instance with SAML login, "an attacker with access to a valid signed SAML document from the IdP could authenticate as another valid user". 2

GitLab's stopgaps show where the flaw was. Turn on two-factor login inside GitLab. Require admin approval for new users created on the fly. Multi-factor login at the identity provider "does not mitigate this vulnerability". 2 The flaw was in the SAML library inside the app. The forged login never passed through the provider, so nothing the provider did could stop it.

The lesson: when a customer's identity provider logs users in to your app, your app must check every answer it receives. One weak check, and anyone can be anyone.

Section 2 of 8

The idea in simple words

A large customer has thousands of staff. It keeps them all in one directory, such as Okta or Microsoft Entra ID. It wants three things from every SaaS app it buys:

  1. Single sign-on. Staff log in with their company account and company MFA. No separate password for your app.
  2. Provisioning. New staff get an account on day one, with the right role.
  3. Deprovisioning. When someone leaves, their access to your app ends the same day.

Two kinds of standards do this. SAML 2.0 and OpenID Connect (OIDC) handle the login. SCIM 2.0 handles creating, changing and removing users. Microsoft says SCIM "is becoming the de facto standard for provisioning". 8

The customer's system is the identity provider (IdP). Your app is the service provider (SP) in SAML, or the relying party (RP) in OIDC. Each customer is a tenant with its own IdP. See Multi-tenancy and noisy neighbours.

The key idea. In enterprise SSO, someone else's system tells you who the user is. Find the right IdP for the tenant, check every signed answer strictly, and let the IdP remove users, not only add them.

Section 3 of 8

How it works

Step through one SAML login. Use Next and Back, or the ← and → keys.

One SP-initiated SAML login: find the tenant's IdP, then check the answer before you trust it Browser App (SP) Acme's IdP asha@acme.comacme.com ✓→ tenant 42 redirectAuthnRequest ID=r7 login + MFAsigned ResponsePOST /acs signature: tenant certused = signedAudience = usInResponseTo = r7time ± skew key: (tenant 42, persistent ID)not the email✓ session for Asha SeniorPath
  1. Asha types her work email. Your app finds acme.com in its list of verified domains. That domain belongs to tenant 42, which uses its own identity provider (IdP).
  2. Your app is the service provider (SP). It sends the browser to tenant 42's IdP with a SAML AuthnRequest. The request has an ID, here r7. The app remembers it.
  3. Asha logs in at her company's IdP, with MFA. The IdP signs a SAML Response that holds an assertion about her. The browser posts it to your app's assertion consumer service URL.
  4. Now the checks. Verify the signature with the certificate stored for tenant 42. Read data only from the signed element. Check the audience, InResponseTo r7 and the time window, with a small skew allowance.
  5. Only now find the user. Key the account on the tenant and a persistent ID from the IdP that is never reassigned, not on the email. Then create a normal session, as in the login lesson.
Step 1 of 5

SAML and OIDC in one table

The authentication lesson covered OIDC ID tokens. SAML does the same job with older tools.

SAML 2.0OIDC
The proof of loginAn XML assertion, inside a ResponseAn ID token, which is a JWT
How it is signedXML SignatureJSON Web Signature
How it reaches youThe browser posts it to your assertion consumer service (ACS) URLUsually, your server swaps a code for it
Who it is forAudience must be your entity ID 3aud must hold your client ID 4

Our advice: support both if you sell to enterprises. For new work, prefer OIDC. It is simpler to check, because there is no XML.

SP-initiated and IdP-initiated login

In SP-initiated login, the user starts at your app. You send an AuthnRequest with an ID. The response must return that ID in InResponseTo. 3

In IdP-initiated login, the user clicks your app's tile in the IdP's portal. A response arrives that you never asked for. OWASP says this is "inherently less secure by design", because it has no login CSRF protection. 3 If customers need it, add replay detection, and check RelayState against an allowlist. 3

The checks on every SAML response

OWASP lists them. 3 In short:

  • Schema first. Validate the XML against trusted local schema copies.
  • The right key. Trust the X.509 certificate stored for this tenant. Ignore any KeyInfo in the message, so an attacker cannot send their own key.
  • Signed means used. The signature's reference must cover the assertion you read. Never use getElementsByTagName to find security elements. Breaking this rule allows XML signature wrapping: the attacker keeps the signed part and adds an unsigned part that your code reads. These attacks on SAML were described in 2012. 3
  • Destination and recipient. Destination and Recipient must match your ACS URL exactly.
  • Audience. Audience must be your entity ID. Otherwise a response meant for another app works on yours.
  • Time. Check NotBefore and NotOnOrAfter.

Clocks on two systems never agree exactly. This is clock skew. The OIDC spec allows "some small leeway, usually no more than a few minutes". 4 Use the same small window for SAML. Never turn off the time check to fix a skew error.

Do not write these checks yourself. Use a well-known library, keep it patched, and test it with bad responses.

Routing users to the right IdP

Your login page has one email box. Many SaaS apps route by email domain:

const domain = email.split("@")[1].toLowerCase();
const conn = await ssoConnections.findVerified(domain);
if (conn) return redirectToIdp(conn); // tenant's SAML or OIDC
return showPasswordLogin();

The word that matters is "verified". A tenant proves it owns acme.com by adding a DNS TXT record with a value you give it. 11 Without this, a tenant could claim gmail.com or a rival's domain.

Store one connection per tenant: IdP entity ID, SSO URL, signing certificates and your ACS URL. Allow two certificates at once, so the customer can rotate keys without downtime. Once SSO works, let the tenant admin enforce it. Docker, for example, then requires SSO for every login. 11

JIT provisioning versus SCIM

Just-in-time (JIT) provisioning creates the user at their first login, from the assertion's attributes. It is easy. But Docker's docs say it plainly: "It doesn't deprovision users." 10

SCIM is a REST API that you host and the IdP calls. RFC 7643 defines two core resources, User and Group. 6 RFC 7644 defines the calls: 7

  • POST /Users creates a user. Return 201. A duplicate userName gets 409.
  • GET /Users?filter=userName eq "asha@acme.com" finds one.
  • PATCH changes some attributes. The body lists add, remove and replace operations.
  • DELETE returns 204. Later GETs must return 404.

Store externalId. It is the IdP's own ID for the user. 6

Offboarding

When someone leaves, Microsoft Entra can soft-delete the user with a PATCH like this: 9

{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
  "Operations": [{ "op": "Replace", "path": "active", "value": false }]
}

Note Replace with a capital R. Entra sends op values that way, so match them without regard to case. 9

Entra expects GET to keep returning an inactive user. Only a hard delete removes it. 9 The spec leaves the meaning of active to you. 6 So make active: false end everything: sessions, API tokens and pending invites. If old sessions survive, the IdP believes the person is gone while they are still inside.

Groups to roles

A user's groups attribute is read-only. Membership changes arrive on the Group resource. 6 Entra sends a PATCH that adds or removes members. 9 Let each tenant admin map their groups to your roles, such as "Acme-Finance" to "billing-admin". Then your normal authorization model takes over. See Authorization models.

Any IdP can put any email in an assertion. OIDC says only iss and sub together are stable. Email "MUST NOT be used" as a unique ID. 4 In 2023, Microsoft warned that apps using the email claim for authorization risk privilege escalation, because some emails were not verified. 5

Key each SSO identity on the tenant, the IdP and its subject ID. In SAML, ask for a persistent NameID or a fixed, never-reassigned user ID attribute. An email-format or transient NameID is not stable. Link an SSO identity to an existing password account only after that user proves they own the account.

Section 4 of 8

Trade-offs

OptionRemoves users when they leave?Setup costMain riskUse it when
Passwords plus invitesNo An admin must remember.LowFormer staff keep access.Small customers with no IdP.
SSO plus JITNo It only creates and updates at login. 10MediumAccounts and sessions outlive the job.A first enterprise tier.
SSO plus SCIMYes The IdP sends active: false or DELETE. 9High. You host a SCIM API.Partial PATCH support breaks syncs.Customers with security reviews and audits.
IdP-initiated loginNot related.LowNo InResponseTo, so replay and login CSRF. 3Only when customers need portal tiles.

Simple rule: offer SSO with JIT first. Add SCIM before your first large customer's security review. Make deactivation end every session.

Section 5 of 8

At work: how a senior uses this

  • Ask: "Which element did we verify, and which element did we read the user from?" They must be the same.
  • Keep a test suite of bad SAML responses: unsigned, wrong audience, wrong recipient, expired and wrapped. Run it on every library upgrade.
  • Pin each tenant's certificate. Alert two weeks before it expires.
  • Ask: "When SCIM sets active to false, what still works?" Test sessions, API tokens and mobile refresh tokens.
  • Log every SCIM call with tenant, operation and result. Customers will ask why a user still had access.
  • Never let a tenant claim a domain without DNS proof.
  • Subscribe to security advisories for your SAML and OIDC libraries.
Section 6 of 8

With AI

What to ask the agent

"List every check our SAML handler runs, in order. For each, show the line. Compare with the OWASP SAML Security Cheat Sheet and mark what is missing."

"Write tests that post these SAML responses to our ACS endpoint: unsigned, signed for another audience, expired, and with a second unsigned assertion added. Each must fail."

"Implement PATCH /scim/v2/Users/{id} per RFC 7644. When active becomes false, revoke all sessions and API tokens for that user in that tenant."

What to check yourself

  • The code does not parse SAML with a hand-written XML lookup. It calls a maintained library.
  • Users are found by tenant plus IdP subject ID, never by email alone.
  • Domain routing reads only verified domains.
  • Every SCIM query and write is scoped to the tenant that owns the bearer token.
  • Deactivation revokes tokens, not only the login.
  • The AI did not invent SCIM fields. Compare them with RFC 7643.
Section 7 of 8

Check yourself

1. Your SAML library finds the signature and the assertion with two different lookups. An attacker adds a second, unsigned assertion. What is the risk?

Show answer

The library may check the signed assertion but read the user from the unsigned one. This is XML signature wrapping. You must read data only from the element the signature covers. OWASP says to reject assertions outside the signed content.

2. Two users sign in with SSO. Both IdPs send the email bob@acme.com. How should your app pick the account?

Show answer

By the tenant's IdP plus the IdP's stable subject ID. OpenID Connect says only iss and sub together are a stable identifier. Email must not be used as a unique ID. Any IdP can send any email.

3. An employee leaves Acme. Acme uses JIT provisioning only, with no SCIM. What happens to their account in your app?

Show answer

It stays active in your app. They cannot log in through the IdP, but old sessions and API tokens can keep working. JIT creates and updates users at login. It does not deprovision. Without SCIM, nothing tells your app that the person left.

4. Microsoft Entra sends PATCH /Users/123 with active set to false. What should your app do?

Show answer

Block the user, end their sessions and tokens, and keep returning the user from GET. This is a soft delete. Entra expects the user to still come back from queries. Your app decides what inactive means, so make it end all access.

5. Why should you verify that a tenant owns a domain before you route its emails to that tenant's IdP?

Show answer

So that one tenant cannot claim gmail.com or a rival's domain and capture other people's logins. Domain routing decides which IdP a user trusts. An unverified claim would let any tenant send other companies' users to an IdP it controls.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 11 sources and related lessons
  1. Peter Stöckli, Sign in as anyone: Bypassing SAML SSO authentication with parser differentials, The GitHub Blog (12 March 2025) (opens in a new tab)
    How two XML parsers in one library disagreed about which signature to check, and how that let an attacker log in as any user.
  2. GitLab Critical Patch Release: 17.9.2, 17.8.5, 17.7.7 (opens in a new tab)
    The vendor's advisory for the same flaw, who was affected, and the stopgaps for customers who could not upgrade at once.
  3. OWASP Cheat Sheet Series, SAML Security Cheat Sheet (opens in a new tab)
    The checks a service provider must run on every SAML response, and why IdP-initiated login is weaker.
  4. OpenID Foundation, OpenID Connect Core 1.0 (opens in a new tab)
    Clock skew leeway, the email_verified claim, and why only iss plus sub identifies a user.
  5. Microsoft Security Response Center, Potential Risk of Privilege Escalation in Azure AD Applications (20 June 2023) (opens in a new tab)
    A real case of apps trusting an email claim that nobody had verified.
  6. Hunt, Grizzle, Wahlstroem and Mortimore, RFC 7643: System for Cross-domain Identity Management: Core Schema (IETF, 2015) (opens in a new tab)
    The User and Group resources, and the userName, externalId, active and members attributes.
  7. Hunt, Grizzle, Ansari, Wahlstroem and Mortimore, RFC 7644: System for Cross-domain Identity Management: Protocol (IETF, 2015) (opens in a new tab)
    The SCIM HTTP API, with create, filter, PATCH and DELETE, and their status codes.
  8. Microsoft Learn, What is automated app user provisioning in Microsoft Entra ID (opens in a new tab)
    Why companies automate provisioning and deprovisioning, and where SCIM, SAML and OIDC fit.
  9. Microsoft Learn, Tutorial - Develop a SCIM endpoint for user provisioning to apps from Microsoft Entra ID (opens in a new tab)
    What one big identity provider actually sends to your SCIM endpoint, with request and response examples.
  10. Docker Docs, User provisioning overview (opens in a new tab)
    A short, real comparison of JIT provisioning and SCIM in one SaaS product.
  11. Docker Docs, Set up single sign-on (opens in a new tab)
    Domain verification with a DNS TXT record, and what changes when SSO is enforced.

Real incident: ruby-saml (open source), GitLab, 12 Mar 2025: ruby-saml: two XML parsers disagreed, so anyone could sign in as anyone

Related: Authentication and authorization · Multi-tenancy and noisy neighbours · Authorization models: RBAC, ABAC and ReBAC · OWASP Top 10 and secure coding

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper