VYPR
Unrated severityNVD Advisory· Published Oct 21, 2022· Updated May 7, 2025

CVE-2022-3627

CVE-2022-3627

Description

LibTIFF 4.4.0 has an out-of-bounds write in _TIFFmemcpy in libtiff/tif_unix.c:346 when called from extractImageSection, tools/tiffcrop.c:6860, allowing attackers to cause a denial-of-service via a crafted tiff file. For users that compile libtiff from sources, the fix is available with commit 236b7191.

AI Insight

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

Affected products

45

Patches

Vulnerability mechanics

Root cause

"Missing input validation in `process_command_opts` allows mutually exclusive crop and page-mode options to be combined, leading to an undersized buffer allocation and a subsequent heap-buffer-overflow in `_TIFFmemcpy`."

Attack vector

An attacker supplies a crafted TIFF file and invokes `tiffcrop` with a combination of mutually exclusive options — specifically, any of `-X`, `-Y`, `-Z`, or `-z` together with other `PAGE_MODE_x` options such as `-H`, `-V`, `-P`, `-J`, or `-K` [ref_id=2]. The reproducer uses `tiffcrop -Z 1:4,3:3 -R 90 -H 300 -i poc2 /tmp/foo` [ref_id=1]. The tool reads the malformed image, allocates a buffer based on incorrect size calculations, and then `_TIFFmemcpy` writes beyond the allocated heap region, causing a heap-buffer-overflow [ref_id=1]. No authentication or special network access is required; the attacker only needs to deliver the crafted file to a victim who runs `tiffcrop` on it.

Affected code

The out-of-bounds write occurs in `_TIFFmemcpy` at `libtiff/tif_unix.c:346`, called from `extractImageSection` at `tools/tiffcrop.c:6860` [ref_id=1]. The allocation is performed by `limitMalloc` at `tools/tiffcrop.c:627` during `loadImage` at `tools/tiffcrop.c:6220` [ref_id=1]. The patch adds a validation check in `process_command_opts` at `tools/tiffcrop.c:2143` to reject unsafe option combinations before they reach the image-processing code [ref_id=2].

What the fix does

The commit [ref_id=2] adds a new validation block in `process_command_opts` that checks whether any of the crop options (`-X`, `-Y`, `-Z`, `-z`) are active together with other `PAGE_MODE_x` options (such as `-H`, `-V`, `-P`, `-J`, `-K`). If such a combination is detected, the program prints an error and exits immediately with `EXIT_FAILURE`. The patch also updates all documentation strings (the file header comment, the `usage_info` string, and the `tiffcrop` man page) with a new "Note 2" explicitly warning that these option combinations are unsupported and may cause buffer overflows [ref_id=2]. By rejecting the dangerous option combination at the argument-parsing stage, the fix prevents the corrupted state that led to the heap-buffer-overflow in `extractImageSection`.

Preconditions

  • inputVictim must run tiffcrop with a combination of -X/-Y/-Z/-z and -H/-V/-P/-J/-K options on the attacker-supplied file.
  • inputThe crafted TIFF file must trigger the malformed internal state that leads to the incorrect buffer allocation.

Reproduction

1. Build libtiff with AddressSanitizer: `CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" CXXFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" ./configure --prefix=$PWD/build_asan --disable-shared && make -j && make install` [ref_id=1]. 2. Obtain the PoC file `poc2` from the issue attachment [ref_id=1]. 3. Run: `./build_asan/bin/tiffcrop -Z 1:4,3:3 -R 90 -H 300 -i poc2 /tmp/foo` [ref_id=1]. 4. Observe the AddressSanitizer heap-buffer-overflow report at `_TIFFmemcpy` in `tif_unix.c:346` [ref_id=1].

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

References

6

News mentions

0

No linked articles in our index yet.