Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEGV libheif/libheif/exif.cc:55 in read16 #1043

Closed
fdu-sec opened this issue Nov 22, 2023 · 2 comments
Closed

SEGV libheif/libheif/exif.cc:55 in read16 #1043

fdu-sec opened this issue Nov 22, 2023 · 2 comments

Comments

@fdu-sec
Copy link

fdu-sec commented Nov 22, 2023

Description

SEGV libheif/libheif/exif.cc:55 in read16

Version

 heif-convert  libheif version: 1.17.5
-------------------------------------------
Usage: heif-convert [options]  <input-image> [output-image]

The program determines the output file format from the output filename suffix.
These suffixes are recognized: jpg, jpeg, png, y4m. If no output filename is specified, 'jpg' is used.

Options:
  -h, --help                     show help
  -v, --version                  show version
  -q, --quality                  quality (for JPEG output)
  -o, --output FILENAME          write output to FILENAME (optional)
  -d, --decoder ID               use a specific decoder (see --list-decoders)
      --with-aux                 also write auxiliary images (e.g. depth images)
      --with-xmp                 write XMP metadata to file (output filename with .xmp suffix)
      --with-exif                write EXIF metadata to file (output filename with .exif suffix)
      --skip-exif-offset         skip EXIF metadata offset bytes
      --no-colons                replace ':' characters in auxiliary image filenames with '_'
      --list-decoders            list all available decoders (built-in and plugins)
      --quiet                    do not output status messages to console
  -C, --chroma-upsampling ALGO   Force chroma upsampling algorithm (nn = nearest-neighbor / bilinear)
      --png-compression-level #  Set to integer between 0 (fastest) and 9 (best). Use -1 for default.

Replay

cd libheif
mkdir build && cd build
CC="gcc -fsanitize=address" CXX="g++ -fsanitize=address" cmake --preset=release ..
make -j
./examples/heif-convert ./poc test.png

ASAN

==1926429==ERROR: AddressSanitizer: SEGV on unknown address 0x60b080000729 (pc 0x55abe2b1012c bp 0x000000000000 sp 0x7ffe0b2df5a0 T0)
==1926429==The signal is caused by a READ memory access.
    #0 0x55abe2b1012c in read16 /eva/put/libheif/libheif/exif.cc:55
    #1 0x55abe2b1012c in find_exif_tag /eva/put/libheif/libheif/exif.cc:103
    #2 0x55abe2b1136b in modify_exif_tag_if_it_exists(unsigned char*, int, unsigned short, unsigned short) /eva/put/libheif/libheif/exif.cc:124
    #3 0x55abe2b1136b in modify_exif_orientation_tag_if_it_exists(unsigned char*, int, unsigned short) /eva/put/libheif/libheif/exif.cc:140
    #4 0x55abe2b16c75 in PngEncoder::Encode(heif_image_handle const*, heif_image const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /eva/put/libheif/examples/encoder_png.cc:126
    #5 0x55abe2b00c99 in main /eva/put/libheif/examples/heif_convert.cc:509
    #6 0x7fb15dc29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #7 0x7fb15dc29e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #8 0x55abe2b09254 in _start (/eva/asan-bin/NestFuzz/libheif/heif-convert+0x15254)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /eva/put/libheif/libheif/exif.cc:55 in read16
==1926429==ABORTING

POC

poc

Environment

Description:	Ubuntu 22.04.2 LTS
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Credit

Yuchuan Meng (Fudan University)

bradh added a commit to bradh/libheif that referenced this issue Nov 30, 2023
@bradh
Copy link
Contributor

bradh commented Nov 30, 2023

A fix for this is in work.

bradh added a commit to bradh/libheif that referenced this issue Dec 1, 2023
bradh added a commit to bradh/libheif that referenced this issue Dec 1, 2023
bradh added a commit to bradh/libheif that referenced this issue Dec 1, 2023
bradh added a commit to bradh/libheif that referenced this issue Dec 1, 2023
@carnil
Copy link

carnil commented Dec 7, 2023

This seems to be CVE-2023-49462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants