VYPR
Unrated severityNVD Advisory· Published Sep 3, 2018· Updated Aug 5, 2024

CVE-2018-16375

CVE-2018-16375

Description

Missing validation of image dimensions in OpenJPEG 2.3.0 pnmtoimage leads to a heap-based buffer overflow.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Missing validation of image dimensions in OpenJPEG 2.3.0 pnmtoimage leads to a heap-based buffer overflow.

Vulnerability

A heap-based buffer overflow exists in OpenJPEG version 2.3.0 in the pnmtoimage function within bin/jpwl/convert.c. The code reads a PNM header via read_pnm_header and stores the dimensions in header_info.height and header_info.width, but fails to validate that these values do not result in an integer overflow when computing the buffer size. An attacker can craft a PNM file with excessively large height and width values, causing a multiplication overflow that leads to an undersized heap allocation and subsequent buffer overflow.

Exploitation

An attacker can exploit this vulnerability by providing a specially crafted PNM image file as input to the pnmtoimage function. The attacker needs no special privileges beyond the ability to supply the file to an application using OpenJPEG (e.g., via file upload or direct processing). No authentication is required. The lack of validation for header_info.height and header_info.width allows the attacker to trigger the integer overflow and subsequent heap corruption.

Impact

Successful exploitation leads to a heap-based buffer overflow, which can corrupt adjacent heap memory. This can result in a denial of service (application crash) or potentially arbitrary code execution, depending on the heap layout and the attacker's ability to control the overflow content. The impact is high due to the possibility of remote code execution in systems that process untrusted PNM files using the vulnerable library.

Mitigation

The official fix is to add a check that verifies the product of header_info.height and header_info.width does not exceed INT_MAX (as proposed in the referenced issue [1]). Users should upgrade to OpenJPEG version 2.3.1 or later, which includes this check. There is no known workaround for earlier versions; users should avoid processing untrusted PNM files with vulnerable versions. The CVE is not listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

AI Insight generated on May 26, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

37

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"Missing checks for image dimensions in the pnmtoimage function can lead to a heap-based buffer overflow."

Attack vector

An attacker can trigger this vulnerability by providing a specially crafted PNM image file to the `pnmtoimage` function. The file must have header information where the `height` and `width` values, when multiplied, exceed the maximum value representable by `INT_MAX`. This leads to an integer overflow during memory allocation calculations, resulting in a heap-based buffer overflow.

Affected code

The vulnerability resides in the `pnmtoimage` function located in the file `src/bin/jpwl/convert.c`. Specifically, the issue arises after the `read_pnm_header` function is called and before the image data is processed, where checks for `header_info.height` and `header_info.width` are missing.

What the fix does

The patch introduces a check for the image dimensions before memory allocation. It verifies that `header_info.height` is not zero and that `header_info.width` is not excessively large relative to `header_info.height` to prevent integer overflow when calculating the total size. If the dimensions are too large, an error message is printed, and the function returns, thus preventing the heap-based buffer overflow.

Preconditions

  • inputA specially crafted PNM image file with excessively large dimensions.

Generated on Jun 3, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

2

News mentions

0

No linked articles in our index yet.