Opened 5 months ago

#10756 new defect

heap-buffer-overflow at libavfilter/avf_showwaves.c:722:24 in showwaves_filter_frame 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 showwaves filter, please confirm.

The poc file(poc18ffmpeg) 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 poc18ffmpeg -filter_complex showwaves tmp.mp4

ASAN Log:

=================================================================
==4047481==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x609000007900 at pc 0x564cc679a50c bp 0x7f1a56bfae70 sp 0x7f1a56bfae68
WRITE of size 2 at 0x609000007900 thread T3 (fc0)
[aac @ 0x619000002d80] Too many bits 9613.061224 > 6144 per frame requested, clamping to max
    #0 0x564cc679a50b in showwaves_filter_frame /ffmpeg/libavfilter/avf_showwaves.c:722:24
    #1 0x564cc679a50b in activate /ffmpeg/libavfilter/avf_showwaves.c:788:16
    #2 0x564cc67a69e8 in ff_filter_activate /ffmpeg/libavfilter/avfilter.c:1340:38
    #3 0x564cc67b6870 in get_frame_internal /ffmpeg/libavfilter/buffersink.c:139:19
    #4 0x564cc67b4000 in avfilter_graph_request_oldest /ffmpeg/libavfilter/avfiltergraph.c:1306:17
    #5 0x564cc66ade64 in read_frames /ffmpeg/fftools/ffmpeg_filter.c:2431:15
    #6 0x564cc66a4948 in filter_thread /ffmpeg/fftools/ffmpeg_filter.c:2824:15
    #7 0x564cc66e84e8 in task_wrapper /ffmpeg/fftools/ffmpeg_sched.c:2200:21
    #8 0x7f1a59d17ac2  (/lib/x86_64-linux-gnu/libc.so.6+0x94ac2) (BuildId: 203de0ae33b53fee1578b117cb4123e85d0534f0)
    #9 0x7f1a59da965f  (/lib/x86_64-linux-gnu/libc.so.6+0x12665f) (BuildId: 203de0ae33b53fee1578b117cb4123e85d0534f0)

0x609000007901 is located 0 bytes to the right of 1-byte region [0x609000007900,0x609000007901)
allocated by thread T3 (fc0) here:
    #0 0x564cc664a107 in __interceptor_posix_memalign (/ffmpeg/ffmpeg_g+0x932107) (BuildId: bab21e45d9666c5cb0f3fbb9efc25079a5bb0a62)
    #1 0x564cc9cd0d30 in av_malloc /ffmpeg/libavutil/mem.c:105:9
    #2 0x564cc9cd0d30 in av_malloc /ffmpeg/libavutil/mem.c:144:14
    #3 0x564cc9cd0d30 in av_mallocz /ffmpeg/libavutil/mem.c:256:17
    #4 0x564cc9cd0d30 in av_calloc /ffmpeg/libavutil/mem.c:267:12
    #5 0x564cc679ab52 in config_output /ffmpeg/libavfilter/avf_showwaves.c:443:26
    #6 0x564cc67a2749 in avfilter_config_links /ffmpeg/libavfilter/avfilter.c:340:31

Thread T3 (fc0) created by T0 here:
    #0 0x564cc6632a0c in __interceptor_pthread_create (/ffmpeg/ffmpeg_g+0x91aa0c) (BuildId: bab21e45d9666c5cb0f3fbb9efc25079a5bb0a62)
    #1 0x564cc66e2a31 in task_start /ffmpeg/fftools/ffmpeg_sched.c:403:11
    #2 0x564cc6701738 in transcode /ffmpeg/fftools/ffmpeg.c:922:11
    #3 0x564cc6701738 in main /ffmpeg/fftools/ffmpeg.c:1050:11
    #4 0x7f1a59cacd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 203de0ae33b53fee1578b117cb4123e85d0534f0)

SUMMARY: AddressSanitizer: heap-buffer-overflow /ffmpeg/libavfilter/avf_showwaves.c:722:24 in showwaves_filter_frame
Shadow bytes around the buggy address:
  0x0c127fff8ed0: fa fa fa fa fa fa fa fa fd fd fd fd fa fa fa fa
  0x0c127fff8ee0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8ef0: fd fd fd fd fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8f00: 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8f10: 02 fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c127fff8f20:[01]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c127fff8f30: fa fa fa fa fa fa fa fa 04 fa fa fa fa fa fa fa
  0x0c127fff8f40: fa fa fa fa fa fa fa fa 00 fa fa fa fa fa fa fa
  0x0c127fff8f50: fa fa fa fa fa fa fa fa 00 00 00 fa fa fa fa fa
  0x0c127fff8f60: fa fa fa fa fa fa fa fa 00 fa fa fa fa fa fa fa
  0x0c127fff8f70: 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
  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
==4047481==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)

poc18ffmpeg (542 bytes ) - added by ZengYunxiang 5 months ago.
POC file

Download all attachments as: .zip

Change History (1)

by ZengYunxiang, 5 months ago

Attachment: poc18ffmpeg added

POC file

Note: See TracTickets for help on using tickets.