Bug 758905 (CVE-2011-4944)

Summary: CVE-2011-4944 python: distutils creates ~/.pypirc insecurely
Product: [Other] Security Response Reporter: Vincent Danen <vdanen>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: derks, dmalcolm, ivazqueznet, jonathansteffan
Target Milestone: ---Keywords: Reopened, Security
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://bugs.python.org/issue13512
Whiteboard: impact=low,public=20111130,reported=20111130,source=debian,cvss2=1.2/AV:L/AC:H/Au:N/C:P/I:N/A:N,rhel-4/python=wontfix,rhel-5/python=affected,rhel-6/python=affected,fedora-all/python=affected,epel-5/python26=affected,fedora-all/python3=affected
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-03 11:42:56 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 805382, 805383, 805384, 805385, 808303, 808304, 808305    
Bug Blocks: 790031    
Attachments:
Description Flags
proposed patch to correct the flaw none

Description Vincent Danen 2011-11-30 18:09:53 EST
It was reported [1] that distutils would create ~/.pypirc insecurely.  There is a race from the time the user's username and password is written to the file to when it is chmod'd with appropriate permissions.

Typically, a user's home directory will be created with default 0700 permissions which would not allow for a local attacker to obtain access to this file during the race window, however if a user were to make their home directory 0755 they could be susceptible to this race.

One solution would be to use tempfile.mkstemp() to create the file and then move it in place.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650555
Comment 1 Vincent Danen 2011-11-30 18:11:05 EST
Statement:

The Red Hat Security Response Team has rated this issue as having low security impact. This issue is not currently planned to be addressed in future updates. For additional information, refer to the Issue Severity Classification: https://access.redhat.com/security/updates/classification/.
Comment 2 Vincent Danen 2011-11-30 18:12:42 EST
Also, the pypi support seems to only be available in python 2.6 and higher, so earlier versions are unaffected.
Comment 3 Vincent Danen 2011-11-30 18:27:04 EST
I've reported this upstream:

http://bugs.python.org/issue13512

I don't believe this issue is significant enough (particularly due to the default of home directories being mode 0700) to warrant more than that.
Comment 4 Vincent Danen 2012-03-27 10:05:51 EDT
Upstream patch to go into 2.7.4:

http://bugs.python.org/file23824/pypirc-secure.diff
Comment 7 Vincent Danen 2012-03-27 14:31:48 EDT
This does in fact affect RHEL5 and earlier; the vulnerable code is in Lib/distutils/command/register.py.
Comment 8 Vincent Danen 2012-03-27 14:40:58 EDT
Created attachment 573152 [details]
proposed patch to correct the flaw

This patch should correct the flaw in python 2.4.x.
Comment 10 Kurt Seifried 2012-03-27 14:47:58 EDT
Corrected CVE number as per http://www.openwall.com/lists/oss-security/2012/03/27/10
Comment 18 Huzaifa S. Sidhpurwala 2012-03-30 01:49:51 EDT
Created python tracking bugs for this issue

Affects: fedora-all [bug 808303]
Comment 19 Huzaifa S. Sidhpurwala 2012-03-30 01:49:57 EDT
Created python3 tracking bugs for this issue

Affects: fedora-all [bug 808304]
Comment 20 Huzaifa S. Sidhpurwala 2012-03-30 01:50:01 EDT
Created python26 tracking bugs for this issue

Affects: epel-5 [bug 808305]
Comment 21 errata-xmlrpc 2012-06-18 08:32:36 EDT
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2012:0744 https://rhn.redhat.com/errata/RHSA-2012-0744.html
Comment 22 errata-xmlrpc 2012-06-18 08:42:57 EDT
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2012:0745 https://rhn.redhat.com/errata/RHSA-2012-0745.html