Bug 1202809 (CVE-2015-2316)

Summary: CVE-2015-2316 Django: possible denial of service in strip_tags()
Product: [Other] Security Response Reporter: Martin Prpič <mprpic>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: abaron, apevec, chrisw, dallan, gkotton, lhh, lpeer, markmc, mrunge, rbryant, sclewis, security-response-team, srevivo
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Django 1.8rc1, Django 1.7.7, Django 1.6.11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-21 00:44:22 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: 1203614, 1203615    
Bug Blocks: 1202821    
Attachments:
Description Flags
is-safe-url-master.diff
none
strip-tags-1.8.diff
none
strip-tags-1.7.diff
none
strip-tags-1.6.diff
none
strip-tags-master.diff none

Description Martin Prpič 2015-03-17 13:30:45 UTC
The following flaw was found in Django:

In a previous release, django.utils.html.strip_tags was changed to work iteratively. The problem is that the size of the input it is processing can increase on each iteration which results in an infinite loop in strip_tags(). This issue only affects versions of Python that haven't received a bugfix in HTMLParser (http://bugs.python.org/issue20288); namely Python < 2.7.7 and 3.3.5. Some operating system vendors have also backported the fix for the Python bug into their packages of earlier versions.

To remedy this issue, strip_tags() will now return the original input if it detects the length of the string it is processing increases. Remember that absolutely NO guarantee is provided about the results of strip_tags() being HTML safe. So NEVER mark safe the result of a strip_tags() call without escaping it first, for example with django.utils.html.escape.

This issue affects Django versions 1.8.x, 1.7.x, and 1.6.x. This issue is fixed in versions 1.8 release candidate 1 (or beta 3), 1.7.7, and 1.6.11.

Acknowledgements:

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

Comment 1 Martin Prpič 2015-03-17 13:33:12 UTC
Created attachment 1002792 [details]
is-safe-url-master.diff

Comment 2 Martin Prpič 2015-03-17 13:33:56 UTC
Created attachment 1002793 [details]
strip-tags-1.8.diff

Comment 3 Martin Prpič 2015-03-17 13:34:21 UTC
Created attachment 1002794 [details]
strip-tags-1.7.diff

Comment 4 Martin Prpič 2015-03-17 13:35:04 UTC
Created attachment 1002795 [details]
strip-tags-1.6.diff

Comment 5 Martin Prpič 2015-03-17 13:35:34 UTC
Created attachment 1002796 [details]
strip-tags-master.diff

Comment 6 Martin Prpič 2015-03-19 09:33:36 UTC
External References:

https://www.djangoproject.com/weblog/2015/mar/18/security-releases/

Comment 7 Martin Prpič 2015-03-19 09:36:33 UTC
Created python-django tracking bugs for this issue:

Affects: fedora-all [bug 1203614]
Affects: epel-7 [bug 1203615]

Comment 8 Fedora Update System 2015-04-09 16:58:47 UTC
python-django-1.6.11-1.el7 has been pushed to the Fedora EPEL 7 stable repository.  If problems still persist, please make note of it in this bug report.