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 1337141 - python-cryptography is broken in a mod_wsgi environment due to execmem requirement
Summary: python-cryptography is broken in a mod_wsgi environment due to execmem requir...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-cryptography
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Nathaniel McCallum
QA Contact: Kaleem
URL:
Whiteboard:
Depends On:
Blocks: 1298243
TreeView+ depends on / blocked
 
Reported: 2016-05-18 11:47 UTC by Patrick Uiterwijk
Modified: 2020-04-15 14:29 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-07 14:19:40 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Delay locking callback patch for python-cryptography 0.8.3 (1.20 KB, patch)
2016-05-18 17:33 UTC, Christian Heimes
no flags Details | Diff
Alternative: monkey patch for Ipsilon (2.82 KB, patch)
2016-05-18 19:40 UTC, Christian Heimes
no flags Details | Diff

Description Patrick Uiterwijk 2016-05-18 11:47:25 UTC
Description of problem:
When using python-cryptography in mod_wsgi, the call "cls.ffi.callback("void(int, int, const char *, int)", cls._lock_cb)" in cryptography/hazmat/bindings/openssl/binding.py requires an execmem permission, which httpd doesn't have.

Version-Release number of selected component (if applicable):
python-cryptography 0.8.2

How reproducible:
Consistent

Steps to Reproduce:
1  sestatus
2  yum install -y python-cffi mod_wsgi httpd python-cryptography
3  yum update -y
4  vi /etc/httpd/conf.d/test.conf
5  vi /usr/libexec/cryptotest
6  service httpd start
7  tail -f /var/log/httpd/error_log /var/log/audit/audit.log 

test.conf:
WSGIScriptAlias / /usr/libexec/cryptotest
<Directory /usr/libexec>
    Require all granted
</Directory>

cryptotest:
print 'Import fernet'
from cryptography.fernet import Fernet
key = Fernet.generate_key()
f = Fernet(key)
print 'Done with fernet'

Visit web server.


Actual results:
See 500 server error.

==> /var/log/httpd/error_log <==
[Tue May 17 12:40:23.225569 2016] [:error] [pid 22291] Import fernet
[Tue May 17 12:40:23.250668 2016] [core:notice] [pid 22287] AH00052: child pid 22290 exit signal Segmentation fault (11)

==> /var/log/audit/audit.log <==
type=AVC msg=audit(1463488824.018:187): avc:  denied  { execmem } for  pid=22291 comm="httpd" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process


Expected results:
404 (because the wsgi doesn't have an "application".

Additional info:
Moving the if not cls._lock_cb_handle: block after the if cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL: block fixes the issue, because seemingly CPython ssl has its own locking.

Comment 2 Christian Heimes 2016-05-18 17:33:04 UTC
Created attachment 1159018 [details]
Delay locking callback patch for python-cryptography 0.8.3

The creation of the locking callback handler is delayed. With CPython the internal _ssl takes care of registering lock handlers.

Comment 4 Christian Heimes 2016-05-18 19:40:45 UTC
Created attachment 1159056 [details]
Alternative: monkey patch for Ipsilon

Untested monkey patch for Ipsilon


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