VYPR
Unrated severityNVD Advisory· Published Feb 13, 2023· Updated Mar 21, 2025

CVE-2023-0797

CVE-2023-0797

Description

LibTIFF 4.4.0 has an out-of-bounds read in tiffcrop in libtiff/tif_unix.c:368, invoked by tools/tiffcrop.c:2903 and tools/tiffcrop.c:6921, 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 afaabc3e.

AI Insight

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

Affected products

20

Patches

Vulnerability mechanics

Root cause

"Missing guard on image parameter swapping in rotateImage() causes width/length mismatch, leading to out-of-bounds read in _TIFFmemcpy."

Attack vector

An attacker supplies a crafted TIFF file with malformed strip offsets/byte counts and invokes tiffcrop with rotation (-R 270) and extraction (-e multiple -z) options [ref_id=2]. The tool calls extractSeparateRegion (tiffcrop.c:6921) which copies pixel data via extractContigSamplesBytes (tiffcrop.c:2903), ultimately reaching _TIFFmemcpy (tif_unix.c:368) with a corrupted buffer size [ref_id=2]. The out-of-bounds read causes a SEGV, resulting in denial-of-service [ref_id=2].

Affected code

The out-of-bounds read occurs in `_TIFFmemcpy` at `libtiff/tif_unix.c:368`, reached via `extractContigSamplesBytes` at `tools/tiffcrop.c:2903` and `extractSeparateRegion` at `tools/tiffcrop.c:6921` [ref_id=2]. The root cause is in `rotateImage()` (tools/tiffcrop.c) which unconditionally swapped `image->width` and `image->length` before the patch [ref_id=1].

What the fix does

The patch [ref_id=1] adds a `rot_image_params` parameter to `rotateImage()` and only swaps `image->width`/`image->length` (and xres/yres) when this flag is TRUE. Previously, `rotateImage()` unconditionally updated `image->width` and `image->length` even when rotating a sub-region (not the whole image), causing downstream code to use mismatched dimensions. The callers in `correct_orientation`, `processCropSelections`, and `createCroppedImage` now pass TRUE or FALSE as appropriate, preventing the width/length corruption that led to the out-of-bounds read.

Preconditions

  • inputAttacker must provide a crafted TIFF file with invalid strip offsets/byte counts
  • configVictim must run tiffcrop with -R 270 (rotation) and -e multiple -z (extraction) options

Reproduction

Build with AddressSanitizer (`CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" ./configure --prefix=$PWD/build_asan --disable-shared; make -j; make install`). Run: `./build_asan/bin/tiffcrop -e multiple -z 1,1,2048,2048:1,2049,2048,4097 -R 270 -i poc /tmp/foo` using the attached poc.zip [ref_id=2].

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.