Project: libsndfile (libsndfile/libsndfile), language: c++
Vulnerability instance: libsndfile.cve-2018-19758
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: Red Hat Bugzilla
## URL: https://bugzilla.redhat.com/show_bug.cgi?id=1643812
## Description:
Bugzilla ID: 1643812
Title: There is a heap-buffer-overflow on address 0x61200000be50 in libsndfile.

Description
shuitao gan 2018-10-29 04:02:33 UTC
Created attachment 1498401 [details]
Trigger by "./sndfile-convert  POC0"

version: libsndfile
Summary: 

There is a heap-buffer-overflow on address 0x61200000be50 in libsndfile.

Description:

The asan debug is as follows:

$./sndfile-convert POC0 a.wav

==122624==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61200000be50 at pc 0x5e96a0 bp 0x7ffd57e9efb0 sp 0x7ffd57e9efa8
READ of size 4 at 0x61200000be50 thread T0
==122624==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
    #0 0x5e969f (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x5e969f)
    #1 0x4cb046 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x4cb046)
    #2 0x4863e9 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x4863e9)
    #3 0x483b5e (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x483b5e)
    #4 0x7f2ec5cf6a3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #5 0x47ede8 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x47ede8)

0x61200000be50 is located 0 bytes to the right of 272-byte region [0x61200000bd40,0x61200000be50)
allocated by thread T0 here:
    #0 0x468dc9 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x468dc9)
    #1 0x66ce6d (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x66ce6d)
    #2 0x4ad66f (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x4ad66f)
    #3 0x485384 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x485384)
    #4 0x483690 (/home/company/real_sanitize/poc_check/libsndfile/sndfile-convert_addr+0x483690)
    #5 0x7f2ec5cf6a3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 ??
Shadow bytes around the buggy address:
  0x0c247fff9770: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c247fff9780: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c247fff9790: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c247fff97a0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c247fff97b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c247fff97c0: 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa
  0x0c247fff97d0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c247fff97e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c247fff97f0: 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa fa
  0x0c247fff9800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c247fff9810: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==122624==ABORTING




$./sndfile-convert POC0 a.wav
Segmentation fault


Comments:
Comment 2
shuitao gan 2018-10-29 04:03:37 UTC
version 1.0.28

---

Comment 3
Rahul Joshi 2018-12-16 10:40:51 UTC
Which version of libsndfile made this crash.
Actually, I didn't get crash in version "libsndfile-1.0.28".
Could u please explain this?
Ref: https://nvd.nist.gov/vuln/detail/CVE-2018-19758

Thanks in advance.

---

Comment 4
Rahul Joshi 2018-12-16 10:46:33 UTC
I downloaded the version from this Github resource as follow.
https://github.com/erikd/libsndfile/releases (1.0.28)

---

Comment 5
Rahul Joshi 2018-12-16 11:07:00 UTC
I got the crash now and Sry for the noise in the channel.
Thanks

---

Comment 7
Michal Hlavinka 2020-06-10 10:21:18 UTC
The Red Hat Enterprise Linux 7 life cycle has entered Maintenance Support Phase, which means that only qualified Critical and Important Security errata advisories (RHSAs) and some Urgent Priority Bug Fix errata advisories (RHBAs) will be released as they become available.  Unfortunately, this issue was not selected to be included in Red Hat Enterprise Linux 7. We will now close this issue. We recommend moving the request to Red Hat Enterprise Linux 8 if applicable.

See the Red Hat Enterprise Linux Life Cycle for more details:
https://access.redhat.com/support/policy/updates/errata/

Attachments:
Attachment 1498401: Trigger by "./sndfile-convert POC0" [Link: https://bugzilla.redhat.com/attachment.cgi?id=1498401]

Build script:
#!/bin/bash
# Default build script template for C/C++ projects
set -eu

# Define configuration options
CONFIG_OPTS="--disable-shared"
CMAKE_OPTS="-DCMAKE_BUILD_TYPE=Debug"
MAKE_OPTS="-j$(nproc)"
BUILD_DIR="build"

# 1. Run build preparation scripts if they exist
for prep_script in buildconf autogen.sh bootstrap; do
  if [ -x "$prep_script" ]; then
    echo "Running $prep_script..."
    ./$prep_script
    break
  elif [ -f "$prep_script" ]; then
    echo "Found $prep_script but it's not executable, setting permissions..."
    chmod +x $prep_script
    ./$prep_script
    break
  fi
done

# 2. Handle different build systems
if [ -f "configure" ]; then
  echo "Found configure script, running with options: $CONFIG_OPTS"
  ./configure $CONFIG_OPTS

  echo "Building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "CMakeLists.txt" ]; then
  echo "Found CMakeLists.txt, using CMake build system"
  mkdir -p $BUILD_DIR
  cd $BUILD_DIR
  cmake $CMAKE_OPTS ..
  make $MAKE_OPTS
elif [ -f "Makefile" ] || [ -f "makefile" ]; then
  echo "Found Makefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "meson.build" ]; then
  echo "Found meson.build, using Meson build system"
  mkdir -p $BUILD_DIR
  meson setup $BUILD_DIR .
  cd $BUILD_DIR
  ninja
elif [ -f "GNUmakefile" ]; then
  echo "Found GNUmakefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -d ".git" ] && [ -f "Makefile.am" ]; then
  echo "Found Makefile.am, running autoreconf"
  autoreconf -i
  ./configure $CONFIG_OPTS
  make $MAKE_OPTS
else
  echo "WARNING: No recognized build system found!"
  echo "Trying generic approach:"
  
  # Try to detect common source patterns and compile them
  if ls *.c >/dev/null 2>&1 || ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
    echo "Found C/C++ source files, attempting direct compilation"
    if ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
      CXX=${CXX:-g++}
      echo "Compiling C++ sources with $CXX"
      $CXX -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.cpp *.cc 2>/dev/null || true
    elif ls *.c >/dev/null 2>&1; then
      CC=${CC:-gcc}
      echo "Compiling C sources with $CC"
      $CC -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.c 2>/dev/null || true
    fi
  fi
fi

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN git clone https://github.com/libsndfile/libsndfile libsndfile
RUN git -C libsndfile checkout 1d928bffdb65e827c3e7d17ece0e123b4a70ec6c
WORKDIR $SRC/libsndfile
COPY build.sh $SRC/

Additional files: