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 1447278 - Missing or incomplete SELinux policy for Let's Encrypt (certbot)
Summary: Missing or incomplete SELinux policy for Let's Encrypt (certbot)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.3
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 1594286 1651783
TreeView+ depends on / blocked
 
Reported: 2017-05-02 09:59 UTC by Robert Scheck
Modified: 2019-08-06 12:52 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 12:51:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3023171 0 None None None 2017-05-04 11:33:01 UTC
Red Hat Product Errata RHBA-2019:2127 0 None None None 2019-08-06 12:52:06 UTC

Description Robert Scheck 2017-05-02 09:59:35 UTC
Description of problem:
It seems like the SELinux policy for Let's Encrypt (certbot) is missing or
incomplete.

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.13.1-102.el7_3.16.noarch
certbot-0.13.0-1.el7.noarch
python2-certbot-0.13.0-1.el7.noarch
python2-certbot-apache-0.13.0-1.el7.noarch

How reproducible:
Install certbot with defaults for usage with Apache webserver including a
cronjob: 5 7,19 * * * root /usr/bin/certbot renew -q -n --rsa-key-size 4096

Actual results:
type=AVC msg=audit(1493485511.139:697789): avc:  denied  { getattr } for  pid=397 comm="httpd" path="/var/lib/letsencrypt/65Z3fG09FSZuMGmYeWh-iuEv-nTzUW9k8ZVhmuWmX3I.crt" dev="dm-1" ino=266553 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:cron_var_lib_t:s0 tclass=file
type=SYSCALL msg=audit(1493485511.139:697789): arch=x86_64 syscall=stat success=no exit=EACCES a0=7f0cde100db0 a1=7fffab954cd0 a2=7fffab954cd0 a3=43 items=0 ppid=1 pid=397 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=httpd exe=/usr/sbin/httpd subj=system_u:system_r:httpd_t:s0 key=(null)

audit2allow reports the file in question as mislabeled. Given the file is
generated by certbot (and does not exist due to SELinux being enforced), it
seems to require some policy adaption?

Expected results:
No AVC denied messages when using Let's Encrypt (certbot).

Comment 2 Milos Malik 2017-05-02 12:56:41 UTC
It seems that selinux-policy does not define better contexts for some of the certbot directories:

# matchpathcon /var/log/letsencrypt/
/var/log/letsencrypt	system_u:object_r:var_log_t:s0
# matchpathcon /var/lib/letsencrypt/
/var/lib/letsencrypt	system_u:object_r:var_lib_t:s0
# ls -Z /var/log/letsencrypt/
-rw-r--r--. root root system_u:object_r:var_log_t:s0   letsencrypt.log
-rw-r--r--. root root system_u:object_r:var_log_t:s0   letsencrypt.log.1
-rw-r--r--. root root system_u:object_r:var_log_t:s0   letsencrypt.log.2
# ls -Z /var/lib/letsencrypt/
# ls -dZ /var/lib/letsencrypt/
drwxr-xr-x. root root system_u:object_r:var_lib_t:s0   /var/lib/letsencrypt/
# semanage fcontext -l | grep letsencrypt
/etc/(letsencrypt|certbot)/(live|archive)(/.*)?    all files          system_u:object_r:cert_t:s0 
#

Comment 3 Robert Scheck 2017-05-02 16:34:35 UTC
It seems like the following makes Let's Encrypt (certbot) for renewals 
happy, while I do not consider this as a good solution, more a workaround:

allow httpd_t cron_var_lib_t:file { getattr open read };

Comment 4 Robert Scheck 2017-05-02 16:40:53 UTC
Cross-filed case 01841927 at the Red Hat customer portal.

Comment 10 Milos Malik 2018-09-17 15:29:17 UTC
Following rule is missing:

type_transition unconfined_service_t var_lib_t : dir cert_t "letsencrypt";

As a result, /var/lib/letsencrypt is created with incorrect var_lib_t context.

# rpm -qa selinux\* | sort
selinux-policy-3.13.1-226.el7.noarch
selinux-policy-devel-3.13.1-226.el7.noarch
selinux-policy-doc-3.13.1-226.el7.noarch
selinux-policy-minimum-3.13.1-226.el7.noarch
selinux-policy-mls-3.13.1-226.el7.noarch
selinux-policy-sandbox-3.13.1-226.el7.noarch
selinux-policy-targeted-3.13.1-226.el7.noarch
#

Comment 12 Chuck Wilson 2018-12-18 19:06:23 UTC
For what it's worth, two paths are missing the `cert_t` context in the selinux-policy package:
1. /etc/(letsencrypt|certbot)/(live|archive)(/.*)?
   This is added via `semanage` in the postinstall script of the EPEL package
2. /var/log/letsencrypt(/.*)?
   This must currently be added manually

Comment 20 errata-xmlrpc 2019-08-06 12:51:45 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/RHBA-2019:2127


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