Bug 1239011 (CVE-2015-5144)

Summary: CVE-2015-5144 Django: possible header injection due to validators accepting newlines in input
Product: [Other] Security Response Reporter: Martin Prpič <mprpic>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: abaron, aortega, apevec, ayoung, bkearney, cbillett, chrisw, dallan, gkotton, gmollett, jrusnack, kseifried, lhh, lpeer, markmc, mrunge, rbryant, sclewis, security-response-team, tdecacqu, tomckay, yeylon
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Django 1.8.3, Django 1.7.9, Django 1.4.21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-25 07:27:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1242350, 1242719, 1242720, 1242721, 1242722    
Bug Blocks: 1239014    
Attachments:
Description Flags
newlines-1.4.x.diff
none
newlines-1.7.x.diff
none
newlines-1.8.x.diff
none
newlines-master.diff none

Description Martin Prpič 2015-07-03 09:10:36 UTC
The following flaw was found in Django:

Some of Django's built-in validators ('django.core.validators.EmailValidator', most seriously) didn't prohibit newline characters (due to the usage of '$' instead of '\Z' in the regular expressions). If an application uses values with newlines in HTTP response or email headers, it can allow an attacker to perform header injection attacks. Django itself isn't vulnerable because 'django.http.HttpResponse' and the mail sending utilities in 'django.core.mail' prohibit newlines in HTTP and SMTP headers, respectively.

While the validators have been fixed in Django, when creating HTTP responses or email messages in other ways, ensure that those methods prohibit newlines as well. Any already-existing data in your application should be checked whether it contains unexpected newlines.

'django.core.validators.validate_ipv4_address()', 'django.core.validators.validate_slug()', and 'django.core.validators.URLValidator' are also affected, however, as of Django 1.6 the 'GenericIPAddresseField', 'IPAddressField', 'SlugField', and 'URLField' form fields which use these validators all strip the input, so the possibility of newlines entering your data only exists if you are using these validators outside of the form fields

Acknowledgements:

Red Hat would like to thank the upstream Django project for reporting this issue.

Comment 1 Martin Prpič 2015-07-07 07:56:44 UTC
Created attachment 1049127 [details]
newlines-1.4.x.diff

Comment 2 Martin Prpič 2015-07-07 07:56:46 UTC
Created attachment 1049128 [details]
newlines-1.7.x.diff

Comment 3 Martin Prpič 2015-07-07 07:56:49 UTC
Created attachment 1049129 [details]
newlines-1.8.x.diff

Comment 4 Martin Prpič 2015-07-07 07:56:52 UTC
Created attachment 1049130 [details]
newlines-master.diff

Comment 5 Kurt Seifried 2015-07-09 04:38:16 UTC
This is now public: https://www.djangoproject.com/weblog/2015/jul/08/security-releases/

Comment 7 Garth Mollett 2015-07-14 03:18:25 UTC
Created Django14 tracking bugs for this issue:

Affects: epel-6 [bug 1242722]

Comment 8 Garth Mollett 2015-07-14 03:18:29 UTC
Created python-django tracking bugs for this issue:

Affects: openstack-rdo [bug 1242719]
Affects: fedora-all [bug 1242720]
Affects: epel-7 [bug 1242721]

Comment 9 Garth Mollett 2015-07-15 00:59:46 UTC
Statement:

This issue affects the version of python-django as included with Red Hat Enterprise Linux OpenStack Platform 5 and 6 however there is no known security impact in a supported use-case at this time.

A future update may address this issue.

Comment 10 Fedora Update System 2015-07-23 08:54:30 UTC
python-django-1.8.3-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.