VYPR
Unrated severityNVD Advisory· Published Jun 19, 2023· Updated Nov 3, 2025

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.

CVE-2023-3316

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

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

4

News mentions

0

No linked articles in our index yet.