Skip to content
Back to CurriculumLesson 16 of 30
oauth-oidcExpert

Enterprise Single Sign-On (SSO): SAML 2.0 vs OIDC & XML Digital Signature Security

Enterprise Single Sign-On allows corporate users to authenticate once across all workplace tools. SAML 2.0 uses XML-based assertions signed with XML-DSig, while modern enterprise SSO leverages OIDC with JSON Web Tokens. Securing SAML requires defending against XML Signature Wrapping (XSW) and XML External Entity (XXE) attacks.

Interactive Visual Concept ExplainerStep-by-Step Educational Simulation
Visual Step-by-Step Concept Explaineroauth-oidc
Enterprise Single Sign-On (SSO): SAML 2.0 vs OIDC & XML Digital Signature Security
Steps:
SAML 2.0 (Legacy Enterprise)
• Heavy XML-DSig signature wrapping
• POST binding via browser form redirect
• Prone to XML External Entity (XXE) parser flaws
OpenID Connect (Modern Standard)
• Compact JSON Web Tokens (JWS / JWE)
• Native mobile and SPA support via PKCE
• Simple HTTP GET /.well-known/openid-configuration
Step 1 of 6
Auto-stepping (1x)

Step 1: User enters their corporate email (@acme.com) on CosmosApp login page.

Security Guarantee: Enterprise SSO centralizes user provisioning and immediate offboarding across thousands of applications.
Why This Architectural Concept Exists

Enterprises manage thousands of employees across hundreds of SaaS applications. Requiring separate passwords for each tool invites password fatigue and prevents centralized offboarding. Enterprise SSO delegates authentication to an enterprise Identity Provider (Okta, Azure AD, PingIdentity).

Intuitive Mental Model

The Corporate Notary Deed vs Digital Smartcard: SAML is an elaborate, multi-page legal deed written on parchment with wax seals and notary signatures (XML-DSig). OIDC is a modern microchip badge with an embedded digital signature (JSON/JWT).

Architectural System TopologyProtocol Diagram
[ Enterprise Employee ]                 [ CosmosApp (SP) ]              [ Okta / Azure AD (IdP) ]
         │                                       │                                  │
         ├── (1) Navigates to cosmos.app ───────►│                                  │
         │                                       ├── (2) Sends SAML AuthnRequest ──►│
         │                                       │       (via Browser Redirect)     │
         │                                       │                                  ├── Authenticate User
         │                                       │                                  ├── Signs XML with IdP Cert
         │                                       │◄── (3) POST SAMLResponse ────────┤
         │                                       │       (XML Assertion via Browser)│
         │                                       ├── 1. Defend against XXE & XSW    │
         │                                       ├── 2. Validate XML-DSig Signature │
         │                                       ├── 3. Verify NotBefore / NotOnOrAfter
         │◄── (4) Logged in with Enterprise Role ─┤
CosmosApp Production Milestone

CosmosApp sells enterprise plans to a Fortune 500 client requiring Okta SAML 2.0 integration. CosmosApp acts as the Service Provider (SP). When employees sign in, Okta returns a signed XML assertion. CosmosApp secures its XML parser by completely disabling external DTD entities (preventing XXE) and strictly verifies that the signature covers the root Assertion element (preventing XSW attacks).

Step-by-Step Execution Sequence
01

Step 1: User enters their corporate email (@acme.com) on CosmosApp login page.

02

Step 2: CosmosApp recognizes enterprise domain and redirects to Acme's Okta IdP with a SAML AuthnRequest.

03

Step 3: User completes corporate authentication (MFA / device certificate) at Okta.

04

Step 4: Okta generates a SAML 2.0 XML assertion containing employee attributes (email, department, groups).

05

Step 5: Okta signs the XML assertion with its X.509 private certificate and posts it to CosmosApp's Assertion Consumer Service (ACS).

06

Step 6: CosmosApp parses the XML safely, verifies the cryptographic signature against Okta's public certificate, and provisions the session.

Production Architecture Blueprint
// CosmosApp SAML Parser Hardening Configuration:
import { DOMParser } from '@xmldom/xmldom';

export function parseSamlAssertionSafely(xmlString: string) {
  // CRITICAL SECURITY: Disable external entity resolution (XXE defense)
  const parser = new DOMParser({
    locator: {},
    errorHandler: {
      warning: () => {},
      error: (msg) => { throw new Error(`XML Error: ${msg}`); },
      fatalError: (msg) => { throw new Error(`Fatal XML Error: ${msg}`); },
    },
  });

  const doc = parser.parseFromString(xmlString, 'text/xml');
  return doc;
}
Common Architectural Misconceptions
  • ✕XML signatures verify the entire document by default (XML-DSig signs specific DOM elements by URI reference; if references are unanchored, attackers can inject unsigned elements via XML Signature Wrapping).
  • ✕SAML 2.0 is obsolete and replaced by OIDC (SAML 2.0 remains deeply entrenched in global enterprise and government infrastructure).

Key Architectural Takeaways

  • ✓Enterprise SSO centralizes user provisioning and immediate offboarding across thousands of applications.
  • ✓SAML implementations must explicitly defend against XML External Entity (XXE) and XML Signature Wrapping (XSW).
  • ✓Always enforce strict clock skew checks on SAML NotOnOrAfter validity windows (maximum 2–5 minutes).
Common Architectural Pitfall

Parsing untrusted SAML XML with default XML parsers that allow external DTD entity expansion (XXE vulnerability).

Production Best Practice Fix

Explicitly disable external entities, DTDs, and schema loading in your XML parser configuration.

Interactive Knowledge Check

What is an XML Signature Wrapping (XSW) attack in SAML 2.0?