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.
Step 1: User enters their corporate email (@acme.com) on CosmosApp login page.
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).
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).
[ 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 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 1: User enters their corporate email (@acme.com) on CosmosApp login page.
Step 2: CosmosApp recognizes enterprise domain and redirects to Acme's Okta IdP with a SAML AuthnRequest.
Step 3: User completes corporate authentication (MFA / device certificate) at Okta.
Step 4: Okta generates a SAML 2.0 XML assertion containing employee attributes (email, department, groups).
Step 5: Okta signs the XML assertion with its X.509 private certificate and posts it to CosmosApp's Assertion Consumer Service (ACS).
Step 6: CosmosApp parses the XML safely, verifies the cryptographic signature against Okta's public certificate, and provisions the session.
// 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;
}- ✕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).
Parsing untrusted SAML XML with default XML parsers that allow external DTD entity expansion (XXE vulnerability).
Explicitly disable external entities, DTDs, and schema loading in your XML parser configuration.
What is an XML Signature Wrapping (XSW) attack in SAML 2.0?