CVE-2024-28757:
libexpat through 2.6.1 allows an XML Entity Expansion attack when there is isolated use of...
7.5
Basic Information
Technical Details
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability (CVE-2024-28757) in libexpat allows an XML Entity Expansion (Billion Laughs) attack when an external parser, created using XML_ExternalEntityParserCreate
, is used in an isolated manner (e.g., to parse only a DTD without a main document, leading to zero direct input bytes being accounted initially).
The analysis of the provided commit information (primarily 1d50b80cf31de87750103656f6eb693746854aa8
which contains the fix, and 072eca0b72373da103ce15f8f62d1d7b52695454
which adds a test case) reveals the following:
-
accountingGetCurrentAmplification
(inexpat/lib/xmlparse.c
): This function contained the direct logical flaw. The commit1d50b80cf31de87750103656f6eb693746854aa8
patches this function. In the vulnerable version, ifrootParser->m_accounting.countBytesDirect
was zero (which happens with isolated external parsers), the function would return anamplificationFactor
of1.0f
. This incorrectly indicated no amplification, thereby bypassing the billion laughs attack detection mechanism. The patch modifies the logic to use a minimum assumed direct input size (lenOfShortestInclude
) when actual direct input is zero, ensuring a meaningful amplification factor is calculated. -
XML_Parse
(and its internal variants like_XML_Parse_SINGLE_BYTES
, inexpat/lib/xmlparse.c
): This is the function (or family of functions) that processes the XML input. The commit message for the fix explicitly describes a scenario whereXML_Parse
is called on an external parser created byXML_ExternalEntityParserCreate
, leading to the vulnerability. The new test case also uses_XML_Parse_SINGLE_BYTES
(an internal helper forXML_Parse
) on such a parser. WhenXML_Parse
processes input using an isolated external parser, it relies onaccountingGetCurrentAmplification
to check for excessive entity expansion. Due to the flaw inaccountingGetCurrentAmplification
, this check would fail to detect the attack. -
XML_ExternalEntityParserCreate
(inexpat/lib/xmlparse.c
): This function is explicitly mentioned in the CVE description and the commit message as the method to create the parser that, when used in an isolated way, leads to the vulnerable condition. It sets up the specific parsing context whereaccountingGetCurrentAmplification
would previously fail.
Therefore, XML_ExternalEntityParserCreate
is used to set up the vulnerable parsing context. XML_Parse
(or its variants) is the function that processes the malicious input within this context. accountingGetCurrentAmplification
is the function that contained the flawed logic, failing to detect the attack when called during the XML_Parse
operation under these specific conditions. All three functions would appear in a runtime profile when the vulnerability is triggered or exploited, with accountingGetCurrentAmplification
being the site of the direct logic error and XML_Parse
being the function that drives the parsing process and calls the flawed check, after the parser is set up by XML_ExternalEntityParserCreate
.