Bug 1234886 (CVE-2015-4645)
|Summary:||CVE-2015-4645 squashfs-tools: integer overflow in read_fragment_table_4|
|Product:||[Other] Security Response||Reporter:||Vasyl Kaigorodov <vkaigoro>|
|Component:||vulnerability||Assignee:||Red Hat Product Security <security-response-team>|
|Status:||CLOSED WONTFIX||QA Contact:|
|Version:||unspecified||CC:||bruno, carnil, jarod, jrusnack, peterm, plougher, tcallawa|
|Fixed In Version:||Doc Type:||Bug Fix|
|Doc Text:||Story Points:||---|
|Last Closed:||2015-10-09 21:01:33 UTC||Type:||---|
|oVirt Team:||---||RHEL 7.3 requirements from Atomic Host:|
|Cloudforms Team:||---||Target Upstream Version:|
|Bug Depends On:||1234888|
Description Vasyl Kaigorodov 2015-06-23 12:54:27 UTC
Integer overflow issue was reported in squashfs-tools. Following code in unsquash-4.c overflows the bytes variable, so that the allocation of fragments_bytes has an erroneous size. int bytes = SQUASHFS_FRAGMENT_BYTES(sBlk.s.fragments); ... fragment_table = malloc(bytes) Upstream bug report: https://github.com/devttys0/sasquatch/pull/5 Upstream fix: https://github.com/gcanalesb/sasquatch/commit/6777e08cc38bc780d27c69c1d8c272867b74524f
Comment 1 Vasyl Kaigorodov 2015-06-23 12:58:20 UTC
Created squashfs-tools tracking bugs for this issue: Affects: fedora-all [bug 1234888]
Comment 2 Bruno Wolff III 2015-06-23 22:50:32 UTC
While the code in question is in Phillip's branch, note that this issue is being reported against an upstream version of squashfs-tools that has diverged from the one we use. The patch with the final set of fixes looks reasonable at first glance and we care carry it as a patch. But given they haven't been keeping up with changes Phillip has made since 4.3 was released, I don't want to switch over to using them as an upstream (at least not at this time).
Comment 3 Bruno Wolff III 2015-06-24 16:20:58 UTC
The upstream patch really should have fixed the trace statement output as well. I don't think there is a security issue with the output formats being too narrow, but the output could be confusing. Casting to unsigned long is probably the most portable way to print size_t. The 'z' modifier is too new. I did find some comments that said it is possible for size_t to be wider than unsigned long, but this seemed rare and as long as the value to be printed fit in an unsigned long, the output would still be OK.
Comment 4 Fedora Update System 2015-07-19 01:57:45 UTC
squashfs-tools-4.3-11.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.
Comment 5 Phillip Lougher 2015-07-20 23:56:20 UTC
(In reply to Bruno Wolff III from comment #2) > The patch with the final set of fixes looks reasonable at first glance and > we care carry it as a patch. But given they haven't been keeping up with > changes Phillip has made since 4.3 was released, I don't want to switch over > to using them as an upstream (at least not at this time). That's good to know because I'm extremely unhappy with sasquatch. Whilst it's aims are laudable, it simply promulgates all the bad practices inherent in the hacked and extremely poor vendor specific implementations which have plagued Squashfs for years. Many of these hacked implementations are full of bugs, and will make Unsquashfs extremely unstable... In addition Squashfs has a specific filesystem layout, and divergences from that are treated as errors and possible security attack vectors (trying to make Squashfs do something wrong). To move to a non-deterministic "guess work" system where filesystem differences are merely treated as "hints" it's been generated by a "vendor variant" makes a mockery of any security checks, and the two years of security hardening I put into Squashfs-tools 4.3. In otherwords you can either make Squashfs-tools secure from attacks by carefully checking the filesystem is correct, OR you can make Squashfs flexible and tolerant of hacked up vendor messes by using kludges and guess work. You can't do both. I think it is outrageous a distribution would even consider moving from the official tools to an entirely unofficial and unendorsed fork. To make myself clear it is not simply unendorsed, I publically denounce it now.
Comment 6 Bruno Wolff III 2015-07-21 00:35:24 UTC
Phillip, I'm glad you commented here. I was wondering if you were aware of the CVE as it didn't seem to be reported at sourceforge. While the bug does seem to plausibly apply to your version of squashfs, I wasn't sure if there were earlier checks that would keep the data from being out of range at the point where the patch changed things.
Comment 7 Phillip Lougher 2015-07-21 02:50:54 UTC
(In reply to Bruno Wolff III from comment #6) > Phillip, I'm glad you commented here. I was wondering if you were aware of > the CVE as it didn't seem to be reported at sourceforge. While the bug does > seem to plausibly apply to your version of squashfs, I wasn't sure if there > were earlier checks that would keep the data from being out of range at the > point where the patch changed things. No, this isn't checked in Unsquashfs. Compared to the Squashfs kernel code and the Mksquashfs code-base Unsquashfs has fewer sanity checks. This is for two reasons: one simply a matter of prioritisation, and the other due to the expected use-case. The prioritisation issue should be simple to understand. In terms of vulnerability the kernel is most critical, then Mksquashfs and last Unsquashfs, and the hardening and addition of sanity checks have been prioritised in that order. The expected use-case is a little less obvious. With the kernel code hardening, it has become increasingly impossible to mount a corrupted Squashfs filesystem. Given we would like to allow users to extract the good data in a corrupted filesystem using Unsquashfs, it stand to reason that Unsquashfs by definition needs to be more tolerant of filesystem corruption and have less sanity checks. Unfortunately this means Unsquashfs is more vulnerable to CVEs than the other code. The question here is what to do about this raised CVE, and what to do in the future. With regards to this CVE, the posted patch is a band-aid, it fixes the symptom but not the cause. The cause is a corrupted fragments superblock entry, the symptom is this value unchecked then leads to a variable overflow and a stack overflow. The fix isn't to paper over the variable overflow and the stack overflow, this will probably simply lead to incorrect behaviour later on. On the one hand the correct fix is obvious, and that is to introduce more sanity checks of the superblock information. But on the other hand this goes against the idea that Unsquashfs is supposed to be more tolerant of filesystem corruption. The ultimate fix in the future is likely to mean making Unsquashfs more actively tolerant of filesystem corruption, rather than at the moment turning a blind eye to filesystem corruption and hoping for the best. What this means is Unsquashfs will need to actively detect filesystem corruption, and rather than simply aborting, try to actively work around the known filesystem corruption. To do this completely is a big task. In the meantime I will work on a more focused patch for this CVE that fixes the cause and not the symptom.
Comment 8 Fedora Update System 2015-07-21 08:12:59 UTC
squashfs-tools-4.3-11.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.