Opened 12 months ago

Closed 12 months ago

Last modified 8 months ago

#10746 closed defect (fixed)

heap-buffer-overflow at libavfilter/af_stereowiden.c:120:69 in FFmpeg

Reported by: ZengYunxiang Owned by:
Priority: important Component: avfilter
Version: git-master Keywords: bugs
Cc: ZengYunxiang Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Dear developers,

We found the following heap-buffer-overflow bug on FFmpeg(version N-113007-g8d24a28d06) when using stereowiden filter, please confirm.

The poc file(poc13ffmpeg) will be attached to this ticket.

How to reproduce:

git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
./configure --cc=clang --cxx=clang++ --ld=clang --enable-debug --toolchain=clang-asan
make -j30

./ffmpeg_g -y -i poc13ffmpeg -filter_complex stereowiden tmp.mp4

ASAN Log:

=================================================================
==3559202==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x609000007e44 at pc 0x55867340ec8e bp 0x7f9fd90fc370 sp 0x7f9fd90fc368
READ of size 4 at 0x609000007e44 thread T2 (fc0)
    #0 0x55867340ec8d in filter_frame /ffmpeg/libavfilter/af_stereowiden.c:120:69
    #1 0x558672c35ed2 in ff_filter_frame_framed /ffmpeg/libavfilter/avfilter.c:969:11
    #2 0x558672c35ed2 in ff_filter_frame_to_filter /ffmpeg/libavfilter/avfilter.c:1123:11
    #3 0x558672c35ed2 in ff_filter_activate_default /ffmpeg/libavfilter/avfilter.c:1182:20
    #4 0x558672c35ed2 in ff_filter_activate /ffmpeg/libavfilter/avfilter.c:1341:11
    #5 0x558672c47f57 in push_frame /ffmpeg/libavfilter/buffersrc.c:168:15
    #6 0x558672c47f57 in av_buffersrc_add_frame_flags /ffmpeg/libavfilter/buffersrc.c:272:15
    #7 0x558672b35d3b in send_frame /ffmpeg/fftools/ffmpeg_filter.c:2668:11
    #8 0x558672b35d3b in filter_thread /ffmpeg/fftools/ffmpeg_filter.c:2808:19
    #9 0x558672b77c18 in task_wrapper /ffmpeg/fftools/ffmpeg_sched.c:2200:21
    #10 0x7f9fdbbe9ac2  (/lib/x86_64-linux-gnu/libc.so.6+0x94ac2) (BuildId: a43bfc8428df6623cd498c9c0caeb91aec9be4f9)
    #11 0x7f9fdbc7ba3f  (/lib/x86_64-linux-gnu/libc.so.6+0x126a3f) (BuildId: a43bfc8428df6623cd498c9c0caeb91aec9be4f9)

0x609000007e44 is located 3 bytes to the right of 1-byte region [0x609000007e40,0x609000007e41)
allocated by thread T2 (fc0) here:
    #0 0x558672adb697 in __interceptor_posix_memalign (/ffmpeg/ffmpeg_g+0x924697) (BuildId: 8d6ccf457a75d047d11f9627d0b67208c2215c8c)
    #1 0x558676144830 in av_malloc /ffmpeg/libavutil/mem.c:105:9
    #2 0x558676144830 in av_malloc /ffmpeg/libavutil/mem.c:144:14
    #3 0x558676144830 in av_mallocz /ffmpeg/libavutil/mem.c:256:17
    #4 0x558676144830 in av_calloc /ffmpeg/libavutil/mem.c:267:12
    #5 0x55867340edab in config_input /ffmpeg/libavfilter/af_stereowiden.c:77:17

Thread T2 (fc0) created by T0 here:
    #0 0x558672ac3f9c in __interceptor_pthread_create (/ffmpeg/ffmpeg_g+0x90cf9c) (BuildId: 8d6ccf457a75d047d11f9627d0b67208c2215c8c)
    #1 0x558672b72161 in task_start /ffmpeg/fftools/ffmpeg_sched.c:403:11
    #2 0x558672b90e68 in transcode /ffmpeg/fftools/ffmpeg.c:922:11
    #3 0x558672b90e68 in main /ffmpeg/fftools/ffmpeg.c:1050:11
    #4 0x7f9fdbb7ed8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: a43bfc8428df6623cd498c9c0caeb91aec9be4f9)

SUMMARY: AddressSanitizer: heap-buffer-overflow /ffmpeg/libavfilter/af_stereowiden.c:120:69 in filter_frame
Shadow bytes around the buggy address:
  0x0c127fff8f70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8f80: 00 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8f90: 04 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8fa0: 00 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8fb0: 04 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c127fff8fc0: fa fa fa fa fa fa fa fa[01]fa fa fa fa fa fa fa
  0x0c127fff8fd0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 fa fa
  0x0c127fff8fe0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 fa fa
  0x0c127fff8ff0: fa fa fa fa fa fa fa fa 00 fa fa fa fa fa fa fa
  0x0c127fff9000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff9010: 00 00 00 00 00 00 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3559202==ABORTING

ffmpeg version:

# ./ffmpeg -version
ffmpeg version N-113007-g8d24a28d06 Copyright (c) 2000-2023 the FFmpeg developers
built with Ubuntu clang version 14.0.0-1ubuntu1.1
configuration: --cc=clang --cxx=clang++ --ld=clang --enable-debug --toolchain=clang-asan
libavutil      58. 34.100 / 58. 34.100
libavcodec     60. 35.100 / 60. 35.100
libavformat    60. 18.100 / 60. 18.100
libavdevice    60.  4.100 / 60.  4.100
libavfilter     9. 14.100 /  9. 14.100
libswscale      7.  6.100 /  7.  6.100
libswresample   4. 13.100 /  4. 13.100

Credit:

Discovered by Zeng Yunxiang.

Thanks for your time!

Attachments (1)

poc13ffmpeg (468 bytes ) - added by ZengYunxiang 12 months ago.
POC file

Download all attachments as: .zip

Change History (3)

by ZengYunxiang, 12 months ago

Attachment: poc13ffmpeg added

POC file

comment:1 by Michael Niedermayer, 12 months ago

Resolution: fixed
Status: newclosed

comment:2 by Dominik Mierzejewski, 8 months ago

Could you backport this to 6.1?

Note: See TracTickets for help on using tickets.