See how expat compares to other vendors in security performance
libexpat through 2.11.0 contains a denial of service vulnerability in ...
libexpat 2.6.0 through 2.11.0 built with XMLGE=0 and XMLUNICODE cont ...
Sebastian Pipping wrote:
The next part of that same paragraph says: The new default behavior can be disabled using -fno-pointer-tbaa. Clang has performed optimisations of this type for a long time, it just does so more aggressively now. If you want to gate the behaviour on >= 20, you should use -fno-pointer-tbaa. This CE link shows specifically what kind of optimization Clang 20 adds to its existing type-based alias analysis:
https://gcc.godbolt.org/z/TMTxhP454
In this example, Clang 20 assumes that p, at the return, cannot have changed since assigned, because only an int was written to memory since. The full reasoning is that either p points to a variable of type long, in which case it's illegal to write to it through the lvalue q, or it points to dynamically allocated memory, in which case it's illegal to read p from there at the return if the write to q touched the same bytes, because in this latter case, the effective type has been changed to int when q was written.
I think that current expat contains both the "int is not aliased with long" kind of violation (at least in some configuration) and also the "int is not aliased with long" kind. Since each violation is a separate opportunity for the compiler to generate code that does not respect the intentions of the programmer, it is even more urgent to use -fno-strict-aliasing when compiling expat (and any other C code) with Clang 20+ than with Clang 19-.
Pascal
Demi Marie Obenour <demiobenour () gmail com> writes: On 11/23/26 6:35 PM, Sam James wrote: Sebastian Pipping <sebastian () pipping org> writes: [...] #1495 Restore and document -fno-strict-aliasing for security with both GCC and Clang >=20. Why Clang >= 20? Clang has supported this flag since forever. libexpat continues to be -Wstrict-aliasing=3 clean and to reject violations via CI but there are multiple known strict aliasing violations within libexpat that despite -Wstrict-aliasing=3 are not detected by GCC and which Note that -Wstrict-aliasing=1 is the most aggressive level [0]. Anyway, in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it has some issues still. Someone has proposed it for GCC now too.
[0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing are hard to impossible to resolve without a mess. These and Why are they so hard to resolve here exactly? In general, just memcpy and move on. In protocol handling code, it requires code like this:
memcpy(&out, ((unsigned char )ptr + structsize index + offsetof(typename, field)), sizeof(out));
instead of:
out = ((typename )ptr)->fam[index].field;
Or it might require:
struct protocolentry { uint32t a, b; };
struct protocolentrymirror;
uint32t protocolentrygeta(const struct protocolentrymirror m) { uint32t v; staticassert(sizeof(v) == sizeof(m->a), "whoops"); memcpy(&v, (const unsigned char ) offsetof(struct protocolentry, a), sizeof(v)); return endianfixup(v); } I think this assumes a specific use model which plenty of cases I've fixed don't. which is unreadable (and unmaintainable) unless autogenerated.
It just winds up being a mess, and for existing code it means a lot of changes all over the place. Building with -fno-strict-aliasing is far, far simpler. I'm aware of your views on the subject, I was wondering about.. I don't know what expat uses type punning for, but I suspect that it, too, would need a fairly large change. .. I was interested in the specifics here for Expat.
sam
On 11/23/26 6:35 PM, Sam James wrote: Sebastian Pipping <sebastian () pipping org> writes: [...] #1495 Restore and document -fno-strict-aliasing for security with both GCC and Clang >=20. Why Clang >= 20? Clang has supported this flag since forever. libexpat continues to be -Wstrict-aliasing=3 clean and to reject violations via CI but there are multiple known strict aliasing violations within libexpat that despite -Wstrict-aliasing=3 are not detected by GCC and which Note that -Wstrict-aliasing=1 is the most aggressive level [0]. Anyway, in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it has some issues still. Someone has proposed it for GCC now too.
[0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing are hard to impossible to resolve without a mess. These and Why are they so hard to resolve here exactly? In general, just memcpy and move on. In protocol handling code, it requires code like this:
memcpy(&out, ((unsigned char )ptr + structsize index + offsetof(typename, field)), sizeof(out));
instead of:
out = ((typename )ptr)->fam[index].field;
Or it might require:
struct protocolentry { uint32t a, b; };
struct protocolentrymirror;
uint32t protocolentrygeta(const struct protocolentrymirror m) { uint32t v; staticassert(sizeof(v) == sizeof(m->a), "whoops"); memcpy(&v, (const unsigned char ) offsetof(struct protocolentry, a), sizeof(v)); return endianfixup(v); }
which is unreadable (and unmaintainable) unless autogenerated.
It just winds up being a mess, and for existing code it means a lot of changes all over the place. Building with -fno-strict-aliasing is far, far simpler.
I don't know what expat uses type punning for, but I suspect that it, too, would need a fairly large change. -- Sincerely, Demi Marie Obenour (she/her/hers)
Sebastian Pipping <sebastian () pipping org> writes: Hello Sam,
On 11/24/26 00:35, Sam James wrote: Why Clang >= 20? Clang has supported this flag since forever. at https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html it reads:
Clang now emits distinct type-based alias analysis tags for incompatible pointers by default, enabling more powerful alias analysis when accessing pointer types. This change may silently change code behavior for code containing strict-aliasing violations. The next part of that same paragraph says: The new default behavior can be disabled using -fno-pointer-tbaa.
Clang has performed optimisations of this type for a long time, it just does so more aggressively now.
If you want to gate the behaviour on >= 20, you should use -fno-pointer-tbaa.
But if you're not confident the codebase is TBAA-safe, you should just use -fno-strict-aliasing unconditionally where the compiler supports it.
Note that -Wstrict-aliasing=1 is the most aggressive level [0]. It also says "least accurate". Yes, but the way you mentioned it made me think "it's [even] -Wstrict-alisaing=3" clean, as if it's the toughest level. Of course you get false positives if you crank up the sensitivity.
Anyway, in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it has some issues still. Someone has proposed it for GCC now too. [0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing I'm in the process of adding Clang's TypeSanitizer to CI. Excellent. Best
Sebastian sam
Hello Sam,
On 11/24/26 00:35, Sam James wrote: Why Clang >= 20? Clang has supported this flag since forever. at https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html it reads:
Clang now emits distinct type-based alias analysis tags for incompatible pointers by default, enabling more powerful alias analysis when accessing pointer types. This change may silently change code behavior for code containing strict-aliasing violations. Note that -Wstrict-aliasing=1 is the most aggressive level [0]. It also says "least accurate". Anyway, in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it has some issues still. Someone has proposed it for GCC now too.
[0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing I'm in the process of adding Clang's TypeSanitizer to CI.
Best
Sebastian
Sebastian Pipping <sebastian () pipping org> writes: [...] #1495 Restore and document -fno-strict-aliasing for security with both GCC and Clang >=20. Why Clang >= 20? Clang has supported this flag since forever. libexpat continues to be -Wstrict-aliasing=3 clean and to reject violations via CI but there are multiple known strict aliasing violations within libexpat that despite -Wstrict-aliasing=3 are not detected by GCC and which Note that -Wstrict-aliasing=1 is the most aggressive level [0]. Anyway, in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it has some issues still. Someone has proposed it for GCC now too.
[0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing are hard to impossible to resolve without a mess. These and Why are they so hard to resolve here exactly? In general, just memcpy and move on. potentially other cases run the risk of miscompilation(!) with -O2/-O3/Os without explicit -fno-strict-aliasing. Hence -fno-strict-aliasing is brought back to both build systems and is recommended to everyone embedding libexpat in particular (but not only) to avoid surprises from potential miscompilation. If curious, for the 2016 article by John Regehr that motivated this move please see: https://blog.regehr.org/archives/1307 .
[...] sam
Hello oss-security,
just a quick note that libexpat 2.11.0 (or "Expat 2.11.0") released today is fixing three vulnerabilities:
- CVE-2026-124317 - CVE-2026-128241 - CVE-2026-134703
The related part of the change log is this:
#1492 CVE-2026-124317 -- Fix overread in unknown encoding decoder It needs use of XMLSetUnknownEncodingHandler to be affected. #1502 CVE-2026-128241 -- xmlwf: Plug symlink attacks with the -d <directory> mode. The xmlwf CLI of libexpat was vulnerable to symlink attacks in the -d <directory> mode with a target directory writable by other users, e.g. /tmp. The attack allowed truncation or overwriting the symlink target file depending on the well-formedness of the XML being parsed. #1519 CVE-2026-134703 -- Malformed UTF-16 content ending in isolated high surrogates could be passed to character data and default handlers depending on their location in the parsed document and could cause arbitrary damage depending on the handler code in the application using libexpat. Applications can expect text free from isolated surrogates from Expat. Similar to past CVE-2026-93990 and CVE-2022-25235. #1495 Restore and document -fno-strict-aliasing for security with both GCC and Clang >=20. libexpat continues to be -Wstrict-aliasing=3 clean and to reject violations via CI but there are multiple known strict aliasing violations within libexpat that despite -Wstrict-aliasing=3 are not detected by GCC and which are hard to impossible to resolve without a mess. These and potentially other cases run the risk of miscompilation(!) with -O2/-O3/Os without explicit -fno-strict-aliasing. Hence -fno-strict-aliasing is brought back to both build systems and is recommended to everyone embedding libexpat in particular (but not only) to avoid surprises from potential miscompilation. If curious, for the 2016 article by John Regehr that motivated this move please see: https://blog.regehr.org/archives/1307 .
Some key links are:
- The blog post about it https://blog.hartwork.org/posts/expat-2-11-0-released/
- The full change log of release 2.11.0 https://github.com/libexpat/libexpat/blob/R2110/expat/Changes
- The fixing pull requests - https://github.com/libexpat/libexpat/pull/1492 - https://github.com/libexpat/libexpat/pull/1502 - https://github.com/libexpat/libexpat/pull/1519 - https://github.com/libexpat/libexpat/pull/1495
- The NVD CVE metadata - https://nvd.nist.gov/vuln/detail/cve-2026-124317 - https://nvd.nist.gov/vuln/detail/cve-2026-128241 - https://nvd.nist.gov/vuln/detail/cve-2026-134703
Best
Sebastian
libexpat through 2.10.0 contains an improper Unicode handling vulnerability in DEFINEUTF16TOUTF16 conversion functions in xmltok.c that can split valid surrogate pairs when output space is limited. In XMLUNICODE builds parsing non-native byte order UTF-16 input, attackers can supply crafted documents that deliver lone high surrogates to character data and default handlers.
libexpat xmlwf through 2.10.0 Symlink Following via -d Output Directory
Hello oss-security,
just a quick note that libexpat 2.10.0 (or "Expat 2.10.0") released today is fixing four vulnerabilities:
- CVE-2026-113351 - CVE-2026-115506 - CVE-2026-117610 - CVE-2026-118370
The related part of the change log is this:
#1431 CVE-2026-113351 -- Fix denial of service with use of XMLParserReset #1433 #1436 .. #1438 #1439 .. #1442 CVE-2026-115506 -- Detect billion laughs attacks quicker and more of its variations. Related payload fuzzer at: https://github.com/hannob/lololol Please note that a layer of compression around XML can significantly reduce the minimum attack payload size. In case of backporting, please note pull request #1439 in particular. #1444 CVE-2026-117610 -- Fix initial non-final empty subparser parse calls. Was segfaulting previously. #1450 CVE-2026-118370 -- Protect attIndex and nPrefixes in function storeAtts from signed integer overflow
Some key links are:
- The blog post about it https://blog.hartwork.org/posts/expat-2-10-0-released/
- The full change log of release 2.10.0 https://github.com/libexpat/libexpat/blob/R2100/expat/Changes
- The fixing pull requests - https://github.com/libexpat/libexpat/pull/1431 - https://github.com/libexpat/libexpat/pull/1433 - https://github.com/libexpat/libexpat/pull/1439 - https://github.com/libexpat/libexpat/pull/1444 - https://github.com/libexpat/libexpat/pull/1450
- The NVD CVE metadata - https://nvd.nist.gov/vuln/detail/cve-2026-113351 - https://nvd.nist.gov/vuln/detail/cve-2026-115506 - https://nvd.nist.gov/vuln/detail/cve-2026-117610 - https://nvd.nist.gov/vuln/detail/cve-2026-118370
Best
Sebastian
libexpat through 2.9.0 contains a NULL pointer dereference vulnerability in externalEntityInitProcessor2() in lib/xmlparse.c that mishandles the XMLTOKNONE token from empty input. Attackers who control stream chunking can force an empty non-final first parse on an external entity subparser, causing a later parse to crash the application.
libexpat through 2.9.0 contains a signed integer overflow vulnerability in storeAtts() in lib/xmlparse.c that allows attackers to trigger out-of-bounds writes via oversized attribute counts. Attackers can supply a multi-gigabyte document with a start tag carrying over 2^30 attributes to overflow attIndex and nPrefixes, crashing applications or corrupting heap memory.
libexpat through 2.9.0 contains a signed integer overflow vulnerability in storeAtts() in lib/xmlparse.c that allows attackers to trigger out-of-bounds writes via oversized attribute counts. Attackers can supply a multi-gigabyte document with a start tag carrying over 2^30 attributes to overflow attIndex and nPrefixes, crashing applications or corrupting heap memory.
libexpat through 2.9.0 contains a NULL pointer dereference vulnerability in externalEntityInitProcessor2() in lib/xmlparse.c that mishandles the XMLTOKNONE token from empty input. Attackers who control stream chunking can force an empty non-final first parse on an external entity subparser, causing a later parse to crash the application.
libexpat through 2.9.0 contains a denial of service vulnerability because billion laughs protection in accountingDiffTolerated() in xmlparse.c detects entity amplification too late. Attackers can supply a moderately sized XML document with a large DTD and nested entity expansions to consume tens of seconds of CPU per parse.
libexpat through 2.9.0 contains a denial of service vulnerability because billion laughs protection in accountingDiffTolerated() in xmlparse.c detects entity amplification too late. Attackers can supply a moderately sized XML document with a large DTD and nested entity expansions to consume tens of seconds of CPU per parse.
libexpat 2.7.2 through 2.9.0 contains a denial of service vulnerability because XMLParserReset zeroes the direct byte count but never offsets tracked heap allocations. Attackers can submit a large XML document so later documents on the same reset parser fail with XMLERRORNOMEMORY until it is recreated.
libexpat 2.7.2 through 2.9.0 contains a denial of service vulnerability because XMLParserReset zeroes the direct byte count but never offsets tracked heap allocations. Attackers can submit a large XML document so later documents on the same reset parser fail with XMLERRORNOMEMORY until it is recreated.
libexpat before commit 13c5f63 contains a heap buffer over-read vulnerability in xmlparse.c. XMLParseBuffer advances the parse buffer end with parser->mbufferEnd += len using a caller-supplied length that is not validated against the allocated buffer size, so repeated XMLParseBuffer calls move mbufferEnd past the end of the heap allocation and subsequent parsing reads out of bounds. Reaching this path requires a parse buffer to already be present; otherwise XMLParseBuffer returns XMLERRORNOBUFFER. A buffer is present after a prior call to XMLGetBuffer, either directly (the common case) or indirectly through a prior XMLParse call that allocates the buffer internally. The over-read discloses adjacent heap memory to the calling application, recovering heap pointers, libc function pointers, and code pointers sufficient to defeat ASLR and build further exploitation primitives.
libexpat before commit 13c5f63 contains a heap buffer over-read vulnerability in xmlparse.c. XMLParseBuffer advances the parse buffer end with parser->mbufferEnd += len using a caller-supplied length that is not validated against the allocated buffer size, so repeated XMLParseBuffer calls move mbufferEnd past the end of the heap allocation and subsequent parsing reads out of bounds. Reaching this path requires a parse buffer to already be present; otherwise XMLParseBuffer returns XMLERRORNOBUFFER. A buffer is present after a prior call to XMLGetBuffer, either directly (the common case) or indirectly through a prior XMLParse call that allocates the buffer internally. The over-read discloses adjacent heap memory to the calling application, recovering heap pointers, libc function pointers, and code pointers sufficient to defeat ASLR and build further exploitation primitives.
Hello oss-security,
just a quick note that libexpat 2.9.0 (or "Expat 2.9.0") released today is fixing two vulnerabilities:
- CVE-2026-77214 - CVE-2026-102633
The related part of the change log is this:
#1392 CVE-2026-102633 -- Integer overflow in function expatrealloc on 32bit platforms #1393 CVE-2026-77214 -- Validate parameter len against available buffer capacity in XMLParseBuffer
Some key links are:
- The blog post about it https://blog.hartwork.org/posts/expat-2-9-0-released/
- The full change log of release 2.9.0 https://github.com/libexpat/libexpat/blob/R290/expat/Changes
- The fixing pull requests - https://github.com/libexpat/libexpat/pull/1392 - https://github.com/libexpat/libexpat/pull/1393
- The NVD CVE metadata - https://nvd.nist.gov/vuln/detail/cve-2026-77214 - https://nvd.nist.gov/vuln/detail/cve-2026-102633
Best
Sebastian
libexpat versions 2.7.2 through 2.8.5 contain an integer overflow vulnerability in expatrealloc() function on 32-bit platforms when computing allocation sizes. Attackers supplying malicious XML to applications parsing with vulnerable libexpat can cause heap buffer overflow, memory corruption, or denial of service.
libexpat 2.7.2 through 2.8.5 Integer Overflow in expatrealloc
It was discovered that Expat did not correctly handle certain integer arithmetic. An attacker could possibly use this issue to cause a denial of service. (CVE-2026-56406, CVE-2026-56407, CVE-2026-56409, CVE-2026-56410, CVE-2026-56411) It was discovered that Expat did not correctly track handler call depth. An attacker could possibly use this issue to cause Expat to crash or execute arbitrary code. (CVE-2026-56131) It was discovered that Expat did not correctly handle certain memory operations. An attacker could possibly use this issue to cause Expat to crash or execute arbitrary code. (CVE-2026-56132) It was discovered that Expat did not correctly handle certain Unicode characters. An attacker could possibly use this issue to cause Expat to use excessive resources, leading to a denial of service. (CVE-2026-72522) It was discovered that Expat did not correctly process certain XML attributes. A remote attacker could possibly use this issue to cause Expat to use excessive resources, leading to a denial of service. (CVE-2026-66046) It was discovered that Expat did not correctly handle certain external entities. An attacker could possibly use this issue to cause Expat to crash or execute arbitrary code. (CVE-2026-76641) It was discovered that Expat did not correctly track handler call depth with custom encodings. An attacker could possibly use this issue to cause Expat to crash or execute arbitrary code. (CVE-2026-76957)
Expat through 2.8.4 fails to validate low surrogates following high surrogates in UTF-16 input, allowing malformed UTF-16 sequences to be accepted. Attackers can craft UTF-16 encoded XML with lone high surrogates that consume following code units, hiding markup characters from the parser and enabling XML injection attacks.
Hello oss-security,
just a quick note that libexpat 2.8.5 (or "Expat 2.8.5") released today is fixing CVE-2026-93990:
Reject high surrogates not followed by a low surrogate during UTF-16 decoding; previously, malformed UTF-16 could be smuggled into the application using Expat and could cause arbitrary damage there, depending on how malformed UTF-16 was handled inside the application; validation was not their job but Expat's. This is similar to past vulnerability CVE-2022-25235. Upstream CVSS 3.1 vector: AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (CVSS score: 9.8)
Some key links are:
- The blog post about it https://blog.hartwork.org/posts/expat-2-8-5-released/
- The change log of release 2.8.5 https://github.com/libexpat/libexpat/blob/R285/expat/Changes
- The fixing pull request https://github.com/libexpat/libexpat/pull/1282
- The NVD CVE metadata https://nvd.nist.gov/vuln/detail/CVE-2026-93990 (with a different CVSS vector)
Best
Sebastian
Expat before 2.8.5 fails to validate that a high surrogate in UTF-16 input is followed by a low surrogate, allowing malformed UTF-16 sequences to be accepted. Attackers can supply UTF-16 encoded XML containing lone high surrogates that consume the following code unit, causing Expat to pass unpaired surrogates to applications built with XMLUNICODE and to silently replace input characters in other builds.
Expat through 2.8.3 contains an out-of-bounds read vulnerability that allows attackers to trigger memory corruption by processing XML with external entity parsers created via XMLExternalEntityParserCreate. A struct size mismatch between ELEMENTTYPE members causes storeAtts to read the attIndex member past allocated memory boundaries, resulting in failure to normalize whitespace in non-CDATA attributes or a wild pointer dereference causing a segfault. This vulnerability was introduced by the fix for CVE-2026-66046.