Bug #890
ASF: heap overflow
100%
Description
asfvideo.cpp:624 reads dataLength amount of data into a buffer of size 500, causing a heap overflow if dataLength>500. Testcase attached.
At a glance lines 617, 630, 638 probably also have similar problems. Also quicktimevideo.cpp:1059/1066/1077/1095?
Files
Associated revisions
#890: Corrected the case of heap overflow if dataLength>500 in asfvideo.cpp, quicktimevideo.cpp
#890: Fixed some possible issues of crashing due to in-efficient management of buffers in riffvideo.cpp
#890: Fixed some possible issues of crashing due to in-efficient management of buffers in asfvideo.cpp
#890: Fixed some possible issues of crashing due to underflow in buffers in quicktimevideo.cpp
History
Updated by Abhinav Badola over 8 years ago
- % Done changed from 0 to 50
Hi Alyssa,
Please test and confirm if this bug is also solved at your end.
Thanking you in anticipation.
Updated by Alyssa Milburn over 8 years ago
That certainly fixes my testcase. I'll check the other cases, thanks for the quick response.
Unfortunately (sorry!) I didn't look carefully enough the first time. Here's some more possible issues:
asfvideo.cpp:560/570/580, riffvideo.cpp:764/786/856 might have the same problem. riffvideo.cpp:654 also looks unsafe (the size comes from line 572?).
riffvideo.cpp:927 might be unsafe in 32-bit builds because the allocation on riffvideo.cpp:868 looks like it can be overflowed (if I provide a size of -1).
Obviously I'm not very familiar with the exiv2 code, but a lot of the other code uses a separate buffer and passes that buf.size_ to the io_->read calls, so there's no chance of a heap overflow. Perhaps it might be worth doing that in some of these cases.
Updated by Alyssa Milburn over 8 years ago
- File overflow2.mov overflow2.mov added
You need to also check for dataLength being too low in your new checks on quicktimevideo.cpp:1082/1100/1119/1138, because you subtract a constant from it during the actual read(). Another (manually constructed) testcase attached.
Updated by Abhinav Badola over 8 years ago
Alyssa Milburn wrote:
That certainly fixes my testcase. I'll check the other cases, thanks for the quick response.
Unfortunately (sorry!) I didn't look carefully enough the first time. Here's some more possible issues:
Don't worry. We are happy to have you here, reporting these issues.
Lets keep this issue open till all the bugs are solved.
It is better that we take some more time on analyzing and fixing bugs right now, than having major program crashes later.
Thank you for analyzing Exiv2, and helping in making it more sturdy and robust.
I will keep on patching the issues that you may find, meanwhile I will expect you to find more.
Updated by Robin Mills over 8 years ago
I'd like to thank both of you for working on this stuff. Fuzzing and hardening the code is good for everybody. Thank you both for working on this.
A couple of questions for Alyssa:
1) Would it help you if we grant you write access to the depot?
2) There's a corrupted file being discussed in Forum topic 1477
http://dev.exiv2.org/boards/3/topics/1477
I'm going to take a look at Aleksandr's file this evening. If you have time and interest to investigate, I would very much appreciate your analysis.
Robin
Updated by Alyssa Milburn over 8 years ago
If Abhinav or others familiar with the project can find the time to fix these bugs, then I think it's a much better idea for them to make the fixes, since they're in a much better position to test the code (and are presumably going to be maintaining it in the long-term). If you need suggested patches for any of these issues then I can make an attempt, though.
Beware that I'm not running an actual fuzzer, and there might well be other obvious bugs which would be caught by one; my filed bugs are just the result of my glancing through the source code and seeing if I spot any suspicious-looking code.
(The file in the forum post seems to be corrupt/truncated as diagnosed; I don't think I can add anything to what's already been said.)
Updated by Robin Mills over 8 years ago
- Status changed from New to Assigned
Thanks for updating us, Alyssa. I'm glad you have the time to just "glance through the code". You're spotting good things. I haven't looked at that corrupted file in Topic 1477, however I'll have a look at it this evening.
Updated by Abhinav Badola over 8 years ago
Updated by Abhinav Badola over 8 years ago
- Status changed from Assigned to Resolved
- % Done changed from 50 to 100
Updated by Robin Mills over 8 years ago
- Status changed from Resolved to Closed
- Target version set to 0.24
Fixed in 0.24.
#890: Corrected the case of Infinite loop in RiffVideo::nikonTagsHandler()