A NULL pointer dereference in TIFFClose() is caused by a failure to open an output file (non-existent path or a path that requires permissions like /dev/null) while specifying zones.
Description
A NULL pointer dereference in TIFFClose() is caused by a failure to open an output file (non-existent path or a path that requires permissions like /dev/null) while specifying zones.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
20- osv-coords18 versionspkg:rpm/almalinux/libtiffpkg:rpm/almalinux/libtiff-develpkg:rpm/almalinux/libtiff-toolspkg:rpm/opensuse/tiff&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/tiff&distro=openSUSE%20Leap%2015.5pkg:rpm/opensuse/tiff&distro=openSUSE%20Leap%20Micro%205.3pkg:rpm/opensuse/tiff&distro=openSUSE%20Leap%20Micro%205.4pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Micro%205.2pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Micro%205.3pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Micro%205.4pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Micro%205.5pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP4pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP5pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Package%20Hub%2015%20SP4pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Package%20Hub%2015%20SP5pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP5pkg:rpm/suse/tiff&distro=SUSE%20Linux%20Enterprise%20Software%20Development%20Kit%2012%20SP5
< 4.4.0-10.el9+ 17 more
- (no CPE)range: < 4.4.0-10.el9
- (no CPE)range: < 4.4.0-10.el9
- (no CPE)range: < 4.4.0-10.el9
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-150000.45.32.1
- (no CPE)range: < 4.0.9-44.71.1
- (no CPE)range: < 4.0.9-44.71.1
- (no CPE)range: < 4.0.9-44.71.1
Patches
Vulnerability mechanics
Root cause
"Missing NULL pointer check in TIFFClose() when the output TIFF* pointer is NULL due to a failure to open the output file."
Attack vector
An attacker can trigger this vulnerability by providing a crafted TIFF file (any valid TIFF works) and invoking `tiffcrop` with the `-Z` (zones) option and an output path that cannot be opened, such as a non-existent directory or a privileged path like `/dev/null`. The tool attempts to open the output file via `update_output_file()`, which fails and returns an error, but the program continues and later calls `TIFFClose()` on a NULL `TIFF*` pointer. This results in a NULL pointer dereference and a segmentation fault [ref_id=1]. The precondition is that the attacker can supply both the input TIFF file and the command-line arguments to `tiffcrop`.
Affected code
The bug resides in `tools/tiffcrop.c` within the `writeSelections()` and `update_output_file()` functions. When `tiffcrop` is invoked with the `-Z` (zones) option and the specified output file cannot be opened (e.g., a non-existent path or a path requiring special permissions like `/dev/null`), `update_output_file()` returns an error but the output `TIFF*` pointer remains `NULL`. Subsequently, `TIFFClose()` in `libtiff/tif_close.c` dereferences this NULL pointer when trying to access `tif->tif_closeproc` [ref_id=1].
What the fix does
The proposed patches address the issue at two levels. The `tiffcrop.c` patch ensures that when `update_output_file()` fails to open the output file, the code properly handles the error and avoids proceeding to `TIFFClose()` with a NULL pointer. The `tif_close.c` patch adds a NULL check at the entry of `TIFFClose()` so that if a NULL `TIFF*` is passed, the function returns early without dereferencing the pointer [ref_id=1]. Together, these changes prevent the NULL pointer dereference that caused the segmentation fault.
Preconditions
- inputAttacker must be able to invoke tiffcrop with the -Z (zones) option
- inputAttacker must supply an output file path that cannot be opened (e.g., non-existent path or /dev/null)
- inputAttacker must provide a valid TIFF input file
Reproduction
Clone the libtiff repository, build it, and run: `tools/tiffcrop -Z 1:1 empty.tif /non-existent-path`. This will produce a "Permission denied" error followed by a segmentation fault [ref_id=1]. Any valid TIFF file can be used as the input.
Generated on May 26, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
4News mentions
0No linked articles in our index yet.