Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer Overflow at j2k.c:9614 #1530

Merged
merged 2 commits into from
May 31, 2024
Merged

Integer Overflow at j2k.c:9614 #1530

merged 2 commits into from
May 31, 2024

Conversation

headshog
Copy link
Contributor

Hi! I've been fuzzing openjpeg with sydr-fuzz security predicates and I found integer overflow error in j2k.c:9614.

In function opj_j2k_read_tile_header at line 9614 integer overflow occurs when value l_marker_size + 2 is subtracted from variable p_j2k->m_specific_param.m_decoder.m_sot_length and value from this variable is less than l_marker_size + 2. So here i decided just to add a checker for valid data.

Environment

How to reproduce this error

  1. Build docker container:

    sudo docker build -t oss-sydr-fuzz-openjpeg .
    
  2. Run docker container:

    sudo docker run --privileged --network host -v /etc/localtime:/etc/localtime:ro --rm -it -v $PWD:/fuzz oss-sydr-fuzz-openjpeg /bin/bash
    
  3. Run on the following input:

     /opj_decompress_fuzzer_JP2_fuzz sydr_j2k.txt
    
  4. Output:

    /home/ubuntu/headshog/openjpeg_build/openjpeg/src/lib/openjp2/j2k.c:9614:64: runtime error: unsigned integer overflow: 147 - 149 cannot be represented in type 'unsigned int'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ubuntu/headshog/openjpeg_build/openjpeg/src/lib/openjp2/j2k.c:9614:64
    

@rouault
Copy link
Collaborator

rouault commented May 31, 2024

the macos failure is unrelated and will be fixed per #1531

@rouault rouault merged commit 2c0823c into uclouvain:master May 31, 2024
11 of 12 checks passed
rouault added a commit to rouault/openjpeg that referenced this pull request Nov 13, 2024
The fix of 2c0823c (uclouvain#1530) broke
decoding of some JPEG2000 files where Isot==0, Psot==0, TPsot==0 and
TNsot==0 like the following ones from the GDAL autotest suite:
autotest/gdrivers/data/jpeg2000/stefan_full_rgba_alpha_1bit.jp2
autotest/gdrivers/data/jpeg2000/3_13bit_and_1bit.jp2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants