Headline
CVE-2023-24754: NULL Pointer Dereference in function ff_hevc_put_weighted_pred_avg_8_sse at sse-motion.cc:237 · Issue #382 · strukturag/libde265
libde265 v1.0.10 was discovered to contain a NULL pointer dereference in the ff_hevc_put_weighted_pred_avg_8_sse function at sse-motion.cc. This vulnerability allows attackers to cause a Denial of Service (DoS) via a crafted input file.
Description
NULL Pointer Dereference in function ff_hevc_put_weighted_pred_avg_8_sse at sse-motion.cc:237
Version
git log
commit 7ea8e3cbb010bc02fa38419e87ed2281d7933850 (HEAD -> master, origin/master, origin/HEAD)
Author: Dirk Farin <[email protected]>
Date: Sat Jan 28 15:03:34 2023 +0100
Steps to reproduce
git clone https://github.com/strukturag/libde265.git
cd libde265
./autogen.sh
export CFLAGS="-g -O0 -lpthread -fsanitize=address"
export CXXFLAGS="-g -O0 -lpthread -fsanitize=address"
export LDFLAGS="-fsanitize=address"
./configure --disable-shared
make -j
cd dec265
./dec265 ./poc_segv05.bin
WARNING: non-existing PPS referenced
WARNING: non-existing PPS referenced
WARNING: non-existing PPS referenced
WARNING: CTB outside of image area (concealing stream error...)
WARNING: CTB outside of image area (concealing stream error...)
WARNING: CTB outside of image area (concealing stream error...)
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3328352==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x55555570c29d bp 0x7ffffffe28c0 sp 0x7ffffffe24d0 T0)
==3328352==The signal is caused by a WRITE memory access.
==3328352==Hint: address points to the zero page.
#0 0x55555570c29c in _mm_storeu_si128(long long __vector(2)*, long long __vector(2)) /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:727
#1 0x55555570c29c in ff_hevc_put_weighted_pred_avg_8_sse(unsigned char*, long, short const*, short const*, long, int, int) /home/fuzz/libde265/libde265/x86/sse-motion.cc:237
#2 0x5555557b9c19 in acceleration_functions::put_weighted_pred_avg(void*, long, short const*, short const*, long, int, int, int) const ../libde265/acceleration.h:249
#3 0x5555557a1a6a in generate_inter_prediction_samples(base_context*, slice_segment_header const*, de265_image*, int, int, int, int, int, int, int, PBMotion const*) /home/fuzz/libde265/libde265/motion.cc:544
#4 0x5555557b973e in decode_prediction_unit(base_context*, slice_segment_header const*, de265_image*, PBMotionCoding const&, int, int, int, int, int, int, int, int) /home/fuzz/libde265/libde265/motion.cc:2155
#5 0x555555683316 in read_prediction_unit(thread_context*, int, int, int, int, int, int, int, int, int) /home/fuzz/libde265/libde265/slice.cc:4136
#6 0x5555556878c1 in read_coding_unit(thread_context*, int, int, int, int) /home/fuzz/libde265/libde265/slice.cc:4497
#7 0x555555689e17 in read_coding_quadtree(thread_context*, int, int, int, int) /home/fuzz/libde265/libde265/slice.cc:4652
#8 0x555555672a97 in read_coding_tree_unit(thread_context*) /home/fuzz/libde265/libde265/slice.cc:2861
#9 0x55555568af7b in decode_substream(thread_context*, bool, bool) /home/fuzz/libde265/libde265/slice.cc:4741
#10 0x55555568ea3f in read_slice_segment_data(thread_context*) /home/fuzz/libde265/libde265/slice.cc:5054
#11 0x55555558c205 in decoder_context::decode_slice_unit_sequential(image_unit*, slice_unit*) /home/fuzz/libde265/libde265/decctx.cc:852
#12 0x55555558d6c0 in decoder_context::decode_slice_unit_parallel(image_unit*, slice_unit*) /home/fuzz/libde265/libde265/decctx.cc:954
#13 0x55555558a7dc in decoder_context::decode_some(bool*) /home/fuzz/libde265/libde265/decctx.cc:739
#14 0x555555589efc in decoder_context::read_slice_NAL(bitreader&, NAL_unit*, nal_header&) /home/fuzz/libde265/libde265/decctx.cc:697
#15 0x55555559070e in decoder_context::decode_NAL(NAL_unit*) /home/fuzz/libde265/libde265/decctx.cc:1239
#16 0x555555592354 in decoder_context::decode(int*) /home/fuzz/libde265/libde265/decctx.cc:1327
#17 0x55555557cffa in de265_decode /home/fuzz/libde265/libde265/de265.cc:362
#18 0x555555577b2f in main /home/fuzz/libde265/dec265/dec265.cc:764
#19 0x7ffff7046082 in __libc_start_main ../csu/libc-start.c:308
#20 0x5555555712ed in _start (/home/fuzz/libde265/dec265/dec265+0x1d2ed)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:727 in _mm_storeu_si128(long long __vector(2)*, long long __vector(2))
==3328352==ABORTING
POC
poc_segv05.bin
GDB
gdb --args ./dec265 ./poc_segv05.bin
─── Output/messages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
WARNING: non-existing PPS referenced
WARNING: non-existing PPS referenced
WARNING: non-existing PPS referenced
WARNING: CTB outside of image area (concealing stream error...)
WARNING: CTB outside of image area (concealing stream error...)
WARNING: CTB outside of image area (concealing stream error...)
Program received signal SIGSEGV, Segmentation fault.
0x000055555570c29d in _mm_storeu_si128(long long __vector(2)*, long long __vector(2)) (__B=..., __P=0x0) at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:727
727 *__P = __B;
─── Assembly ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0x000055555570c281 _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+101 mov $0x10,%esi
0x000055555570c286 _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+106 mov %rdx,%rdi
0x000055555570c289 _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+109 callq 0x555555571040 <__asan_report_store_n@plt>
0x000055555570c28e _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+114 movdqa -0x250(%rbp),%xmm0
0x000055555570c296 _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+122 mov -0x380(%rbp),%rdx
0x000055555570c29d _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+129 movups %xmm0,(%rdx)
0x000055555570c2a0 _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+132 nop
~
~
~
─── Breakpoints ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Expressions ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── History ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Memory ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─── Registers ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
rax 0x000055555581d520 rbx 0x00007ffffffeed20 rcx 0x0000000000000000 rdx 0x0000000000000000 rsi 0x0000000000000007 rdi 0x0000000000000000 rbp 0x00007ffffffe2870 rsp 0x00007ffffffe2480
r8 0x0000000000000000 r9 0x0000000000000040 r10 0x0000000000000040 r11 0x0000000000000040 r12 0x000055555581d520 r13 0x0000000000000010 r14 0x00000fffffffc54c r15 0x00007ffffffe2a60
rip 0x000055555570c29d eflags [ PF ZF IF RF ] cs 0x00000033 ss 0x0000002b ds 0x00000000 es 0x00000000 fs 0x00000000 gs 0x00000000
─── Source ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
722 }
723
724 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
725 _mm_storeu_si128 (__m128i_u *__P, __m128i __B)
726 {
727 *__P = __B;
728 }
729
730 extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
731 _mm_storel_epi64 (__m128i_u *__P, __m128i __B)
─── Stack ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[0] from 0x000055555570c29d in _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+129 at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:727
[1] from 0x000055555570c29d in ff_hevc_put_weighted_pred_avg_8_sse(unsigned char*, long, short const*, short const*, long, int, int)+1711 at sse-motion.cc:237
[2] from 0x00005555557b9c1a in acceleration_functions::put_weighted_pred_avg(void*, long, short const*, short const*, long, int, int, int) const+282 at ../libde265/acceleration.h:249
[3] from 0x00005555557a1a6b in generate_inter_prediction_samples(base_context*, slice_segment_header const*, de265_image*, int, int, int, int, int, int, int, PBMotion const*)+18639 at motion.cc:544
[4] from 0x00005555557b973f in decode_prediction_unit(base_context*, slice_segment_header const*, de265_image*, PBMotionCoding const&, int, int, int, int, int, int, int, int)+496 at motion.cc:2155
[5] from 0x0000555555683317 in read_prediction_unit(thread_context*, int, int, int, int, int, int, int, int, int)+2790 at slice.cc:4136
[6] from 0x00005555556878c2 in read_coding_unit(thread_context*, int, int, int, int)+14437 at slice.cc:4497
[7] from 0x0000555555689e18 in read_coding_quadtree(thread_context*, int, int, int, int)+3873 at slice.cc:4652
[8] from 0x0000555555672a98 in read_coding_tree_unit(thread_context*)+1351 at slice.cc:2861
[9] from 0x000055555568af7c in decode_substream(thread_context*, bool, bool)+4333 at slice.cc:4741
[+]
─── Threads ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[1] id 3335404 name dec265 from 0x000055555570c29d in _mm_storeu_si128(long long __vector(2)*, long long __vector(2))+129 at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:727
─── Variables ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
arg __B = {[0] = 0, [1] = 0}, __P = 0x0: Cannot access memory at address 0x0
loc x = 0, y = 0, dst = 0x0: Cannot access memory at address 0x0, r0 = {[0] = 0, [1] = 0}, r1 = {[0] = 0, [1] = 0}, f0 = {[0] = 18014673391583296, [1] = 18014673391583296}, r2 = {[0] = 0, [1] = 0}, r3 = {[0] = 0, [1] = 0}
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>>>
Impact
This vulnerability is capable of crashing software, causing a denial of service via a crafted input file.
Related news
Gentoo Linux Security Advisory 202408-20 - Multiple vulnerabilities have been discovered in libde265, the worst of which could lead to arbitrary code execution. Versions greater than or equal to 1.0.11 are affected.
Ubuntu Security Notice 6659-1 - It was discovered that libde265 could be made to write out of bounds. If a user or automated system were tricked into opening a specially crafted file, an attacker could possibly use this issue to cause a denial of service or execute arbitrary code. It was discovered that libde265 could be made to read out of bounds. If a user or automated system were tricked into opening a specially crafted file, an attacker could possibly use this issue to cause a denial of service.