Bug 2038955

Summary: FR cannot create a TCP socket (avc: denied { name_connect } for pid comm="radiusd" dest=1813 )
Product: Red Hat Enterprise Linux 8 Reporter: Filip Dvorak <fdvorak>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: low Docs Contact:
Priority: low    
Version: 8.6CC: lvrabec, mmalik, ssekidde
Target Milestone: rcKeywords: AutoVerified, Triaged
Target Release: 8.6   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.14.3-87.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:15:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Filip Dvorak 2022-01-10 16:04:28 UTC
Description of problem:
FR can forward auth or acct messages to the second FR server. It uses UDP  protocol by default but in proxy.conf it is possible to configure to use TCP protocol between these servers. 
The problem is that the FR server cannot create a TCP connection because of selinux policy.
 
Version-Release number of selected component (if applicable):
RHEL-8.6.0-20220102.3
freeradius-3.0.20-12.module+el8.6.0+13617+542eca26.x86_64
selinux-policy-3.14.3-85.el8.noarch

How reproducible:


Steps to Reproduce:
1. dnf install freeradius freeradius-utils -y
2. configure home_server in /etc/raddb/proxy.conf
realm NULL {
}

realm redhat.com {
    pool = pool_redhat.com
    nostrip
}

home_server redhat.com {
    type = auth+acct
    ipaddr = #(random ip_addr)
    port = 1812
    secret = testing123
    status_check = none
    proto = tcp

}

home_server_pool pool_redhat.com {
    type = fail-over
    home_server = redhat.com
}

3. systemctl start radiusd
4. echo 'User-Name=localuser,Acct-Session-Id=60000061,Acct-Status-Type=Start,NAS-IP-Address=192.168.111.100,NAS-Port=0'| radclient -x localhost:1813 acct testing123 

Actual results:
radiusd log:
...
Error: Failed opening new proxy socket 'proxy (0.0.0.0, 0) -> home_server ($ip_addr, 1813)' : Failed connecting socket: Permission denied
...

AVC message:
type=PROCTITLE msg=audit(1641828609.991:359): proctitle=2F7573722F7362696E2F72616469757364002D64002F6574632F7261646462
type=SYSCALL msg=audit(1641828609.991:359): arch=c000003e syscall=42 success=no exit=-13 a0=8 a1=7f71c6f22a50 a2=10 a3=7f71c6f22ad8 items=0 ppid=1 pid=21784 auid=4294967295 uid=95 gid=95 euid=95 suid=95 fsuid=95 egid=95 sgid=95 fsgid=95 tty=(none) ses=4294967295 comm="radiusd" exe="/usr/sbin/radiusd" subj=system_u:system_r:radiusd_t:s0 key=(null)
type=AVC msg=audit(1641828609.991:359): avc:  denied  { name_connect } for  pid=21784 comm="radiusd" dest=1813 scontext=system_u:system_r:radiusd_t:s0 tcontext=system_u:object_r:radacct_port_t:s0 tclass=tcp_socket permissive=0

Expected results:
The FR should forward acct or auth messages to the home_server (ip_addr in a proxy.conf) via TCP

Additional info:
It is possible to use TCMS tests -> TCMS#597393	/CoreOS/freeradius/Multihost/copy-acct-to-home-server-sanity [freeradius:3.0 perl:5.26]

Comment 1 Milos Malik 2022-01-10 16:26:36 UTC
Caught in enforcing mode:
----
type=PROCTITLE msg=audit(01/10/2022 11:23:13.050:338) : proctitle=/usr/sbin/radiusd -d /etc/raddb 
type=SOCKADDR msg=audit(01/10/2022 11:23:13.050:338) : saddr={ saddr_fam=inet laddr=10.0.137.191 lport=1813 } 
type=SYSCALL msg=audit(01/10/2022 11:23:13.050:338) : arch=x86_64 syscall=connect success=no exit=EACCES(Permission denied) a0=0x8 a1=0x7f9294f4ca50 a2=0x10 a3=0x7f9294f4cad8 items=0 ppid=1 pid=21216 auid=unset uid=radiusd gid=radiusd euid=radiusd suid=radiusd fsuid=radiusd egid=radiusd sgid=radiusd fsgid=radiusd tty=(none) ses=unset comm=radiusd exe=/usr/sbin/radiusd subj=system_u:system_r:radiusd_t:s0 key=(null) 
type=AVC msg=audit(01/10/2022 11:23:13.050:338) : avc:  denied  { name_connect } for  pid=21216 comm=radiusd dest=1813 scontext=system_u:system_r:radiusd_t:s0 tcontext=system_u:object_r:radacct_port_t:s0 tclass=tcp_socket permissive=0 
----

Caught in permissive mode:
----
type=PROCTITLE msg=audit(01/10/2022 11:25:34.687:353) : proctitle=/usr/sbin/radiusd -d /etc/raddb 
type=SOCKADDR msg=audit(01/10/2022 11:25:34.687:353) : saddr={ saddr_fam=inet laddr=10.0.137.191 lport=1813 } 
type=SYSCALL msg=audit(01/10/2022 11:25:34.687:353) : arch=x86_64 syscall=connect success=no exit=EHOSTUNREACH(No route to host) a0=0x8 a1=0x7f45c5905a50 a2=0x10 a3=0x7f45c5905ad8 items=0 ppid=1 pid=21307 auid=unset uid=radiusd gid=radiusd euid=radiusd suid=radiusd fsuid=radiusd egid=radiusd sgid=radiusd fsgid=radiusd tty=(none) ses=unset comm=radiusd exe=/usr/sbin/radiusd subj=system_u:system_r:radiusd_t:s0 key=(null) 
type=AVC msg=audit(01/10/2022 11:25:34.687:353) : avc:  denied  { name_connect } for  pid=21307 comm=radiusd dest=1813 scontext=system_u:system_r:radiusd_t:s0 tcontext=system_u:object_r:radacct_port_t:s0 tclass=tcp_socket permissive=1 
----

Comment 2 Zdenek Pytela 2022-01-14 15:24:45 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/1002

Comment 4 Zdenek Pytela 2022-01-17 16:14:10 UTC
To backport:
commit cb03984acddb7a126e2aa854b52db767b15760a0 (HEAD -> rawhide, upstream/rawhide)
Author: Zdenek Pytela <zpytela>
Date:   Fri Jan 14 16:15:18 2022 +0100

    Allow radiusd connect to the radacct port

Comment 14 errata-xmlrpc 2022-05-10 15:15: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 (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