Security Advisory

CVE-2022-40674: Expat doContent Use-After-Free

Last updated:
  • CVE-2022-40674

CVE-2022-40674 is a heap use-after-free in the doContent function of Expat (libexpat), the XML parser built into many device firmware images. It affects Expat before 2.4.9, which fixed it on 20 September 2022. NVD scores it 8.1, Siemens scores it 9.8, and Siemens lists SCALANCE XCM332 and S7-1500 MFP firmware as affected.

Vulnerability summary

CVSS base score

8.1

High severity

EPSS score (FIRST)

2.4%

Probability of exploitation in the wild in the next 30 days

CISA KEV catalog

No

Not listed

Published

Vulnerability ID: CVE-2022-40674 · Source: NVD

Affected components

ComponentCPEVersion range
Expat / libexpat (doContent)cpe:2.3:a:libexpat_project:libexpat:*:*:*:*:*:*:*:*before 2.4.9 (fixed in 2.4.9, 20 September 2022)
Siemens SCALANCE XCM332—before V2.2 (fixed in V2.2, per SSA-558014)
Siemens SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP (GNU/Linux subsystem)—V3.1.0 to before V3.1.5 (fixed in V3.1.5, per SSA-398330)

What does this mean for affected devices?

CVE-2022-40674 is a heap use-after-free (CWE-416) in Expat, the XML parser library also known as libexpat. NVD's description: "libexpat before 2.4.9 has a use-after-free in the doContent function in xmlparse.c." NVD's Primary CVSS 3.1 score is 8.1, vector CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H; the high attack complexity is what keeps it below 9.8 (NVD).

Expat 2.4.9, released 20 September 2022, fixed it. The Expat Changes file lists it as the release's only security fix: "Heap use-after-free vulnerability in function doContent. Expected impact is denial of service or potentially arbitrary code execution." The upstream pull request #640 adds the regression test for the bug.

Siemens ProductCERT names industrial devices that ship the vulnerable Expat and scores the CVE higher than NVD, at 9.8. SSA-558014 covers the SCALANCE XCM332 switch before V2.2, fixed in V2.2. SSA-398330 covers the additional GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP from V3.1.0 to before V3.1.5, fixed by updating to V3.1.5. Use the vendor's score when it rates the product as shipped, and NVD's when you are ranking a library match across many images.

For a firmware team the questions are where Expat parses network input (UPnP and SOAP handlers, configuration imports) and which Expat build each binary uses, since Expat is small enough to be copied statically into programs. Distribution packages backported the fix: the Debian tracker marks bullseye fixed in 2.2.10-2+deb11u4 (DSA-5236-1) and buster in 2.2.6-2+deb10u5 (DLA-3119-1).

This CVE is not in the CISA KEV catalog as of 2026-11-16 (catalog version 2026.11.13, CISA KEV). FIRST EPSS gives it 0.024, the 84.3rd percentile, in its 2026-11-15 dataset (FIRST EPSS).

The fix is Expat 2.4.9 or later; later releases add many more security fixes, so upgrading to the current release is the durable step. Our zlib, Expat and libxml2 vulnerabilities in embedded firmware guide covers locating Expat in an image and ranking its CVEs by reachability, and the memory corruption fix guide covers use-after-free fixes. Other Expat flaws on this site: CVE-2022-25235 (malformed UTF-8) and CVE-2024-45491 (32-bit integer overflow).

How to fix this class of issueThis advisory's weakness class is Memory corruption. Our practical guide covers how to detect, fix, verify and disclose it: How to fix memory corruption in embedded firmware.

Evidence

  • libexpat before 2.4.9 has a use-after-free in doContent in xmlparse.c; NVD Primary CVSS 3.1 8.1 (AC:H); CWE-416. — NVD
  • Expat 2.4.9 (20 Sep 2022): heap use-after-free in doContent; expected impact denial of service or potentially arbitrary code execution. — Expat Changes
  • SCALANCE XCM332 before V2.2 affected, fix V2.2; Siemens CVSS 9.8. — Siemens SSA-558014
  • S7-1500 CPU 1518(F)-4 PN/DP MFP GNU/Linux subsystem V3.1.0 to before V3.1.5 affected, fix V3.1.5; Siemens CVSS 9.8. — Siemens SSA-398330
  • Debian bullseye fixed in 2.2.10-2+deb11u4 (DSA-5236-1), buster in 2.2.6-2+deb10u5 (DLA-3119-1). — Debian Security Tracker
  • Not in the CISA KEV catalog version 2026.11.13 as of 2026-11-16. — CISA KEV
  • EPSS 0.02401, percentile 0.84303, dataset 2026-11-15. — FIRST EPSS

Related advisories

Sources

  1. NVD
  2. Expat Changes (release 2.4.9)
  3. libexpat pull request #640 (CVE-2022-40674 test coverage)
  4. Siemens SSA-558014 (SCALANCE XCM332 before V2.2)
  5. Siemens SSA-398330 (S7-1500 CPU 1518 MFP GNU/Linux subsystem before V3.1.5)
  6. Debian Security Tracker
  7. CISA KEV
  8. CISA KEV data (catalog JSON)
  9. FIRST EPSS

Frequently asked questions

Why do NVD and Siemens score CVE-2022-40674 differently?

NVD rates it 8.1 with high attack complexity (AC:H), while Siemens rates it 9.8 in SSA-558014 and SSA-398330 for its products (per NVD and Siemens ProductCERT).

Which Siemens products are affected by CVE-2022-40674?

SSA-558014 lists the SCALANCE XCM332 before V2.2, and SSA-398330 lists the GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP from V3.1.0 to before V3.1.5 (per Siemens ProductCERT).

Which Expat release fixes CVE-2022-40674?

Expat 2.4.9, released 20 September 2022. Debian backported the fix to bullseye (2.2.10-2+deb11u4) and buster (2.2.6-2+deb10u5) (per the Expat Changes file and the Debian Security Tracker).

Is CVE-2022-40674 in the CISA KEV catalog?

No, it is absent from catalog version 2026.11.13 as of 2026-11-16. FIRST EPSS gives it 0.024, the 84.3rd percentile, in the 2026-11-15 dataset (per CISA KEV and FIRST EPSS).