Critical Memory Mismanagement in Expat Package - CVE-2021-45960

expat Updated 02 Oct 2025

Summary

01/01/2022
N/A
Yes i
High
8.8

ALPINE-CVE-2021-45960: In Expat (aka libexpat) before 2.4.3, a left shift by 29 (or more) places in the storeAtts function in xmlparse.c can lead to realloc misbehavior (e.g., allocating too few bytes, or only freeing memory). Affects expat versions < 2.2.10-r0. Fixed in 2.2.10-r0. 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 an XML parsing library widely used in various applications for its efficiency and ease of use. It provides a simple API for parsing XML documents and is known for its performance and low memory footprint. However, it has been identified to have a critical vulnerability that can lead to memory mismanagement, potentially affecting applications that rely on it.

Vulnerability Detail

In Expat (aka libexpat) before version 2.4.3, a left shift by 29 or more places in the storeAtts function within xmlparse.c can lead to realloc misbehavior. This misbehavior may result in allocating insufficient memory or improperly freeing memory, which can lead to application crashes or exploitation by attackers. The vulnerability has a CVSS score of 8.8, indicating a high severity level.

How To Fix

Minimum fixed version

2.2.10-r0

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

As a temporary workaround, consider avoiding the use of the affected functions in Expat until the package is updated. Review your application's XML parsing logic to ensure it does not rely on the vulnerable aspects of the library.

Conclusion

The vulnerability identified as CVE-2021-45960 in the Expat package poses a significant risk to applications that utilize this XML parsing library. It is crucial to update to the patched version to mitigate potential security threats. Utilize available resources like Vulert to monitor your applications for vulnerabilities effectively.

See every vulnerability recorded for expat →

Share this vulnerability

FAQ

CVE-2021-45960 is a vulnerability in the Expat XML parsing library that can lead to memory mismanagement.

If your application uses Expat versions prior to 2.4.3, it may be susceptible to crashes or exploitation due to improper memory handling.

Consider implementing a workaround by avoiding the use of the affected functions until you can update to a patched version.

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

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

Related vulnerabilities

Recent vulnerabilities recorded for expat.

How To Fix

Minimum fixed version

2.2.10-r0

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