Miggo Logo

CVE-2024-28757:
libexpat through 2.6.1 allows an XML Entity Expansion attack when there is isolated use of...

7.5

CVSS Score
3.1

Basic Information

EPSS Score
0.63806%
Published
3/10/2024
Updated
3/28/2025
KEV Status
No
Technology
-

Technical Details

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

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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:

  1. accountingGetCurrentAmplification (in expat/lib/xmlparse.c): This function contained the direct logical flaw. The commit 1d50b80cf31de87750103656f6eb693746854aa8 patches this function. In the vulnerable version, if rootParser->m_accounting.countBytesDirect was zero (which happens with isolated external parsers), the function would return an amplificationFactor of 1.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.

  2. XML_Parse (and its internal variants like _XML_Parse_SINGLE_BYTES, in expat/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 where XML_Parse is called on an external parser created by XML_ExternalEntityParserCreate, leading to the vulnerability. The new test case also uses _XML_Parse_SINGLE_BYTES (an internal helper for XML_Parse) on such a parser. When XML_Parse processes input using an isolated external parser, it relies on accountingGetCurrentAmplification to check for excessive entity expansion. Due to the flaw in accountingGetCurrentAmplification, this check would fail to detect the attack.

  3. XML_ExternalEntityParserCreate (in expat/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 where accountingGetCurrentAmplification 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.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

li**xp*t t*rou** *.*.* *llows *n XML *ntity *xp*nsion *tt**k w**n t**r* is isol*t** us* o* *xt*rn*l p*rs*rs (*r**t** vi* XML_*xt*rn*l*ntityP*rs*r*r**t*).

Reasoning

T** vuln*r**ility (*V*-****-*****) in li**xp*t *llows *n XML *ntity *xp*nsion (*illion L*u**s) *tt**k w**n *n *xt*rn*l p*rs*r, *r**t** usin* `XML_*xt*rn*l*ntityP*rs*r*r**t*`, is us** in *n isol*t** m*nn*r (*.*., to p*rs* only * *T* wit*out * m*in *o*