Bug 758905 (CVE-2011-4944) - CVE-2011-4944 python: distutils creates ~/.pypirc insecurely
Summary: CVE-2011-4944 python: distutils creates ~/.pypirc insecurely
Alias: CVE-2011-4944
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL: http://bugs.python.org/issue13512
Whiteboard: impact=low,public=20111130,reported=2...
Depends On: 805382 805383 805384 805385 808303 808304 808305
Blocks: 790031
TreeView+ depends on / blocked
Reported: 2011-11-30 23:09 UTC by Vincent Danen
Modified: 2019-06-08 18:58 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2012-07-03 15:42:56 UTC

Attachments (Terms of Use)
proposed patch to correct the flaw (864 bytes, patch)
2012-03-27 18:40 UTC, Vincent Danen
no flags Details | Diff

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0744 normal SHIPPED_LIVE Moderate: python security update 2012-06-18 16:31:56 UTC
Red Hat Product Errata RHSA-2012:0745 normal SHIPPED_LIVE Moderate: python security update 2012-06-18 16:42:17 UTC

Description Vincent Danen 2011-11-30 23:09:53 UTC
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 23:11:05 UTC

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 23:12:42 UTC
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 23:27:04 UTC
I've reported this upstream:


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 14:05:51 UTC
Upstream patch to go into 2.7.4:


Comment 7 Vincent Danen 2012-03-27 18:31:48 UTC
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 18:40:58 UTC
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 18:47:58 UTC
Corrected CVE number as per http://www.openwall.com/lists/oss-security/2012/03/27/10

Comment 18 Huzaifa S. Sidhpurwala 2012-03-30 05:49:51 UTC
Created python tracking bugs for this issue

Affects: fedora-all [bug 808303]

Comment 19 Huzaifa S. Sidhpurwala 2012-03-30 05:49:57 UTC
Created python3 tracking bugs for this issue

Affects: fedora-all [bug 808304]

Comment 20 Huzaifa S. Sidhpurwala 2012-03-30 05:50:01 UTC
Created python26 tracking bugs for this issue

Affects: epel-5 [bug 808305]

Comment 21 errata-xmlrpc 2012-06-18 12:32:36 UTC
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 12:42:57 UTC
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

Note You need to log in before you can comment on or make changes to this bug.