-
Notifications
You must be signed in to change notification settings - Fork 466
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
sprintf buffer overflow #1088
Comments
This is indeed a problem, when appropriate binary is built (-DBUILD_MJ2=On).
|
This uses snprintf() with correct buffer length instead of sprintf(). This prevents a buffer overflow when providing a long output prefix. Furthermore the program exits with an error when the provided output prefix is too long. Fixes uclouvain#1088.
This uses snprintf() with correct buffer length instead of sprintf(). This prevents a buffer overflow when providing a long output prefix. Furthermore the program exits with an error when the provided output prefix is too long. Fixes uclouvain#1088.
This uses snprintf() with correct buffer length instead of sprintf(), which prevents a buffer overflow when providing a long output prefix. Furthermore the program exits with an error when the provided output prefix is too long. Fixes uclouvain#1088.
This has been assigned CVE-2018-7648 |
Hi @kbabioch , is it possible to publish the file Speedway.mj2 for completeness? |
Hi @OrenGitHub, here you go: Speedway.mj2.tar.gz. Unfortunately I had to put it into an tarball, as GitHub does not support this filetype. |
Thanks, it works. I apologize for being greedy, but would it be possible to upload a file with just 1 frame instead of 200? from the CVE point of view, a minimal example is best, and the overflow occurs in the very first iteration in:
(I've tried editing the file with bless, but can't seem to find the 200 frames number) |
The file is really not relevant here. The buffer overflow affects the CLI parameter processing, not the image handling itself. |
I agree, but for example, if the mj2 file has incorrect format, then the buffer overflow statement might not be executed. I'm trying to synthesize the smallest legal mj2 file that will enable the execution of the buffer overflow statement:
|
I've tried manually editing the *.mj2 file (to make it smaller but still valid) but I keep getting:
Which means I'm somehow breaking its validity ... any advice? thanks! |
@setharnold, @kbabioch, @OrenGitHub, the simplest patch follows:
@OrenGitHub , |
I'm analyzing the openjpeg package with symbolic execution (SE). |
The size of the minimal (legal) *.mj2 file is a measure for how difficult
it will be for the SE engine to find
an *.mj2 file. I agree with previous posts that say that the file itself is
irrelevant -- however, it does have to be a legal *.mj2 file, otherwise the
sprintf statement won't be reached ...
Oren, if you have a crashing input already that you would like to make
smaller, try the afl-tmin tool from the AFL suite of programs. It can
minimize test cases so that they still crash or still succeed, one of which
might be useful to you here. (AFL has another tool that can help annotate
the meaning behind bytes in an input file but I've never tried it on
something this complicated before, just toys. Maybe once you've got a
smaller example you might have luck with it.)
Thanks
|
do you want to test the validity of the file BEFORE calling 'opj_mj2_extract'? Normally the validity is checked in
which you can find in 'src/lib/openmj2/mj2.c' Here are two tests:
winfried |
@szukw000 no, I'm interested in the smallest *.mj2 file that will pass all the sanity checks from your post ... like MOOV box etc. ... |
@OrenGitHub , |
Thank you very much @szukw000 !!! this is what I was looking for !! |
openjpeg/src/bin/mj2/opj_mj2_extract.c
Line 143 in 06f7d41
Hello, it looks like this
sprintf(3)
could overflow the buffer that is supplied for it.Thanks
The text was updated successfully, but these errors were encountered: