RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1774471 - Python os.urandom() is not FIPS compliant
Summary: Python os.urandom() is not FIPS compliant
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: python3
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: 8.2
Assignee: Python Maintainers
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks: 1760850
TreeView+ depends on / blocked
 
Reported: 2019-11-20 11:15 UTC by Christian Heimes
Modified: 2022-05-06 00:25 UTC (History)
8 users (show)

Fixed In Version: python3-3.6.8-23.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-28 16:08:30 UTC
Type: Bug
Target Upstream Version:
Embargoed:
cheimes: needinfo-


Attachments (Terms of Use)
Experimental patch for Python master (3.40 KB, patch)
2019-11-20 11:20 UTC, Christian Heimes
no flags Details | Diff
Updated FIPS getrandom patch on top of Petr's FIPS branch (4.84 KB, application/mbox)
2019-11-25 14:39 UTC, Christian Heimes
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1687905 1 None None None 2021-01-20 06:05:38 UTC
Red Hat Issue Tracker RHELPLAN-30636 0 None None None 2022-05-06 00:25:05 UTC
Red Hat Product Errata RHSA-2020:1764 0 None None None 2020-04-28 16:08:42 UTC

Description Christian Heimes 2019-11-20 11:15:30 UTC
Description of problem:
Python's internal CSPRNG for hash randomization and os.urandom() use the Kernel DRBG via the getrandom() syscall. The Kernel RNG is not (yet) FIPS compliant.

os.urandom() is the preferred source for cryptographically secure random data. It is used a lot, amongst others by 389-DS/RHDS, IPA/IdM, and Dogtag/RHCS. It would take too much effort the modify all Python libraries and applications to use a FIPS compliant RNG. Instead Python should be modified to handle FIPS compliance internally.

Version-Release number of selected component (if applicable):
python3-3.6.8-22.el8

How reproducible:
always

Steps to Reproduce:
1. strace -egetrandom python3 -c "import os; os.urandom(8)"

Actual results:
getrandom("...", 24, GRND_NONBLOCK) = 24
getrandom("...", 8, 0) = 8


Expected results:
getrandom syscall is not used by Python directly.

Additional info:
There is an ongoing effort to make the Kernel's DRBG FIPS compliant. However it is not clear if the goal can be archived in time for RHEL 8.2. Python can use OpenSSL's DRBG through RAND_bytes() API. The DRBG in OpenSSL 1.1.1 is fork-safe.

Comment 1 Christian Heimes 2019-11-20 11:20:27 UTC
Created attachment 1638086 [details]
Experimental patch for Python master

The patch adds RAND_bytes() as preferred RNG source for Python.

A patched Python calls getrandom() three times when OpenSSL initializes its DRBG. There may be more calls under FIPS. os.urandom() does not call getrandom() any more.

$ strace -e getrandom ./python -c "import os; os.urandom(8); os.urandom(8); os.urandom(8)"
getrandom("...", 16, 0) = 16
getrandom("...", 16, 0) = 16
getrandom("...", 16, 0) = 16

Comment 3 Christian Heimes 2019-11-25 14:39:31 UTC
Created attachment 1639525 [details]
Updated FIPS getrandom patch on top of Petr's FIPS branch

https://github.com/encukou/cpython/compare/fips...tiran:fips_getrandom?expand=1

Comment 12 errata-xmlrpc 2020-04-28 16:08:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:1764


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