CVE-2024-52596: Simplesamlphp/xml common SimpleSAMLphp Xml-common XXE Vulnerability Vulnerability

HIGH
Advisory Identifier: GHSA-2x65-fpch-2fcm
CWE-611
Published
Advisory Summary

CVE-2024-52596 is a HIGH simplesamlphp xml-common xxe vulnerability vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Simplesamlphp/xml common libraries in the Packagist ecosystem. The issue involves simplesamlphp xml-common xxe vulnerability. Remediation is available by upgrading affected packages to version 1.20.0.

CVE-2024-52596 at a Glance

CVE Identifier CVE-2024-52596
GHSA Identifier GHSA-2x65-fpch-2fcm
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Simplesamlphp/xml common
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2024-52596

To remediate this vulnerability, upgrade all affected Simplesamlphp/xml common dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

simplesamlphp/xml-common fixed: 1.20.0
Upgrade simplesamlphp/xml-common to 1.20.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for simplesamlphp/xml-common

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-52596, inspect your project dependencies for Simplesamlphp/xml common:

inspect dependencies for simplesamlphp/xml-common

Analyze the terminal output to locate any version of Simplesamlphp/xml common in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.20.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In Simplesamlphp/xml common, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Summary When loading an (untrusted) XML document, for example the SAMLResponse, it's possible to induce an XXE. $options is defined as: https://github.com/simplesamlphp/xml-common/blob/v1.19.0/src/DOMDocumentFactory.php#L39 including the DTDLoad option, which allows an attacker to read file contents from local file system OR internal network. While there is the NONET option, an attacker can simply bypass if by using PHP filters: php://filter/convert.base64-encode/resource=http://URL OR FILE From there an attacker can induce network connections and steal the targeted file OOB (haven't fully tested this). RCE may be possible with the php://expect or php://phar wrappers, but this hasn't been tested. Note: The mitigation here: https://github.com/simplesamlphp/xml-common/blob/v1.19.0/src/DOMDocumentFactory.php#L58 Comes too late, as the XML has already been loaded into a document. Mitigation: Remove the LIBXML_DTDLOAD | LIBXML_DTDATTR options. Additionally, as a defense in depth measure, check if there is the string: <!DOCTYPE inside the XML before parsing it. (This is not a complete fix because someone may be able to exploit some parser differentials, to load a DOCTYPE, maybe through spacing like: <! DOCTYPE)

CVE-2024-52596 Affected Simplesamlphp/xml common Versions

1 component(s)
Fixed Versions:
1.20.0
Product / Package Ecosystem Affected Versions Fixed Version
simplesamlphp/xml-common
Packagist
< 1.20.0
1.20.0

References

Frequently Asked Questions

What is CVE-2024-52596?
CVE-2024-52596 is a security vulnerability in Simplesamlphp/xml common involving SimpleSAMLphp xml-common XXE vulnerability under CWE-611: Improper Restriction of XML External Entity Reference.
Which Simplesamlphp/xml common versions are affected?
Affected versions include releases prior to 1.20.0 across affected packages: simplesamlphp/xml-common.
What version fixes CVE-2024-52596?
Upgrading to 1.20.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is simplesamlphp/xml-common affected?
Yes, simplesamlphp/xml-common is affected in releases prior to 1.20.0. Upgrade your dependency to 1.20.0 or later.
What CWE is associated with CVE-2024-52596?
CVE-2024-52596 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check Packagist dependencies for CVE-2024-52596?
Run the dependency tree command: 'inspect dependencies for simplesamlphp/xml-common'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2x65-fpch-2fcm",
  "modified" : "2024-12-12T22:19:57Z",
  "published" : "2024-12-02T17:14:30Z",
  "aliases" : [ "CVE-2024-52596" ],
  "summary" : "SimpleSAMLphp xml-common XXE vulnerability",
  "details" : "Summary\n\nWhen loading an (untrusted) XML document, for example the SAMLResponse, it's possible to induce an XXE.\n\n$options is defined as: https://github.com/simplesamlphp/xml-common/blob/v1.19.0/src/DOMDocumentFactory.php#L39\nincluding the DTDLoad option, which allows an attacker to read file contents from local file system OR internal network.\n\nWhile there is the NONET option, an attacker can simply bypass if by using PHP filters:\nphp://filter/convert.base64-encode/resource=http://URL OR FILE\n\nFrom there an attacker can induce network connections and steal the targeted file OOB (haven't fully tested this).\n\nRCE may be possible with the php://expect or php://phar wrappers, but this hasn't been tested.\n\nNote:\nThe mitigation here:\nhttps://github.com/simplesamlphp/xml-common/blob/v1.19.0/src/DOMDocumentFactory.php#L58\nComes too late, as the XML has already been loaded into a document.\nMitigation:\n\nRemove the LIBXML_DTDLOAD | LIBXML_DTDATTR options.\nAdditionally, as a defense in depth measure, check if there is the string: <!DOCTYPE inside the XML before parsing it. (This is not a complete fix because someone may be able to exploit some parser differentials, to load a DOCTYPE, maybe through spacing like: <! DOCTYPE)",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:H/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "simplesamlphp/xml-common"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.20.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 1.20"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/simplesamlphp/xml-common/security/advisories/GHSA-2x65-fpch-2fcm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52596"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/simplesamlphp/xml-common/commit/fa4ade391c3194466acf5fbfd5d2ecdbf5e831f5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/simplesamlphp/xml-common"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2024/12/msg00001.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-02T17:14:30Z",
    "nvd_published_at" : "2024-12-02T17:15:12Z"
  }
}