Skip to content
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

Integer Overflow in ImagingResampleHorizontal #1710

Closed
nedwill opened this issue Feb 4, 2016 · 5 comments
Closed

Integer Overflow in ImagingResampleHorizontal #1710

nedwill opened this issue Feb 4, 2016 · 5 comments

Comments

@nedwill
Copy link
Contributor

nedwill commented Feb 4, 2016

ImagingResampleHorizontal mallocs two buffers:

kk = malloc(xsize * kmax * sizeof(float));
...
xbounds = malloc(xsize * 2 * sizeof(int));

xsize is trusted user input. These multiplications can overflow, leading the malloc'd buffer to be undersized. These allocations are followed by a loop that writes out of bounds. This can lead to corruption on the heap of the Python process with attacker controlled data (exploiting this would be really cool, as the loop contains some serious floaty arithmetic). It's possible someone has an image resizing service using Pillow. :)

See the following proof of concept:

from PIL import Image
im = Image.open("cat.jpg").convert("L")
xsize = 0x100000008 / 4
ysize = 0x1337 # unrelated
im.im.resize((xsize, ysize), Image.LINEAR) # any resampling filter will do here

where "cat.jpg" is your favorite valid cat picture.

@radarhere
Copy link
Member

Sounds to me like you have a fairly good handle on the situation. Would you be interested in creating a PR to solve the problem?

@nedwill
Copy link
Contributor Author

nedwill commented Feb 4, 2016

Sure, I'll take a look.

@nedwill
Copy link
Contributor Author

nedwill commented Feb 4, 2016

Oh, I just noticed in #1708 there's a mention of a private repo for security updates and some CVEs. I hope you don't mind that I disclosed this bug here. If I find related bugs in the future, should I contact the maintainers through some other channel?

@radarhere
Copy link
Member

The current conclusion of #1658 is to e-mail aclark@aclark.net and let him know.

@nedwill
Copy link
Contributor Author

nedwill commented Feb 4, 2016

Ok, in the future I'll contact him there. I've contributed security fixes to some projects before but hadn't encountered a security procedure like this. (For example, the CPython project itself just accepts public disclosures in their normal bug tracker.)

uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 13, 2016
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
MFH:		2016Q1
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@408782 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 13, 2016
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
MFH:		2016Q1
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 13, 2016
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49

Approved by:	ports-secteam (security)
tota pushed a commit to tota/freebsd-ports that referenced this issue Feb 20, 2016
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
MFH:		2016Q1
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@408782 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Dec 2, 2016
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49

Approved by:	ports-secteam (security)
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 1, 2021
Backport security fixes from 3.1.1 release, resolving the following
vulnerabilities:

 * CVE-2016-0775: Buffer overflow in FLI decoding code
 * CVE-2016-0740: Buffer overflow in TIFF decoding code
 * Integer overflow in Resample.c [1]
 * Buffer overflow in PCD decoder [2]

[1] python-pillow/Pillow#1710
[2] python-pillow/Pillow#568

PR:		207053
Submitted by:	rakuco
Security:	a8de962a-cf15-11e5-805c-5453ed2e2b49

Approved by:	ports-secteam (security)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants