Expat Package Vulnerability: Stack Exhaustion via DTD Element Nesting

expat Updated 02 Oct 2025

Summary

18/02/2022
N/A
Yes i
Medium
6.5

ALPINE-CVE-2022-25313: In Expat (aka libexpat) before 2.4.5, an attacker can trigger stack exhaustion in build_model via a large nesting depth in the DTD element. Affects expat versions < 2.2.10-r2. Fixed in 2.2.10-r2. 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 Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Expat, also known as libexpat, is a widely used XML parsing library that provides a fast and efficient way to parse XML documents. It is known for its simplicity and ease of integration into various applications. However, it has been identified that certain versions of Expat are vulnerable to a stack exhaustion issue when processing Document Type Definitions (DTDs) with excessive nesting, which can lead to application crashes or denial of service.

Vulnerability Detail

The vulnerability, identified as CVE-2022-25313, arises from the inability of Expat to handle deep nesting in DTD elements. An attacker can exploit this flaw by crafting a malicious XML document that contains a DTD with a large nesting depth. When the Expat parser attempts to process this document, it can lead to stack exhaustion, causing the application to crash or become unresponsive. This vulnerability affects multiple versions of the Expat library prior to version 2.4.5.

How To Fix

Minimum fixed version

2.2.10-r2

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

If immediate upgrading is not feasible, consider disabling DTD processing in your XML parser configuration, if supported. This can help mitigate the risk of exploitation until the package can be updated.

Conclusion

The Expat package has a critical vulnerability that can lead to stack exhaustion through deep nesting in DTD elements. It is crucial to update to the patched version to mitigate this risk. Utilizing tools like Vulert can help monitor and manage vulnerabilities effectively.

See every vulnerability recorded for expat →

Share this vulnerability

FAQ

CVE-2022-25313 is a vulnerability in the Expat XML parsing library that allows attackers to cause stack exhaustion through deep nesting in DTD elements.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Exploitation of this vulnerability can lead to application crashes or denial of service, impacting the availability of your application.

Yes, the vulnerability has been patched in Expat version 2.4.5 and later. It is recommended to update to this version or higher.

Vulert is a tool that monitors and alerts for open-source vulnerabilities in software using just a manifest file like package-lock.json, providing real-time insights.

Related vulnerabilities

Recent vulnerabilities recorded for expat.

How To Fix

Minimum fixed version

2.2.10-r2

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