Engineer working on a laptop connected to a device test rig, surrounded by wiring harnesses and test hardware

Firmware vulnerabilities & fixes

zlib, Expat and libxml2 vulnerabilities in embedded firmware: finding, triaging and patching them

Last updated:

zlib, Expat and libxml2 vulnerabilities in embedded firmware are found by locating every copy of each library in the image, shared or statically linked, reading its version, and checking it against each project's own changelog: zlib 1.4 (4 November 2026), Expat 2.11.0 (23 November 2026) and libxml2 2.15.4 (1 September 2026) all list security fixes.

Triage then asks whether the vulnerable function is reachable from untrusted input on that device, and the fix is an upgrade, a backported patch, or a parser setting that closes the risky path.

Key takeaways

  • Because they sit underneath other software.
  • Start from the unpacked root file system and check three kinds of evidence for each library: the file name, the version string inside the binary, and the build metadata.
  • A small XML document that nests entity references can expand into gigabytes of output, the "billion laughs" attack.
  • The CVEs above, with the first fixed upstream release and the condition that decides exposure.

Why do zlib, Expat and libxml2 show up in so many firmware scans?

Because they sit underneath other software. zlib does the compression for gzip, PNG, HTTP content encoding, SSH and firmware update archives. Expat and libxml2 are the two common C XML parsers, used by UPnP and SOAP device-management stacks, configuration readers and scripting runtimes. zlib is also not the only decompressor on the HTTP path, and the others can have inflate-style bugs too: Google's Brotli decoder in 1.0.3 through 1.2.0 has an out-of-bounds write reachable through a crafted Brotli-compressed stream (CVE-2026-111497, fixed in Brotli 1.2.1, 1.1.1 and 1.0.10), and it is in CISA's KEV catalog as of 2026-11-29, added on 27 October 2026.

They also turn up more than once in one image. Besides the shared libz.so, libexpat.so and libxml2.so, copies get compiled into individual binaries. CPython carries its own Expat in Modules/expat, whose expat.h declared version 2.11.0 on 2026-12-01, so a device with a bundled Python interpreter can have an Expat the package manager does not list.

The bootloader and kernel are a separate case. U-Boot's include/u-boot/zlib.h still carries the header text "version 1.2.3, July 18th, 2005", and the Linux kernel's lib/zlib_inflate/inflate.c says it is "Based on zlib 1.2.3 but modified for the Linux Kernel". Both are maintained forks, so upstream zlib version ranges do not map onto them. Our U-Boot bootloader security and Linux kernel CVEs on embedded devices guides cover those two components.

How do you find which versions a firmware image ships?

Start from the unpacked root file system and check three kinds of evidence for each library: the file name, the version string inside the binary, and the build metadata.

Library Shared library name Version evidence inside the binary Static or bundled copies
zlib libz.so.1 " inflate 1.4 Copyright 1995-2026 Mark Adler " and the matching deflate string Same strings appear in any binary that compiled zlib in; U-Boot and kernel forks need separate review
Expat libexpat.so.1 XML_ExpatVersion() returns "expat_2.10.0" style strings CPython's pyexpat, other programs that vendor xmlparse.c
libxml2 libxml2.so.2 (before 2.14), libxml2.so.16 (2.14 and later) xmlParserVersion holds a number string, 2.15.4 is "21504" Symbol names such as xmlParseDocument in unstripped binaries

The zlib strings come from inftrees.c and deflate.c; a comment in inftrees.c asks product makers to "keep this copyright string in the executable of your product", which is why it survives static linking. A practical sequence:

  1. Search every ELF file, not only /lib and /usr/lib, for inflate 1., deflate 1. and expat_2.; each hit outside the shared library is a separate copy to track.
  2. Run readelf -d on each executable and list which ones name libz.so.1, libexpat.so.1, libxml2.so.2 or libxml2.so.16 as a dependency. That tells you which programs a shared-library upgrade fixes.
  3. Read the package database (opkg on OpenWrt-style images) or the Yocto or Buildroot manifest. Treat the version there as the upstream base: distributions and vendors backport fixes without changing it.
  4. Record the bootloader and kernel zlib forks as separate components rather than as "zlib 1.2.3".

Our firmware SBOM guide covers turning this into a component inventory, and the Yocto and Buildroot SBOM guide covers getting it from the build system instead.

Which vulnerability classes matter for zlib, Expat and libxml2?

zlib: inflate and deflate memory corruption

CVE-2022-37434 is the one most scanners report: NVD describes "a heap-based buffer over-read or buffer overflow in inflate in inflate.c via a large gzip header extra field" in zlib through 1.2.12, and adds that "only applications that call inflateGetHeader are affected". CVE-2018-25032 is the compression-side counterpart: memory corruption "when deflating (i.e., when compressing) if the input has many distant matches", fixed in 1.2.12.

The zlib home page lists the 1.4 security fixes: a gzwrite() buffer overflow (CVE-2026-85091), out-of-bounds pointer arithmetic in contrib/infback9 (CVE-2026-4738), and an inflateGetDictionary() bug that "could write up to 8 MB past the caller's 32K buffer", which zlib says "Affects 1.2.8 through 1.3.2". The release also fixes several flaws in contrib/minizip, a separate ZIP library in the zlib tree that only some devices build.

Expat and libxml2: entity expansion

A small XML document that nests entity references can expand into gigabytes of output, the "billion laughs" attack. The Expat XML security page says Expat versions before 2.4.0 were affected (CVE-2013-0340) and that by default Expat now "stops processing inputs if the output is more than 100 times larger than the input and larger than 8 MiB". Variants keep appearing: the Expat Changes file lists CVE-2026-115506 in 2.10.0 to "Detect billion laughs attacks quicker and more of its variations", noting that "a layer of compression around XML can significantly reduce the minimum attack payload size". A device that inflates a compressed manifest before parsing it has zlib and the XML parser on one attack path.

libxml2's NEWS file says its billion laughs protection "has been greatly improved" in 2.11.0. The XML_PARSE_HUGE option relaxes libxml2's size limits, and CVE-2022-40303 shows the cost: before 2.10.3, "When parsing a multi-gigabyte XML document with the XML_PARSE_HUGE parser option enabled, several integer counters can overflow". Firmware that sets this option for untrusted input should drop it. Entity handling also produces memory bugs that reach industrial products through their bundled copy: Hitachi Energy's RTU500 advisory, republished by CISA as ICSA-26-293-05, lists CVE-2026-6653, a use-after-free in libxml2's xmlParseInternalSubset that crafted XML with improper entity resolution can trigger in the RTU's XML-based services to cause a denial of service, fixed in CMU firmware 13.9.1, or 12.7.8 on the 12.7 line.

On external entities (XXE), Expat's security page states that "By default, Expat does not access external URLs" and only does so if the application installs an external entity handler. Review any firmware code that calls XML_SetExternalEntityRefHandler on network input.

Integer overflows on 32-bit targets

Several Expat fixes apply only where unsigned int and size_t are the same width, the normal case on 32-bit ARM and MIPS. Expat 2.6.3 fixed CVE-2024-45491 and CVE-2024-45492, integer overflows in dtdCopy and nextScaffoldPart "on 32-bit platforms (where UINT_MAX equals SIZE_MAX)", with impact up to "potentially artitrary code execution" [sic]. Expat 2.8.2 fixed 13 CVEs, among them six library integer overflows (CVE-2026-56403 to CVE-2026-56408) and three in the xmlwf tool, and 2.9.0 fixed CVE-2026-102633, an "Integer overflow in function expat_realloc on 32bit platforms". In libxml2, CVE-2025-6021 is an integer overflow in xmlBuildQName that "can lead to a stack-based buffer overflow", fixed in 2.14.4. Our memory corruption in embedded firmware guide covers the general pattern.

Malformed input passed through to the application

Expat 2.4.5 fixed CVE-2022-25235, where malformed UTF-8 passed to the application "can cause arbitrary damage (e.g. code execution)"; the Changes file says "Exploits with code execution are known to exist". Expat 2.8.5 fixed a related UTF-16 issue, CVE-2026-93990, with an upstream CVSS 3.1 score of 9.8; as of 2026-11-18, NVD shows the VulnCheck CNA score, CVSS 3.1 7.5.

Which CVEs should you know, and which release fixes each?

The CVEs above, with the first fixed upstream release and the condition that decides exposure. A vendor build can carry a fix under an older version number, so "fixed in" is the upstream answer only.

Library CVE Issue Fixed in Exposed only if
zlib CVE-2018-25032 Deflate memory corruption 1.2.12 Device compresses attacker-influenced data
zlib CVE-2022-37434 Gzip header extra field overflow 1.2.13 A program calls inflateGetHeader
zlib CVE-2026-85091 gzwrite() buffer overflow 1.4 A program writes gzip files through gz* functions
zlib CVE-2026-4738 inftree9.c pointer arithmetic 1.4 contrib/infback9 is built in
Expat CVE-2022-25235 Malformed UTF-8 passed through 2.4.5 Untrusted XML reaches the parser
Expat CVE-2024-45491, CVE-2024-45492 Integer overflows 2.6.3 32-bit target parsing untrusted XML
Expat CVE-2026-102633 expat_realloc overflow 2.9.0 32-bit target
Expat CVE-2026-115506 Billion laughs variants 2.10.0 Untrusted XML, often behind compression
libxml2 CVE-2022-40303 Counter overflows 2.10.3 XML_PARSE_HUGE set on untrusted input
libxml2 CVE-2025-6021 xmlBuildQName overflow 2.14.4 Untrusted XML with qualified names

Where does each project publish security fixes?

Each project publishes differently, which decides how you track them.

  • zlib. Release notes on zlib.net and the ChangeLog. Releases are infrequent (1.3.1 on 22 January 2024, 1.3.2 on 17 February 2026, 1.4 on 4 November 2026), and ChangeLog lines often describe a fix without naming a CVE, so map them against NVD records.
  • Expat. Every security fix appears in the Changes file with its CVE and pull request, and releases are announced on libexpat.github.io; eleven releases between January and November 2026 carried security fixes. The maintainer lists reported but unfixed issues in issue #1160: on 2026-11-14 it held 55 entries, 23 still unchecked, and the Changes file header states "Expat has UNFIXED SECURITY ISSUES!" Plan update capacity for further Expat releases.
  • libxml2. The NEWS file on GNOME GitLab has a Security heading per release; v2.15.4's six entries name the fixed function, not a CVE. The README says the project is "maintained by volunteers", that "It's NOT recommended to use this software to process untrusted data", and that security reports are handled "as a best effort".

How should a device maker triage these CVEs?

A version match produces a long list, most of it unreachable on a given device. Work through each match in order:

  1. Confirm the copy and versionWhich binary holds it, which version string, and whether the vendor or distribution has backported the fix.
  2. Check reachabilityFor zlib: does any program call inflateGetHeader, inflateGetDictionary or the gz* file functions on untrusted data? For a dynamically linked program, readelf --dyn-syms shows the imported zlib functions. For Expat and libxml2: does the device parse XML from the network, uploads or update packages, or only fixed files on a read-only partition?
  3. Check the targetA 32-bit-only overflow such as CVE-2024-45491 applies to a 32-bit ARM or MIPS build and not to a 64-bit one.
  4. Check exploitation dataOn 2026-12-01 the CISA KEV catalog (version 2026.11.30, 1,810 entries) listed no zlib, Expat or libxml2 library CVE; its one zlib-related entry, CVE-2025-14847, is a MongoDB Server bug in handling zlib-compressed protocol headers. FIRST EPSS scores on 2026-12-01 were 0.517 for CVE-2018-25032, 0.414 for CVE-2022-40303, 0.194 for CVE-2013-0340, 0.192 for CVE-2022-37434, 0.049 for CVE-2022-25235 and 0.025 for CVE-2022-40674. EPSS is a probability of exploitation activity, not a severity; our KEV and EPSS prioritization guide explains both.
  5. Record the decisionFor each matched CVE that does not apply, write down why (function not called, option not set, 32-bit only, fix backported). A machine-readable format such as OpenVEX lets customers and scanners see the same decision.

What does triage look like on one image? A worked example

Synthetic example, not a real product or customer: a 32-bit ARMv7 network video recorder image, triaged with the steps above.

Copy found Evidence Matched CVEs (selection) Decision
/usr/lib/libz.so.1 inflate 1.2.11 string; opkg says 1.2.11 CVE-2018-25032, CVE-2022-37434, CVE-2026-85091 No program imports inflateGetHeader, so CVE-2022-37434 is recorded as not affected; the web server compresses pages that echo user input, so CVE-2018-25032 applies. Upgrade to 1.4
zlib compiled into the update agent inflate 1.2.8 string inside the binary; no libz.so.1 dependency inflateGetDictionary bug (1.2.8 to 1.3.2) Static copy: the shared-library upgrade does not fix it. Rebuild the agent against 1.4
/usr/lib/libexpat.so.1 opkg says 2.2.9; UPnP SOAP handler parses LAN requests CVE-2022-25235, CVE-2024-45491, CVE-2024-45492 Network-reachable on a 32-bit target: all apply. Upgrade to 2.11.0
/usr/lib/libxml2.so.2 "20914" version string (2.9.14) CVE-2022-40303, CVE-2025-6021 Only a setup tool reading files from the read-only partition links it, without XML_PARSE_HUGE: not reachable today. Schedule the upgrade, allowing for the soname change
U-Boot zlib fork Header text "version 1.2.3" Upstream ranges do not apply Review against each CVE's code path with the bootloader

The result is two upgrades, one rebuild and three recorded not-affected decisions instead of a flat match list.

How do you patch zlib, Expat and libxml2 in firmware?

Upgrading the shared library through Yocto or Buildroot fixes every program that links it dynamically. It does not fix statically linked copies: each program that compiled zlib or Expat in needs its own rebuild, which is why the inventory step matters. Bootloader and kernel zlib forks are patched through U-Boot and kernel updates, not the zlib package.

Some upgrades change the interface. libxml2 2.14 moved the soname from libxml2.so.2 to libxml2.so.16, so programs linked against the old name must be rebuilt. libxml2 2.15 needs the XML_PARSE_UNZIP option to read compressed data and removed the built-in HTTP client. zlib 1.4 lists breaking changes, for example deflateReset() now resets the gzip header set by deflateSetHeader().

Build options narrow the exposure while an upgrade waits, and keep it narrow afterwards:

Library Option Default Embedded use
Expat EXPAT_GE, EXPAT_DTD ON Turn off where the device never needs entities or DTDs, which removes entity expansion paths (CMakeLists.txt)
Expat EXPAT_BUILD_TOOLS ON in typical builds Skip xmlwf on the device; three 2.8.2 CVEs were in it
libxml2 minimum false "build a minimally sized library", then enable only needed features (meson_options.txt)
libxml2 zlib, catalog, xinclude Feature options zlib, liblzma and HTTP support have been off by default since 2.13.0; leave out what the device does not use
zlib contrib/minizip, contrib/infback9 Not part of the core library Do not build them unless used; 1.4 fixed flaws in both

At run time, keep Expat's billion laughs limits at their defaults or tighten them with XML_SetBillionLaughsAttackProtectionMaximumAmplification, do not install external entity handlers for untrusted input, and drop XML_PARSE_HUGE from libxml2 calls that read network data. To confirm what a vendor update changed, see firmware diffing and patch analysis. Related library guides: libcurl, OpenSSL and glibc, uClibc and musl.

What are the common mistakes with these three libraries?

  • Upgrading libz.so.1 and closing every zlib finding. Static copies inside other binaries keep their old version.
  • Mapping the U-Boot or kernel fork onto upstream ranges. "1.2.3" in a fork header is not upstream zlib 1.2.3.
  • Trusting the package version over the binary. A backport can fix a CVE without changing the number, and a vendored copy can be older than the package says.
  • Dropping in libxml2 2.14 or later without rebuilding. Programs still ask for libxml2.so.2.
  • Treating XML from the update channel as trusted. If the manifest is compressed and parsed before its signature is checked, it is untrusted input.

AI-assisted analysis: what SoftWSP actually runs

SoftWSP's automated scan unpacks a firmware image, catalogs the software components it can identify in the extracted file system, and records each one's name, version and identifiers. Where the image carries identifiable zlib, Expat or libxml2 version evidence, that component is matched against CVE records, CISA's KEV catalog and FIRST's EPSS scores. The code scores, and AI narrates.

AI then writes the plain-language explanation: which CVEs matched, which are KEV-listed or have a high EPSS score, and what version evidence they rest on, citing the component, version and record behind every sentence. An engineer reviews every finding before the report is delivered. The judgements this guide describes as manual stay with that engineer: whether a static copy or a bootloader or kernel fork is affected, whether firmware calls inflateGetHeader or parses untrusted XML, whether the target is 32-bit, and whether a vendor backport already closes a matched CVE.

For a specific image, see device & firmware security services.

This guide draws on the zlib, Expat and libxml2 project sources and release notes, NVD records, CISA's KEV catalog and FIRST EPSS data, read directly between 2026-11-12 and 2026-11-14; KEV and EPSS figures rechecked on 2026-12-01.

Put this guide to work

Frequently asked questions

How do I find the zlib, Expat and libxml2 versions inside a firmware image?

Unpack the root file system and search every ELF file, not only the shared libraries. zlib embeds the strings " inflate 1.x Copyright ... Mark Adler " and " deflate 1.x Copyright ... Jean-loup Gailly and Mark Adler ", so a strings search shows the version even in statically linked copies. Expat's XML_ExpatVersion() returns a string of the form "expat_2.10.0", which is also searchable. libxml2 stores its version as a number string (2.15.4 becomes "21504"), so pair a search for libxml2.so.2 or libxml2.so.16 with readelf -d on each binary and the package database or build manifest. Separately check U-Boot and the Linux kernel, which carry their own zlib forks.

Which zlib, Expat and libxml2 CVEs matter most on a device?

The ones whose code path the device actually reaches with attacker-controlled input. CVE-2022-37434, the zlib inflate heap overflow through a large gzip header extra field, only affects applications that call inflateGetHeader. CVE-2024-45491 and CVE-2024-45492 in Expat are integer overflows on 32-bit platforms, which describes many embedded ARM and MIPS targets. Entity-expansion (billion laughs) denial of service matters wherever a device parses XML from the network: Expat added protection in 2.4.0 against CVE-2013-0340, and libxml2's CVE-2022-40303 integer overflows need the XML_PARSE_HUGE option, which also lifts libxml2's safety limits.

Are any zlib, Expat or libxml2 vulnerabilities in CISA's KEV catalog?

No library CVE from the three projects appears in the CISA Known Exploited Vulnerabilities catalog version 2026.11.30 (1,810 entries). The only entry that mentions zlib, CVE-2025-14847, is a MongoDB Server flaw in how it handles zlib-compressed protocol headers, not a zlib library bug. Ranking therefore leans on reachability and FIRST EPSS: on 2026-12-01 EPSS gave CVE-2018-25032 (zlib deflate) 0.517, against 0.414 for CVE-2022-40303 (libxml2), 0.194 for CVE-2013-0340 (Expat billion laughs), 0.192 for CVE-2022-37434 (zlib inflate), 0.049 for Expat's CVE-2022-25235 and 0.025 for Expat's CVE-2022-40674.

Where do zlib, Expat and libxml2 publish their security fixes?

zlib lists fixes on the zlib.net home page and in the ChangeLog in github.com/madler/zlib; ChangeLog lines often describe the fix without a CVE number. Expat lists each fix with its CVE in the Changes file in github.com/libexpat/libexpat, announces releases on libexpat.github.io and tracks unfixed reports in GitHub issue #1160. libxml2 lists fixes under a Security heading in the NEWS file on gitlab.gnome.org/GNOME/libxml2; recent entries name the fixed function rather than a CVE.

Does SoftWSP decide whether a zlib, Expat or libxml2 CVE is reachable in my firmware?

No, not automatically. SoftWSP's scan identifies software components and versions in the unpacked firmware and matches them against CVE records, CISA KEV and FIRST EPSS data; AI then writes a summary that cites the component, version and record behind each finding, and an engineer reviews it. Whether firmware calls inflateGetHeader, parses untrusted XML, runs on a 32-bit target or carries a vendor backport is decided in that engineer review.

Sources

  1. zlib home page (zlib 1.4 release notes, 4 November 2026)
  2. madler/zlib: ChangeLog
  3. libexpat: Expat Changes (release notes and security fixes)
  4. libexpat: issue #1160, Unfixed non-public security issues
  5. libexpat: Expat XML parser home page (release news)
  6. libexpat: XML Security (XXE and billion laughs)
  7. GNOME/libxml2: NEWS (v2.15.4, 1 September 2026)
  8. libexpat: expat/CMakeLists.txt (EXPAT_GE, EXPAT_DTD and other build options)
  9. GNOME/libxml2: meson_options.txt (v2.15.4 build options)
  10. madler/zlib: inftrees.c (copyright string kept in product executables)
  11. GNOME/libxml2: README (Security section)
  12. U-Boot: include/u-boot/zlib.h (bundled zlib 1.2.3 header)
  13. Linux kernel: lib/zlib_inflate/inflate.c
  14. CPython: Modules/expat (bundled Expat copy)
  15. NIST NVD: CVE-2022-37434 (zlib inflate gzip header)
  16. NIST NVD: CVE-2018-25032 (zlib deflate memory corruption)
  17. NIST NVD: CVE-2022-40303 (libxml2 XML_PARSE_HUGE integer overflows)
  18. NIST NVD: CVE-2025-6021 (libxml2 xmlBuildQName)
  19. CISA: Known Exploited Vulnerabilities (KEV) Catalog
  20. FIRST: Exploit Prediction Scoring System (EPSS)
Was this guide helpful?

In this cluster

zlib, Expat and libxml2 vulnerabilities in embedded firmware: finding, triaging and patching them