Standard random number generators (using shuffle ) should not be used to generate randomness

Bug #1319639 reported by Zhang Yun
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Ivan Kolodyazhny

Bug Description

In cinder code : /cinder/utils.py . Below two lines of code used shuffle to generate a random number, Standard random number generators should not be used to generate randomness used for security reasons. Could we use a crytographic randomness generator to provide sufficient entropy to instead of it?

 # If length < len(symbolgroups), the leading characters will only
 # be from the first length groups. Try our best to not be predictable
 # by shuffling and then truncating.
 r.shuffle(password) ----------------> This line of code has described issue.
 password = password[:length]
 length -= len(password)

# finally shuffle to ensure first x characters aren't from a
# predictable group
r.shuffle(password) ----------------> This line of code has described issue.

return ''.join(password)

Tags: security
Zhang Yun (zhangyun)
information type: Private Security → Public
description: updated
Zhang Yun (zhangyun)
summary: - Standard random number generators should not be used to generate
- randomness
+ Standard random number generators (using shuffle ) should not be used
+ to generate randomness
Mike Perez (thingee)
Changed in cinder:
importance: Undecided → Medium
milestone: none → juno-1
status: New → Triaged
Thierry Carrez (ttx)
information type: Public → Public Security
Revision history for this message
Thierry Carrez (ttx) wrote :

Cinder devs: could you comment on how much those "random" numbers are used in a security context ? We need to determine is this would be a welcome strengthening (no advisory published) or an exploitable vulnerability (advisory published).

Changed in ossa:
status: New → Incomplete
Revision history for this message
John Griffith (john-griffith) wrote :

This is used by some drivers to generate a CHAP secret, the base driver as well as IBM/Storwize and HP/Lefthand. I'm not sure I agree that his is a security concern at all.

While in general rand and shuffle should not be used for setting secure passwords, the algorithm here does a number of things in addition to rand and shuffle by then also filling in random symbols. Regardless, given that this is for a CHAP setting only I think that this can be improved without a security advisory or notification.

Revision history for this message
Jay Bryant (jsbryant) wrote :

I second John's sentiment. I think it would be good to strengthen security here but an advisory is not necessary.

Revision history for this message
Jeremy Stanley (fungi) wrote :

I've removed the advisory task, switched the bug from public security (indicating some sort of actual vulnerability) to public, and added the "security" tag to indicate it's a potential strengthening opportunity.

no longer affects: ossa
information type: Public Security → Public
tags: added: security
Changed in cinder:
milestone: juno-1 → juno-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/105779

Changed in cinder:
assignee: nobody → Ivan Kolodyazhny (e0ne)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/105779
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=063e515e780c241ddac755b0b9a2414316d983f5
Submitter: Jenkins
Branch: master

commit 063e515e780c241ddac755b0b9a2414316d983f5
Author: Ivan Kolodyazhny <email address hidden>
Date: Wed Jul 9 19:08:18 2014 +0300

    Use PyCrypto to generate randomness passwords

    Standard random generator is not secure enouph. Use PyCrypto instead.
    Updated requirements.txt with pycrypto>=2.6 according to
    global-requirements

    Change-Id: I38fd47a30893a946de30fad95c57759781312be6
    Closes: bug #1319639

Changed in cinder:
status: In Progress → Fix Committed
Changed in cinder:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: juno-2 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.