CVE-2026-137063 in Leptonicainfo

Summary

by MITRE • 11/25/2026

Leptonica 1.79.0 through 1.87.0 contains a heap-based buffer overflow vulnerability in l_byteaInitFromStream() that allows attackers to write past a heap buffer by supplying oversized input. Attackers can provide a file larger than 1,000,000,000 bytes, causing l_byteaCreate() to allocate a 201-byte buffer before memcpy copies the full stream size, crashing the application.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 11/25/2026

The vulnerability identified in Leptonica versions 1.79.0 through 1.87.0 represents a critical heap-based buffer overflow within the l_byteaInitFromStream function. This library is widely utilized for image processing tasks, including reading and writing various raster formats such as TIFF, JPEG, PNG, and others. The core of the issue lies in how memory allocation interacts with data ingestion from input streams. When an application utilizing Leptonica processes a file via this specific function, it attempts to initialize a byte array based on the size of the incoming stream. However, the implementation contains a logical flaw where the allocated buffer size does not correspond correctly to the actual amount of data being copied into memory during certain conditions involving large files.

The technical mechanism of the exploit involves an attacker providing a crafted input file that exceeds one billion bytes in size. Upon receiving this oversized input, the function l_byteaCreate is invoked with specific parameters that result in the allocation of only 201 bytes on the heap. This allocation appears to be based on a default or initial capacity setting rather than the full stream length. Subsequently, the memcpy operation proceeds to copy the entire contents of the stream into this severely undersized buffer. Because the source data is significantly larger than the destination buffer's allocated space, the memory write operations extend beyond the boundaries of the heap allocation. This out-of-bounds write corrupts adjacent heap metadata or other critical data structures stored in memory immediately following the buffer.

This type of vulnerability falls under CWE-122, which describes a heap-based buffer overflow allowing an attacker to overwrite arbitrary memory locations. The operational impact is severe, as such corruption can lead to immediate application crashes due to segmentation faults when the program attempts to access invalid memory addresses or when the heap manager detects inconsistencies during subsequent allocation requests. More critically, in scenarios where the vulnerable code runs with elevated privileges or processes untrusted user input, an attacker may leverage this overflow to achieve arbitrary code execution. By carefully crafting the payload and controlling the data written past the buffer boundary, it is possible to overwrite function pointers or return addresses on the heap, thereby hijacking control flow within the application process.

From a threat intelligence perspective, this vulnerability aligns with ATT&CK technique T1203, which covers Exploitation for Client Execution if Leptonica is used in client-side applications like image viewers or editors that automatically open files upon user interaction. It also relates to T1496, Resource Hijacking, as the initial crash can be used to cause denial of service against services relying on this library for continuous processing tasks such as web-based image conversion APIs or batch processing pipelines. The ability to trigger a crash with a single large file makes it particularly dangerous in automated environments where files are processed without rigorous size validation prior to passing them to Leptonica functions.

Mitigation strategies must focus on updating the underlying library and implementing defensive coding practices at the application level. Users of Leptonica should immediately upgrade to version 1.87.1 or later, where this allocation logic has been corrected to ensure that buffer sizes match the actual data requirements before copying occurs. For applications unable to update immediately due to dependency constraints, developers can implement a pre-processing step that validates file sizes and rejects inputs exceeding reasonable thresholds for their specific use case. Additionally, employing memory-safe languages for new development or using static analysis tools configured with rules targeting CWE-120 and CWE-122 during the code review phase can help identify similar patterns in custom image processing logic. Enabling heap protection mechanisms such as Address Sanitizer (ASan) during testing phases is also recommended to detect these boundary violations early in the development lifecycle before deployment.

Responsible

VulnCheck

Reservation

11/25/2026

Disclosure

11/25/2026

Moderation

accepted

CPE

ready

EPSS

0.00233

KEV

no

Activities

low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!