Skip to content

Integer Overflow in num_images #1338

Closed
@NigelX

Description

Hello openjpeg2 team,
I found an integer overflow vulnerability in the command line options.

-ImgDir

If there are many files in the imgdir directory The number of files read by opj_compress will overflow.

openjpeg2(tested with revision * master 0bda718).

run commd

./opj_compress -ImgDir testcase/ -OutFor outcase/t.jp2 

asan info

Folder opened successfully
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==1852564==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000001183310 (pc 0x7ffff764cefa bp 0x0000000fffff sp 0x7fffffff3988 T1852564)
==1852564==The signal is caused by a WRITE memory access.
    #0 0x7ffff764cefa  /build/glibc-eX1tMB/glibc-2.31/string/../sysdeps/x86_64/multiarch/strcpy-avx2.S:630
    #1 0x42d9a5 in load_images /home/test/Downloads/openjpeg/src/bin/jp2/opj_compress.c:508:9
    #2 0x429366 in main /home/test/Downloads/openjpeg/src/bin/jp2/opj_compress.c:1924:13
    #3 0x7ffff74e70b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #4 0x408c7d in _start (/home/test/Downloads/openjpeg/fast_build64/bin/opj_compress+0x408c7d)

UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV /build/glibc-eX1tMB/glibc-2.31/string/../sysdeps/x86_64/multiarch/strcpy-avx2.S:630 
==1852564==ABORTING

image1

When num_images is equal to 1048576, multiplying with OPJ_PATH_LEN will produce an overflow result of 0

poc.zip


HX from Topsec alpha Security Team

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions