CVE-2022-40304: Hash Table Key Corruption in libxml2
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.