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 2043599 - postfix cannot use certs stored in dovecot certs directory
Summary: postfix cannot use certs stored in dovecot certs directory
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.5
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.6
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-21 15:32 UTC by Renaud Métrich
Modified: 2022-05-10 16:25 UTC (History)
4 users (show)

Fixed In Version: selinux-policy-3.14.3-92.el8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 15:15:49 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-109131 0 None None None 2022-01-21 15:35:23 UTC
Red Hat Product Errata RHBA-2022:1995 0 None None None 2022-05-10 15:16:09 UTC

Description Renaud Métrich 2022-01-21 15:32:02 UTC
Description of problem:

When configuring smtpd to use certs stored in dovecot's certs directory, the following AVCs are seen:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=PROCTITLE msg=audit(01/19/2022 17:27:01.181:7173515) : proctitle=smtpd -n smtps -t inet -u -o stress= -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o
type=SYSCALL msg=audit(01/19/2022 17:27:01.181:7173515) : arch=x86_64 syscall=openat success=no exit=EACCES(Permission denied) a0=0xffffff9c a1=0x56000dcbef00 a2=O_RDONLY a3=0x0 items=0 ppid=1870242 pid=1914640 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smtpd exe=/usr/libexec/postfix/smtpd subj=system_u:system_r:postfix_smtpd_t:s0 key=(null)
type=AVC msg=audit(01/19/2022 17:27:01.181:7173515) : avc:  denied  { search } for  pid=1914640 comm=smtpd name=dovecot dev="dm-0" ino=67970523 scontext=system_u:system_r:postfix_smtpd_t:s0 tcontext=system_u:object_r:dovecot_cert_t:s0 tclass=dir permissive=0
...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

audit2allow shows:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
#============= postfix_smtpd_t ==============
allow postfix_smtpd_t dovecot_cert_t:dir search;
allow postfix_smtpd_t dovecot_cert_t:file getattr;
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This happens because postfix policy only have this:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
miscfiles_read_generic_certs(postfix_domain)
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

which ends up reading cert_t stuff only.

I think it's harmless to allow postfix from reading all kind of certs, something like this:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
miscfiles_read_all_certs(postfix_domain)
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


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

selinux-policy-3.14.3-80.el8_5.2.noarch

How reproducible:

Always


Steps to Reproduce:
1. Configure postfix for TLS usage and store certs in dovecot dir

  /etc/postfix/main.cf:
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
  smtpd_tls_cert_file = /etc/pki/dovecot/certs/some.cert
  smtpd_tls_key_file = /etc/pki/dovecot/certs/some.key
  -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Actual results:

AVCs above.

Expected results:

No AVC


Additional info:

If allowing all certs is too much from security perspective, then an attribute for "mailer certs" should be created instead.
For now dovecot_cert_t registered through "miscfiles_cert_type(dovecot_cert_t)"

Comment 1 Zdenek Pytela 2022-01-21 17:02:31 UTC
We currently have these types or certificates:

# seinfo -xa cert_type

Type Attributes: 1
   attribute cert_type;
        cert_t
        dovecot_cert_t
        fwupd_cert_t
        home_cert_t (not in rhel8)
        ipa_cert_t (in ipa-selinux)
        pki_tomcat_cert_t
        slapd_cert_t

Comment 2 Patrik Koncity 2022-02-02 19:13:09 UTC
Hi Renaud, 

please can you reproduce the scenario again and attach here full AVC's messages in permissive mode?

Steps to enable full auditing and permissive SELinux mode:

1) Open the /etc/audit/rules.d/audit.rules file in an editor.
2) Remove the following line if it exists:
-a task,never
3) Add the following line to the end of the file:
-w /etc/shadow -p w
4) Restart the audit daemon:
  # service auditd restart
5) Open the /etc/selinux/config file in an editor.
change line
SELINUX=enforcing
to
SELINUX=permissive
6) Re-run your scenario 
7) Collect AVC denials:
# ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts today

Thank you,
Patrik

Comment 4 Zdenek Pytela 2022-02-11 16:52:51 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/1068

Allowing access to dovecot_cert_t only, given the output in #c1 I don't think there is a reason to read other certificates.

Comment 5 Zdenek Pytela 2022-02-14 15:36:34 UTC
To backport:
commit 03e93e0ddd2b3c41138bd3cbc20ea7bd61f58502 (HEAD -> rawhide, upstream/rawhide)
Author: Zdenek Pytela <zpytela>
Date:   Fri Feb 11 17:48:59 2022 +0100

    Allow postfix_domain read dovecot certificates

Comment 14 errata-xmlrpc 2022-05-10 15:15:49 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 (selinux-policy bug fix and enhancement update), 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-2022:1995


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