Bug 827558 (CVE-2012-2681)

Summary: CVE-2012-2681 cumin: weak session keys
Product: [Other] Security Response Reporter: Vincent Danen <vdanen>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: fweimer, grid-maint-list, security-response-team, sgraf, tmckay, vdanen
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 840106 (view as bug list) Environment:
Last Closed: 2021-10-19 21:54:02 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: 840106, 858868    
Bug Blocks: 808230, 828434, 828935    

Description Vincent Danen 2012-06-01 18:32:17 UTC
Florian Weimer reported a flaw in cumin that would cause it to create weak session keys.  The wooly.util.unique_id() uses the random.getrandbits() function to generate the session keys, however random.getrandbits() leaks state and can eventually become predictable (according to the Python documentation it uses the Mersenne Twister algorithm).

To create truly unique session keys, wooly.util.unique_id() should open /dev/urandom and read 16 bytes from there.

Comment 1 Trevor McKay 2012-06-04 16:10:05 UTC
There is a fix for this in revision 5400 on the cumin trunk.

Here is the diff:

 def unique_id():
-    bits0 = random.getrandbits(32)
-    bits1 = random.getrandbits(32)
-    bits2 = random.getrandbits(32)
-    bits3 = random.getrandbits(32)
 
-    return "%08x-%08x-%08x-%08x" % (bits0, bits1, bits2, bits3)
+    # Generate 4 unsigned integers.
+    # Take 4 bytes from urandom and interpret
+    # them as a standard-sized ('=') unsigned long ('L').
+    # Unpack returns a tuple, hence the [0].
+    try:
+        bits = [struct.unpack("=L", os.urandom(4))[0] for x in range(4)]
+    except NotImplementedError:
+        bits = [random.getrandbits(32) for x in range(4)]
 
+    return "%08x-%08x-%08x-%08x" % (bits[0], bits[1], bits[2], bits[3])
+

Comment 2 Tomas Hoger 2012-08-07 11:25:15 UTC
svn diff -c 5400 http://svn.fedorahosted.org/svn/cumin
svn diff -c 5437 http://svn.fedorahosted.org/svn/cumin

Comment 5 Vincent Danen 2012-09-19 16:10:53 UTC
Acknowledgements:

This issue was discovered by Florian Weimer of the Red Hat Product Security Team.

Comment 6 errata-xmlrpc 2012-09-19 17:43:38 UTC
This issue has been addressed in following products:

  MRG for RHEL-5 v. 2

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

Comment 7 errata-xmlrpc 2012-09-19 17:52:44 UTC
This issue has been addressed in following products:

  MRG for RHEL-6 v.2

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

Comment 8 Vincent Danen 2012-09-19 21:09:41 UTC
Created cumin tracking bugs for this issue

Affects: fedora-all [bug 858868]