Bug 1474497 - clamav-milter cannot listen on a TCP socket because of SELinux policy
clamav-milter cannot listen on a TCP socket because of SELinux policy
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy (Show other bugs)
7.3
All Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Lukas Vrabec
Milos Malik
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-24 14:40 EDT by Ugo Bellavance
Modified: 2017-10-12 08:21 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-10-12 08:19:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ugo Bellavance 2017-07-24 14:40:52 EDT
Description of problem:
Since clamav-milter version 0.99.2-8, there SElinux prohibits the communication between an MTA and clamav-milter trough a TCP socket. Details:

SELinux is preventing /usr/sbin/clamav-milter from name_bind access on the tcp_socket port 8890.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that clamav-milter should be allowed name_bind access on the port 8890 tcp_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'clamav-milter' --raw | audit2allow -M my-clamavmilter
# semodule -i my-clamavmilter.pp


Additional Information:
Source Context                system_u:system_r:antivirus_t:s0
Target Context                system_u:object_r:milter_port_t:s0
Target Objects                port 8890 [ tcp_socket ]
Source                        clamav-milter
Source Path                   /usr/sbin/clamav-milter
Port                          8890
Host                          atqsmtp2.atqlan.agri-tracabilite.qc.ca
Source RPM Packages           clamav-milter-0.99.2-8.el7.x86_64
Target RPM Packages
Policy RPM                    selinux-policy-3.13.1-102.el7_3.16.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     atqsmtp2.atqlan.agri-tracabilite.qc.ca
Platform                      Linux atqsmtp2.atqlan.agri-tracabilite.qc.ca
                              3.10.0-514.26.2.el7.x86_64 #1 SMP Fri Jun 30
                              05:26:04 UTC 2017 x86_64 x86_64
Alert Count                   60
First Seen                    2017-07-24 11:58:28 EDT
Last Seen                     2017-07-24 14:20:36 EDT
Local ID                      49c123a3-7fe6-46aa-940e-bcb29301b6d9

Raw Audit Messages
type=AVC msg=audit(1500920436.317:268): avc:  denied  { name_bind } for  pid=2858 comm="clamav-milter" src=8890 scontext=system_u:system_r:antivirus_t:s0 tcontext=system_u:object_r:milter_port_t:s0 tclass=tcp_socket


type=SYSCALL msg=audit(1500920436.317:268): arch=x86_64 syscall=bind success=no exit=EACCES a0=3 a1=7ffe14fef1a0 a2=10 a3=7ffe14feeee0 items=0 ppid=1 pid=2858 auid=4294967295 uid=989 gid=986 euid=989 suid=989 fsuid=989 egid=986 sgid=986 fsgid=986 tty=(none) ses=4294967295 comm=clamav-milter exe=/usr/sbin/clamav-milter subj=system_u:system_r:antivirus_t:s0 key=(null)

Hash: clamav-milter,antivirus_t,milter_port_t,tcp_socket,name_bind

It looks that the deamon is now transitioning to system_u:system_r:antivirus_t:s0 context, while it was system_u:system_r:init_t before.

Is system_u:system_r:init_t supposed to be allowed to connect to clamav-milter's socket by default?  I don't remember adding any SELinux-related configuration.
 
https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2017-85d282a75d

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-102.el7_3.16.noarch

How reproducible:
Always

Steps to Reproduce:
1.Install the necessary rpms (see below)
2.Configure clamav-milter to listen on a TCP socket (see config below)
3.Configure postfix to use a TCP socket to communicate with clamav-milter (smtpd_milters = inet:localhost:8890)
4.Try sending an email (easiest way is via telnet localhost 25)

Actual results:
Postfix refuses to accept the message because it cannot connect to the milter

Expected results:
Postfix sends the message to the milter, which sends the message to clamd socket, and return it to postfix for delivery, if clean.

Additional info:
Here are the rpms I have on my system:
clamav-server-0.99.2-8.el7.x86_64
clamav-scanner-0.99.2-8.el7.noarch
clamav-update-0.99.2-8.el7.x86_64
clamav-filesystem-0.99.2-8.el7.noarch
clamav-scanner-systemd-0.99.2-8.el7.noarch
clamav-0.99.2-8.el7.x86_64
clamav-server-systemd-0.99.2-8.el7.noarch
clamav-milter-systemd-0.99.2-8.el7.noarch
clamav-milter-0.99.2-8.el7.x86_64
clamav-data-0.99.2-8.el7.noarch
clamav-lib-0.99.2-8.el7.x86_64

/etc/mail/clamav-milter.conf contents:

AddHeader add
AllowSupplementaryGroups yes
ClamdSocket tcp:127.0.0.1
LogSyslog yes
MilterSocket inet:8890@localhost
OnInfected Reject
RejectMsg Message rejected: Infected by %v
User clamilt
Comment 3 Lukas Vrabec 2017-10-12 08:19:45 EDT
We're going to close this bug as WONTFIX because

 * of limited capacity of selinux-policy developers
 * the bug is related to EPEL component or 3rd party SW only
 * the bug appears in unsupported configuration 

We believe this bug can be fixed via a local policy module.
For more information please see: 

 * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/sect-security-enhanced_linux-troubleshooting-fixing_problems#sect-Security-Enhanced_Linux-Fixing_Problems-Allowing_Access_audit2allow

If you disagree, please re-open the bug.
Comment 4 Lukas Vrabec 2017-10-12 08:21:36 EDT
We're going to close this bug as WONTFIX because

 * of limited capacity of selinux-policy developers
 * the bug is related to EPEL component or 3rd party SW only
 * the bug appears in unsupported configuration 

We believe this bug can be fixed via a local policy module.
For more information please see: 

 * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/sect-security-enhanced_linux-troubleshooting-fixing_problems#sect-Security-Enhanced_Linux-Fixing_Problems-Allowing_Access_audit2allow

If you disagree, please re-open the bug.

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