CVE-2012-3444
Description
The get_image_dimensions function in the image-handling functionality in Django before 1.3.2 and 1.4.x before 1.4.1 uses a constant chunk size in all attempts to determine dimensions, which allows remote attackers to cause a denial of service (process or thread consumption) via a large TIFF image.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
DjangoPyPI | < 1.3.2 | 1.3.2 |
DjangoPyPI | >= 1.4, < 1.4.1 | 1.4.1 |
Affected products
29cpe:2.3:a:djangoproject:django:*:*:*:*:*:*:*:*+ 28 more
- cpe:2.3:a:djangoproject:django:*:*:*:*:*:*:*:*range: <=1.3
- cpe:2.3:a:djangoproject:django:0.95:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:0.96:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0.1:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0.2:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0:alpha1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0:alpha2:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0:beta:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.0:beta2:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1.2:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1.3:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1.4:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1:alpha1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1:beta1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.1:rc1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2.2:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2.4:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2.5:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2.6:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2.7:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2-alpha1:*:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2:beta1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.2:rc1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.3:alpha1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.3:beta1:*:*:*:*:*:*
- cpe:2.3:a:djangoproject:django:1.4:*:*:*:*:*:*:*
Patches
5c14f325c4eef[1.4.x] Fixed second security issue in image uploading. Disclosure and release forthcoming.
1 file changed · +4 −14
django/forms/fields.py+4 −14 modified@@ -570,20 +570,10 @@ def to_python(self, data): file = StringIO(data['content']) try: - # load() is the only method that can spot a truncated JPEG, - # but it cannot be called sanely after verify() - trial_image = Image.open(file) - trial_image.load() - - # Since we're about to use the file again we have to reset the - # file object if possible. - if hasattr(file, 'reset'): - file.reset() - - # verify() is the only method that can spot a corrupt PNG, - # but it must be called immediately after the constructor - trial_image = Image.open(file) - trial_image.verify() + # load() could spot a truncated JPEG, but it loads the entire + # image in memory, which is a DoS vector. See #3848 and #18520. + # verify() must be called immediately after the constructor. + Image.open(file).verify() except ImportError: # Under PyPy, it is possible to import PIL. However, the underlying # _imaging C module isn't available, so an ImportError will be
b2eb4787a0ff[1.3.x] Fixed second security issue in image uploading. Disclosure and release forthcoming.
1 file changed · +4 −14
django/forms/fields.py+4 −14 modified@@ -538,20 +538,10 @@ def to_python(self, data): file = StringIO(data['content']) try: - # load() is the only method that can spot a truncated JPEG, - # but it cannot be called sanely after verify() - trial_image = Image.open(file) - trial_image.load() - - # Since we're about to use the file again we have to reset the - # file object if possible. - if hasattr(file, 'reset'): - file.reset() - - # verify() is the only method that can spot a corrupt PNG, - # but it must be called immediately after the constructor - trial_image = Image.open(file) - trial_image.verify() + # load() could spot a truncated JPEG, but it loads the entire + # image in memory, which is a DoS vector. See #3848 and #18520. + # verify() must be called immediately after the constructor. + Image.open(file).verify() except ImportError: # Under PyPy, it is possible to import PIL. However, the underlying # _imaging C module isn't available, so an ImportError will be
da33d67181b5[1.4.x] Fixed a security issue in image uploading. Disclosure and release forthcoming.
1 file changed · +6 −1
django/core/files/images.py+6 −1 modified@@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False): file = open(file_or_path, 'rb') close = True try: + # Most of the time PIL only needs a small chunk to parse the image and + # get the dimensions, but with some TIFF files PIL needs to parse the + # whole file. + chunk_size = 1024 while 1: - data = file.read(1024) + data = file.read(chunk_size) if not data: break p.feed(data) if p.image: return p.image.size + chunk_size = chunk_size*2 return None finally: if close:
9ca0ff6268ee[1.3.x] Fixed a security issue in image uploading. Disclosure and release forthcoming.
1 file changed · +6 −1
django/core/files/images.py+6 −1 modified@@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False): file = open(file_or_path, 'rb') close = True try: + # Most of the time PIL only needs a small chunk to parse the image and + # get the dimensions, but with some TIFF files PIL needs to parse the + # whole file. + chunk_size = 1024 while 1: - data = file.read(1024) + data = file.read(chunk_size) if not data: break p.feed(data) if p.image: return p.image.size + chunk_size = chunk_size*2 return None finally: if close:
dd16b17099b7Fixed a security issue in image uploading. Disclosure and release forthcoming.
1 file changed · +6 −1
django/core/files/images.py+6 −1 modified@@ -47,13 +47,18 @@ def get_image_dimensions(file_or_path, close=False): file = open(file_or_path, 'rb') close = True try: + # Most of the time PIL only needs a small chunk to parse the image and + # get the dimensions, but with some TIFF files PIL needs to parse the + # whole file. + chunk_size = 1024 while 1: - data = file.read(1024) + data = file.read(chunk_size) if not data: break p.feed(data) if p.image: return p.image.size + chunk_size = chunk_size*2 return None finally: if close:
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
15- www.djangoproject.com/weblog/2012/jul/30/security-releases-issued/nvdPatchVendor Advisory
- github.com/advisories/GHSA-5h2q-4hrp-v9rrghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2012-3444ghsaADVISORY
- www.debian.org/security/2012/dsa-2529nvdWEB
- www.mandriva.com/security/advisoriesnvdWEB
- www.openwall.com/lists/oss-security/2012/07/31/1nvdWEB
- www.openwall.com/lists/oss-security/2012/07/31/2nvdWEB
- www.ubuntu.com/usn/USN-1560-1nvdWEB
- github.com/django/django/commit/9ca0ff6268eeff92d0d0ac2c315d4b6a8e229155ghsaWEB
- github.com/django/django/commit/b2eb4787a0fff9c9993b78be5c698e85108f3446ghsaWEB
- github.com/django/django/commit/c14f325c4eef628bc7bfd8873c3a72aeb0219141ghsaWEB
- github.com/django/django/commit/da33d67181b53fe6cc737ac1220153814a1509f6ghsaWEB
- github.com/django/django/commit/dd16b17099b7d86f27773df048c5014cf439b282ghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2012-4.yamlghsaWEB
- www.djangoproject.com/weblog/2012/jul/30/security-releases-issuedghsaWEB
News mentions
0No linked articles in our index yet.