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:3962 #1490

Merged
merged 1 commit into from
Dec 8, 2023
Merged

Conversation

headshog
Copy link
Contributor

@headshog headshog commented Dec 6, 2023

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

In function opj_j2k_merge_ppm at line 3962 integer overflow occurs in variable l_ppm_data_size (the value of l_N_ppm was 4294967295). Also there is a comment that says it can't overflow, but l_N_ppm (returned from opj_read_bytes) turned out to be too big. So I've just added a checked for that overflow, but maybe it is also possible to check for its validity in opj_read_byte.

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_J2K_fuzz  sydr_j2k_data.txt
    
  4. Output:

    /openjpeg/src/lib/openjp2/j2k.c:3962:37: runtime error: unsigned integer overflow: 1150 + 4294967295 cannot be represented in type 'unsigned int'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /openjpeg/src/lib/openjp2/j2k.c:3962:37
    

@rouault rouault merged commit 49c4ef5 into uclouvain:master Dec 8, 2023
12 checks passed
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