SAML Consumer Service External Dereference SSRF
Description
The application's SAML Consumer Service improperly processes SAML assertions containing external references in KeyInfo elements, such as RetrievalMethod. This allows unauthenticated attackers to craft malicious SAML responses that force the server to retrieve content from attacker-specified URLs or local file paths. The vulnerability enables Server-Side Request Forgery (SSRF) attacks by exploiting the XML signature validation process.
Remediation
Disable external entity resolution and URL dereferencing in the SAML XML parser configuration. Implement the following security controls:
1. Configure XML Parser Security Settings:
Disable external entity processing and URL dereferencing in your SAML library. For example, when using common SAML libraries:
// Java (using OpenSAML)
BasicParserPool parserPool = new BasicParserPool();
parserPool.setIgnoreComments(true);
Map<String, Boolean> features = new HashMap<>();
features.put("http://xml.org/sax/features/external-general-entities", false);
features.put("http://xml.org/sax/features/external-parameter-entities", false);
features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
parserPool.setBuilderFeatures(features);# Python (using python3-saml) from onelogin.saml2.settings import OneLogin_Saml2_Settings settings = OneLogin_Saml2_Settings(settings_dict) # Ensure XML parser forbids external entities settings.set_strict(True) # Use defusedxml library for additional protection import defusedxml.ElementTree as ET
2. Restrict RetrievalMethod Processing:
Configure your SAML implementation to reject or ignore RetrievalMethod elements in KeyInfo sections of SAML assertions.
3. Implement Allow-listing:
If external references are absolutely required, implement strict allow-listing of permitted URLs and protocols (e.g., only HTTPS to specific trusted domains).
4. Network Segmentation:
Apply network-level controls to prevent the application server from accessing internal resources or sensitive metadata endpoints (e.g., 169.254.169.254 for cloud metadata).