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:11114 #1491

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:11114.

In function opj_j2k_read_SQcd_SQcc at line 11114 integer overflow occurs in pointer's p_header_size value (in our case *p_header_size was 0 and l_num_band is 2). I've just added two checkers for that overflow case in both branches of if (l_tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) and it's else statement.

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

    /openjpeg/src/lib/openjp2/j2k.c:11114:41: runtime error: unsigned integer overflow: 0 - 2 cannot be represented in type 'unsigned int'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /openjpeg/src/lib/openjp2/j2k.c:11114:41
    

@rouault rouault merged commit 00e0bdc 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