CVE-2024-52806: Simplesamlphp/saml2 legacy SimpleSAMLphp SAML2 Has An XXE Vulnerability

MODERATE
Advisory Identifier: GHSA-pxm4-r5ph-q2m2
CVSS 8.3
CWE-611
Published
Advisory Summary

CVE-2024-52806 is a MODERATE (CVSS 8.3) simplesamlphp saml2 has an xxe vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Simplesamlphp/saml2 legacy libraries in the Packagist ecosystem. The issue involves simplesamlphp saml2 has an xxe in parsing saml messages. Remediation is available by upgrading affected packages to version 4.6.14.

CVE-2024-52806 at a Glance

CVE Identifier CVE-2024-52806
GHSA Identifier GHSA-pxm4-r5ph-q2m2
Severity MODERATE
CVSS v3.1 Base Score 8.3
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Simplesamlphp/saml2 legacy
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-52806

To remediate this vulnerability, upgrade all affected Simplesamlphp/saml2 legacy 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/saml2-legacy fixed: 4.6.14
Upgrade simplesamlphp/saml2-legacy to 4.6.14
simplesamlphp/saml2 fixed: 4.6.14
Upgrade simplesamlphp/saml2 to 4.6.14
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/saml2-legacy

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-52806, inspect your project dependencies for Simplesamlphp/saml2 legacy:

inspect dependencies for simplesamlphp/saml2-legacy

Analyze the terminal output to locate any version of Simplesamlphp/saml2 legacy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.6.14), 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/saml2 legacy, 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/saml2/blob/717c0adc4877ebd58428637e5626345e59fa0109/src/SAML2/DOMDocumentFactory.php#L41 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/saml2/blob/717c0adc4877ebd58428637e5626345e59fa0109/src/SAML2/DOMDocumentFactory.php#L63-L69 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-52806 Affected Simplesamlphp/saml2 legacy Versions

2 component(s)
Fixed Versions:
4.6.14
Product / Package Ecosystem Affected Versions Fixed Version
simplesamlphp/saml2-legacy
Packagist
< 4.6.14
4.6.14
simplesamlphp/saml2
Packagist
< 4.6.14
4.6.14

References

Frequently Asked Questions

What is CVE-2024-52806?
CVE-2024-52806 is a security vulnerability in Simplesamlphp/saml2 legacy involving SimpleSAMLphp SAML2 has an XXE in parsing SAML messages under CWE-611: Improper Restriction of XML External Entity Reference.
Which Simplesamlphp/saml2 legacy versions are affected?
Affected versions include releases prior to 4.6.14 across affected packages: simplesamlphp/saml2-legacy, simplesamlphp/saml2.
What version fixes CVE-2024-52806?
Upgrading to 4.6.14 (or the latest patched release for your respective branch) resolves the vulnerability.
Is simplesamlphp/saml2-legacy affected?
Yes, simplesamlphp/saml2-legacy is affected in releases prior to 4.6.14. Upgrade your dependency to 4.6.14 or later.
Is simplesamlphp/saml2 affected?
Yes, simplesamlphp/saml2 is affected in releases prior to 4.6.14. Upgrade your dependency to 4.6.14 or later.
What is the CVSS score of CVE-2024-52806?
CVE-2024-52806 has a CVSS v3.1 base score of 8.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L.
What CWE is associated with CVE-2024-52806?
CVE-2024-52806 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-52806?
Run the dependency tree command: 'inspect dependencies for simplesamlphp/saml2-legacy'. 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-pxm4-r5ph-q2m2",
  "modified" : "2024-12-13T20:39:57Z",
  "published" : "2024-12-02T17:25:43Z",
  "aliases" : [ "CVE-2024-52806" ],
  "summary" : "SimpleSAMLphp SAML2 has an XXE in parsing SAML messages",
  "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/saml2/blob/717c0adc4877ebd58428637e5626345e59fa0109/src/SAML2/DOMDocumentFactory.php#L41\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/saml2/blob/717c0adc4877ebd58428637e5626345e59fa0109/src/SAML2/DOMDocumentFactory.php#L63-L69\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_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "simplesamlphp/saml2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.6.14"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "simplesamlphp/saml2-legacy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.6.14"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/simplesamlphp/saml2/security/advisories/GHSA-pxm4-r5ph-q2m2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52806"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/simplesamlphp/saml2/commit/5fd4ce4596656fb0c1278f15b8305825412e89f7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/simplesamlphp/saml2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-02T17:25:43Z",
    "nvd_published_at" : "2024-12-02T17:15:12Z"
  }
}