Closed
Description
Here is a link to the file that causes the problem: http://526ddd950476442e0e6c-adab491b4c7746bcac4e5a193c3c94e6.r70.cf1.rackcdn.com/golden.pcd
This file was created using 'convert', so it might not have proper formatting/header or whatever else, but it most definitely shouldn't cause a seg fault.
i = Image.open('golden.pcd')
i.resize(new_dim) # crashes here or upon any other operation
Let me know if any other info is needed.
A fix for this error is not crucial for me, just want to help make this library even better.
Metadata
Metadata
Assignees
Labels
BugAny unexpected behavior, until confirmed feature.
Activity
wiredfool commentedon Mar 25, 2014
Ok, that's weird. The backtrace I'm getting is entirely python code.
I'm seeing it on multiple python versions, multiple versions of Pillow.
aclark4life commentedon Mar 25, 2014
@lehins Thanks for reporting
aclark4life commentedon Mar 25, 2014
I'm currently targeting 2.4.0 for this, though I expect we may not get to it.
wiredfool commentedon Mar 31, 2014
Ok. This is still weird. I've thrown this at Fedora 20, where GDB is better integrated with the python runtime. It's failing in ImageFile.load:
n = 64512, len(b) == 66560. It's the second time through, so b == ~1k from the first round, and 64k from this read, and we're indexing for the last 2k. This seems entirely reasonable to me. The only thing that I can think of is that the decode must be messing with the buffer, but that doesn't seem to be the case.
Detailed traces &c follow.
Py-bt is really short:
The locals from the current python frame:
Full bt, truncated to the call to Image.resize
dfandrich commentedon Jan 19, 2015
I'm getting a suspicious memory error when run under glibc 2.20 with Pillow 2.5.3 on an authentic PhotoCD image:
Curiously, the
free(): invalid next sizeerror doesn't appear when debug symbols are available.Valgrind gives even more useful messages; here is a selection:
aclark4life commentedon Jan 19, 2015
@dfandrich can you please try with 2.7.0 and confirm the same issue still exists? Thanks
dfandrich commentedon Jan 20, 2015
I just tried with git HEAD with seemingly identical results. The line numbers were slightly different, e.g.
==5395== Invalid write of size 1
==5395== at 0x72AA605: ImagingPcdDecode (PcdDecode.c:47)
==5395== by 0x728D1EE: _decode (decode.c:123)
==5395== Address 0xb09d480 is 0 bytes after a block of size 2,304 alloc'd
==5395== at 0x4C27F3F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==5395== by 0x728D0DA: _setimage (decode.c:188)
==5395== Use of uninitialised value of size 8
==5395== at 0x72AE9A4: ImagingUnpackYCC (UnpackYCC.c:140)
==5395== by 0x72AA664: ImagingPcdDecode (PcdDecode.c:53)
==5395== by 0x728D1EE: _decode (decode.c:123)
==5395== Invalid write of size 1
==5395== at 0x72AA69E: ImagingPcdDecode (PcdDecode.c:62)
==5395== by 0x728D1EE: _decode (decode.c:123)
--5395-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting
--5395-- si_code=80; Faulting address: 0x0; sp: 0x802b99dd0
5 remaining items
PCD decoder overruns the shuffle buffer, Fixes python-pillow#568
Merge pull request #1706 from wiredfool/pcd-segfault
PCD decoder overruns the shuffle buffer, Fixes #568
dfandrich commentedon Feb 5, 2016
Could this buffer overflow have security implications? Can it overflow by more than a single byte (which isn't necessary safe either)?
wiredfool commentedon Feb 6, 2016
It overflows 768 bytes. The pattern is writing the first three bytes of the word, then leaves the next untouched.
I'd recommend updating to 3.1.1, which includes this fix.
dfandrich commentedon Feb 6, 2016
In that case, it sounds very strongly like this is a potentially exploitable security problem. Are you planning on applying for a CVE number?
dfandrich commentedon Feb 6, 2016
I found the CVE request—http://openwall.com/lists/oss-security/2016/02/02/5
wiredfool commentedon Feb 6, 2016
Yep. The release notes may be helpful as well: https://github.com/python-pillow/Pillow/blob/3.1.x/docs/releasenotes/3.1.1.rst
graphics/py-pillow: Backport security fixes
graphics/py-pillow: Backport security fixes
MFH: r408782 graphics/py-pillow: Backport security fixes
graphics/py-pillow: Backport security fixes
MFH: r408782 graphics/py-pillow: Backport security fixes
MFH: r408782 graphics/py-pillow: Backport security fixes