Heap-buffer-overflow in xmlParseCommentComplex in libxml2

libxml2 Updated 02 Oct 2025

Summary

10/10/2023
HIGH
Yes i
High
Not published

OSV-2023-999: Heap-buffer-overflow in xmlParseCommentComplex. Affects libxml2 versions >= 8afd321abd2f75cf795f679b54333237b364d4d9, < 4fc5340ec55a12cd6819395030d5d132a219984a. Fixed in 4fc5340ec55a12cd6819395030d5d132a219984a. 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 an open-source library for parsing and manipulating XML files. It provides a set of functions and APIs to handle XML data. The library is widely used in various applications and frameworks. However, a vulnerability has been discovered in the xmlParseCommentComplex function of libxml2, which can lead to a heap-buffer-overflow write. This vulnerability can be exploited by an attacker to execute arbitrary code or cause a denial-of-service condition.

Vulnerability Detail

The vulnerability originates from a heap-buffer-overflow write in the xmlParseCommentComplex function of libxml2. When parsing a specially crafted XML comment, the function fails to properly validate the input, leading to a buffer overflow. This can result in overwriting adjacent memory regions, potentially allowing an attacker to execute arbitrary code or crash the application. The vulnerability has been assigned a high severity rating.

How To Fix

Minimum fixed version

4fc5340ec55a12cd6819395030d5d132a219984a

This is the first release that contains the fix.

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

Workaround

As a temporary workaround, developers can implement input validation and sanitization measures when processing XML comments. This can help mitigate the risk of exploitation. Here is an example of how to sanitize XML comments using a regular expression in Python:

import re

def sanitize_xml_comment(comment):
    sanitized_comment = re.sub(r'--', '', comment)
    return sanitized_comment

This code snippet removes any double hyphens from the XML comment, which can help prevent the vulnerability from being triggered.

Conclusion

The heap-buffer-overflow vulnerability in xmlParseCommentComplex in libxml2 can have severe consequences, including arbitrary code execution and denial-of-service. It is crucial to update the libxml2 library to a patched version that addresses this vulnerability. Additionally, implementing input validation and sanitization measures can provide temporary protection. 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 provides a set of functions and APIs to handle XML data.

The vulnerability can be exploited by an attacker to execute arbitrary code or cause a denial-of-service condition.

To fix this vulnerability, update the libxml2 library to a version that includes the fix.

As a temporary workaround, implement input validation and sanitization measures when processing XML comments.

For more information about this vulnerability, refer to the OSS-Fuzz report linked in the details section.

Related vulnerabilities

Recent vulnerabilities recorded for libxml2.

How To Fix

Minimum fixed version

4fc5340ec55a12cd6819395030d5d132a219984a

This is the first release that contains the fix.

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