CVE-2017-11427
Manipulation of SAML data without invalidating the cryptographic signature in OneLogin PythonSAML (2.3.0 and earlier)
- CVSS 9.8
- CWE-287
- Cryptographic
- Remote
OneLogin PythonSAML 2.3.0 and earlier may incorrectly utilize the results of XML DOM traversal and canonicalization APIs in such a way that an attacker may be able to manipulate the SAML data without invalidating the cryptographic signature, allowing the attack to potentially bypass authentication to SAML service providers.
- CWE
- CWE-287
- CVSS base score
- 9.8
- Published
- 2019-04-17
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Cryptographic
- Subcategory
- Cryptographic Implementation Error
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Fixed by upgrading
- Yes
Solution
Update to OneLogin PythonSAML version 2.3.1 or higher
Vulnerable code sample
import xml.etree.ElementTree as ET
import xmlsec
def validate_saml_response(saml_response):
"""Vulnerable function that demonstrates the security issue."""
# VULNERABLE: This code is susceptible to path traversal
root = ET.fromstring(saml_response)
xml_data = ET.tostring(root, method='xml', encoding='utf-8')
key = xmlsec.Key.from_file('path/to/public_key.pem', xmlsec.KeyFormat.PEM)
signature_context = xmlsec.SignatureContext(key)
signature_template = xmlsec.template.create(root, xmlsec.TransformExclC14N, xmlsec.TransformSignature)
signature_context.verify(signature_template)
return True
saml_response = '''<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">...</samlp:Response>'''
if validate_saml_response(saml_response):
print("SAML response is valid and signature is verified.")
else:
print("Invalid SAML response or signature.")Patched code sample
import defusedxml.ElementTree as ET
import xmlsec
def validate_saml_response(saml_response):
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents path traversal
root = ET.fromstring(saml_response)
signature_node = xmlsec.tree.find_node(root, xmlsec.Node.SIGNATURE)
if signature_node is None:
raise ValueError("No Signature node found in SAML response.")
key = xmlsec.Key.from_file('path/to/public_key.pem', xmlsec.KeyFormat.PEM)
ctx = xmlsec.SignatureContext()
ctx.key = key
ctx.verify(signature_node)
return True
saml_response = '''<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">...</samlp:Response>'''
try:
if validate_saml_response(saml_response):
print("SAML response is valid and signature is verified.")
except Exception as e:
print(f"Validation failed: {e}")Cite this entry
@misc{vaitp:cve201711427,
title = {{Manipulation of SAML data without invalidating the cryptographic signature in OneLogin PythonSAML (2.3.0 and earlier)}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2019},
note = {VAITP Python Vulnerability Dataset, entry CVE-2017-11427},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2017-11427/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
