classification
Title: insecure os.urandom on VMS
Type: security Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.1, Python 2.7, Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: loewis, zooko
Priority: normal Keywords:

Created on 2010-06-30 03:48 by zooko, last changed 2010-06-30 09:47 by pitrou.

Messages (3)
msg108963 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2010-06-30 03:48
os.urandom() on VMS invokes OpenSSL's RAND_pseudo_bytes(). That is documented on:

http://www.openssl.org/docs/crypto/RAND_bytes.html

as being predictable and therefore unsuitable for many cryptographic purposes. This is inconsistent with the documentation of os.urandom():

"""
urandom(n) -> str\n\n\
Return a string of n random bytes suitable for cryptographic use.
"""

This probably means that users of Python on VMS are vulnerable to attack based on the predictability of the results they get from os.urandom().

Honestly, I would have guessed that there *were* no users of Python on VMS when I started this bug report, but look--apparently there are:

http://www.vmspython.org

To fix this, change the call from RAND_pseudo_bytes() to RAND_bytes(). It has the same type signature and actually does what os.urandom() needs.
msg108964 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2010-06-30 03:49
HACK Zooko-Ofsimplegeos-MacBook-Pro:~/playground/python/release27-trunk$ svn diff
Index: Modules/posixmodule.c
===================================================================
--- Modules/posixmodule.c       (revision 82382)
+++ Modules/posixmodule.c       (working copy)
@@ -8481,7 +8481,7 @@
     result = PyString_FromStringAndSize(NULL, howMany);
     if (result != NULL) {
         /* Get random data */
-        if (RAND_pseudo_bytes((unsigned char*)
+        if (RAND_bytes((unsigned char*)
                               PyString_AS_STRING(result),
                               howMany) < 0) {
             Py_DECREF(result);
msg108965 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2010-06-30 03:49
This issue is a security vulnerability.
History
Date User Action Args
2010-06-30 09:47:06pitrousetnosy: + loewis

type: security
components: + Library (Lib)
versions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2
2010-06-30 03:49:55zookosetmessages: + msg108965
2010-06-30 03:49:26zookosetmessages: + msg108964
2010-06-30 03:48:33zookocreate