Use-after-free vulnerability in libexpat

expat Updated 02 Oct 2025

Summary

24/10/2022
N/A
Yes i
High
7.5

CVE-2022-43680: In libexpat through 2.4.9, there is a use-after free caused by overeager destruction of a shared DTD in XML_ExternalEntityParserCreate in out-of-memory situations. Affects expat across 2 version ranges.

< 2.2.10-r8 < d77291a4824d78e697c5dc2b8024fd65ab31e209

Fixed in 2.2.10-r8. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

libexpat is a widely used open-source library for parsing XML documents. It provides a set of functions and APIs for handling XML data. The library is used by various applications and frameworks to parse and process XML files. However, a use-after-free vulnerability has been discovered in libexpat versions prior to 2.4.9. This vulnerability can be triggered in out-of-memory situations, leading to a use-after-free condition in the XML_ExternalEntityParserCreate function. This function is responsible for creating a parser for parsing external entities in XML documents.

Vulnerability Detail

The use-after-free vulnerability in libexpat occurs when the library incorrectly destroys a shared DTD (Document Type Definition) in out-of-memory situations. This can result in a situation where the memory previously allocated for the DTD is freed, but still accessed by the program. An attacker can exploit this vulnerability by crafting a malicious XML document that triggers an out-of-memory condition, leading to a use-after-free condition. This could potentially allow the attacker to execute arbitrary code or cause a denial-of-service (DoS) condition on the affected system.

How To Fix

Minimum fixed version

2.2.10-r8

This is the first release that contains the fix.

sudo apk add --upgrade expat

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is recommended to update to a fixed version of libexpat as soon as possible.

Conclusion

The use-after-free vulnerability in libexpat can be a serious security issue, potentially allowing an attacker to execute arbitrary code or cause a denial-of-service condition. It is crucial to update to a fixed version of libexpat (version 2.4.9 or later) to mitigate the risk of exploitation. Regularly checking for updates and applying patches for other dependencies or applications that use libexpat is also recommended. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for expat →

Share this vulnerability

FAQ

libexpat is an open-source library for parsing XML documents. It provides functions and APIs for handling XML data.

A use-after-free vulnerability occurs when a program continues to use memory after it has been freed. This can lead to memory corruption and potentially allow an attacker to execute arbitrary code or cause a denial-of-service condition.

This vulnerability can be exploited by crafting a malicious XML document that triggers an out-of-memory condition in libexpat, leading to a use-after-free condition.

The impact of this vulnerability can vary depending on the context in which libexpat is used. In some cases, it could allow an attacker to execute arbitrary code or cause a denial-of-service condition on the affected system.

To mitigate the risk of exploitation, it is recommended to update to a fixed version of libexpat (version 2.4.9 or later). Regularly checking for updates and applying patches for other dependencies or applications that use libexpat is also advisable.

Related vulnerabilities

Recent vulnerabilities recorded for expat.

How To Fix

Minimum fixed version

2.2.10-r8

This is the first release that contains the fix.

sudo apk add --upgrade expat

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback