CVE-2022-40304: Hash Table Key Corruption in libxml2

libxml2 Updated 02 Oct 2025

Summary

23/11/2022
N/A
Yes i
High
7.8

CVE-2022-40304: An issue was discovered in libxml2 before 2.10.3. Affects libxml2 across 3 version ranges.

< 1b41ec4e9433b05bb0376be4725804c54ef1d80b < 2.9.14-r2 < f507d167f1755b7eaea09fb1a44d29aab828b6d1

Fixed in 2.9.14-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

libxml2 is a widely used open-source library for parsing and manipulating XML files. It provides various functionalities for XML processing and is commonly used in applications that deal with XML data. However, a vulnerability has been discovered in versions prior to 2.10.3 that can lead to hash table key corruption, potentially resulting in logic errors and even double-free vulnerabilities.

Vulnerability Detail

The vulnerability (CVE-2022-40304) arises from the mishandling of certain invalid XML entity definitions in libxml2. When processing these definitions, a hash table key can become corrupted, leading to subsequent logic errors. In some cases, this corruption can trigger a double-free vulnerability. An attacker could potentially exploit this vulnerability to execute arbitrary code or cause a denial-of-service condition.

How To Fix

Minimum fixed version

2.9.14-r2

This is the first release that contains the fix.

sudo apk add --upgrade libxml2

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

Workaround

If updating libxml2 is not immediately feasible, a possible workaround is to sanitize and validate XML entity definitions before passing them to libxml2. By ensuring that only valid and well-formed entity definitions are used, the risk of triggering the vulnerability can be mitigated. However, this workaround may not provide complete protection and should be considered temporary until the library can be updated.

Conclusion

The vulnerability (CVE-2022-40304) in libxml2 can lead to hash table key corruption and subsequent logic errors. It is crucial to update libxml2 to version 2.10.3 or later to mitigate the risk. Additionally, ensure that any applications or libraries dependent on libxml2 are also updated and recompiled. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for libxml2 →

Share this vulnerability

FAQ

libxml2 is an open-source library for parsing and manipulating XML files. It is widely used in various applications and provides functionalities for XML processing.

The vulnerability can lead to hash table key corruption and subsequent logic errors. In some cases, it can also result in a double-free vulnerability. An attacker could potentially exploit this to execute arbitrary code or cause a denial-of-service condition.

Versions prior to 2.10.3 are affected by this vulnerability.

To fix this vulnerability, update libxml2 to version 2.10.3 or later. Ensure that any applications or libraries dependent on libxml2 are also updated and recompiled.

A temporary workaround is to sanitize and validate XML entity definitions before passing them to libxml2. However, updating to the patched version is the recommended solution.

Related vulnerabilities

Recent vulnerabilities recorded for libxml2.

How To Fix

Minimum fixed version

2.9.14-r2

This is the first release that contains the fix.

sudo apk add --upgrade libxml2

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