-
Notifications
You must be signed in to change notification settings - Fork 282
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
Heap-buffer-overflow and OOB memory access in src/jp2image.cpp:359:77 #1522
Comments
Please provide a proper description of how you produced this error and your input file. Please provide:
We have discontinued the 'master' branch and renamed it 'old-master'. We are planning to ship v0.27.4 from branch 0.27-maintenance on 2021-04-30. If we can accurately identify and reproduce your report, a fix is likely to be included in the release. |
Hi @clanmills
In poc It only allocate 1 byte by |
Thank you for getting back to me. And thank you for providing accurate details to reproduce your report. I can confirm I have reproduced this on branch 0.27-maintenance and hope to provide you with a patch later today. I will delay releasing Exiv2 v0.27.4 RC2 to ensure we reach closure on this issue. |
diff --git a/src/jp2image.cpp b/src/jp2image.cpp
index eb31cea4..f10bbc44 100644
--- a/src/jp2image.cpp
+++ b/src/jp2image.cpp
@@ -353,7 +353,7 @@ static void boxes_check(size_t b,size_t m)
if (io_->error()) throw Error(kerFailedToReadImageData);
if (bufRead != rawData.size_) throw Error(kerInputDataReadFailed);
- if (rawData.size_ > 0)
+ if (rawData.size_ > 8) // "II*\0long"
{
// Find the position of Exif header in bytes array.
long pos = ( (rawData.pData_[0] == rawData.pData_[1]) And when I run your file: 1581 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance/build $ exiv2 ~/Downloads/poc.jpg
Warning: Failed to decode Exif metadata.
File name : /Users/rmills/Downloads/poc.jpg
File size : 268 Bytes
MIME type : image/jp2
Image size : 0 x 0
/Users/rmills/Downloads/poc.jpg: No Exif data found in the file
1582 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance/build $ |
Btw, would the same/similar bmff fix help here for the 0x0 image size as well? |
Fix submitted: #1523. |
@kmilos. Ah, no this is a parsing error. We should consider replacing jp2image.cpp with bmffimage.cpp for v1.0 because it's shorter and simpler. I didn't do that for v0.27.4 for the following reasons:
Reasons to consider using bmffimage.cpp to parse jp2 in v1.00 are:
|
Ah, sorry, I just assumed the code base was very similar since the jp2 and bmff specs are pretty much the same, should've checked first... Merging them in the future makes total sense. |
This issue appears to have been assigned CVE-2021-3482. |
Hi, I found a vulnerability in current master
src/jp2image.cpp:359:77
There was an improper check of the
rawData.size_
, it can lead to heap overflow and memory access out-of-bounds.Here is the and the ASAN details:
The text was updated successfully, but these errors were encountered: