The vulnerability, CVE-2026-105747, stems from the docling library's handling of gzip-compressed tar archives (METS-GBS format). Specifically, the tarfile.TarFile.getmembers() method was called in two critical areas: during format detection and when opening the archive in the METS-GBS backend. This method eagerly loads the entire list of archive members into memory before any max_member_count limit could be effectively applied. An attacker could exploit this by providing a small, compressed archive containing a very large number of empty members. This would cause docling to allocate a disproportionately large amount of memory (e.g., 408 MB for a 6.2 MB input), leading to memory exhaustion and a denial-of-service condition.
The provided patch addresses this by modifying the code to iterate over archive members lazily, reading them one at a time and enforcing the max_member_count limit as members are processed, rather than after all headers have been read. The _tar.extractfile() calls were also replaced with a custom _extract_member method that respects the lazy loading and member count limits.
The identified vulnerable functions are:
MetsGbsDocumentBackend.__init__ in docling/backend/mets_gbs_backend.py: This constructor initially used self._tar.getmembers() to process archive members, leading to the eager loading issue.
MetsGbsDocumentBackend._parse_page in docling/backend/mets_gbs_backend.py: This method used self._tar.extractfile() to access specific members, which also triggered the full member list enumeration.
_DocumentConversionInput._detect_mets_gbs in docling/datamodel/document.py: This function, responsible for detecting the METS-GBS format, also used tar.getmembers(), causing memory exhaustion even before the format was fully confirmed or rejected.