Bug 2528280

Summary: SSH TCP port forwarding fails with "connect failed" due to SELinux sshd_session_t missing name_connect on unreserved ports
Product: [Fedora] Fedora Reporter: Henry Luengas <redhat-bugzilla>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 44CC: dwalsh, johannes.hack, lvrabec, mmalik, omosnacek, pkoncity, vmojzis, zpytela
Target Milestone: ---Keywords: Regression, SELinux
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-44.9-1.fc44 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-09-16 00:54:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Henry Luengas 2026-09-03 22:02:17 UTC
Following the update to selinux-policy-targeted-44.8-1.fc44 (which removed permissive mode for sshd_session_t in 44.7+), SSH TCP port forwarding fails with a "connect failed" channel error.

This impacts all SSH port forwarding features, including local port forwarding (`ssh -L`), dynamic SOCKS proxying (`ssh -D`), and developer tools relying on SSH tunnels like VS Code Remote-SSH.

Reproducible: Always

Steps to Reproduce:
1. From a client machine running VS Code with the "Remote - SSH" extension, connect to a Fedora 44 host running selinux-policy-targeted-44.8-1.fc44:

2. Observe the connection sequence as VS Code downloads and starts the remote server CLI (which listens locally on an ephemeral port, e.g. 127.0.0.1:35793).

3. VS Code attempts to establish its SSH port forwarding tunnel to that remote port.

====OR=====

1. On the target Fedora host, start a simple listener on an unreserved port:
    $ python3 -m http.server 35793 --bind 127.0.0.1

2. From a client machine, initiate an SSH connection with local port forwarding:
    $ ssh -v -N -L 35793:127.0.0.1:35793 user@fedora-host

3. From the client machine, attempt to connect to the forwarded port:
    $ curl http://127.0.0.1:35793
Actual Results:
VS Code fails to establish the connection with:
`Failed to set up socket for dynamic port forward to remote port 35793: Socket closed. TCP port forwarding may be disabled, or the remote server may have crashed.`
`stderr> channel 3: open failed: connect failed: open failed`

The Linux kernel blocks the connection with the following SELinux AVC denial in /var/log/audit/audit.log:
type=AVC msg=audit(1788469375.728:1230): avc:  denied  { name_connect } for  pid=3825095 comm="sshd- session" dest=35793 scontext=system_u:system_r:sshd_session_t:s0-s0:c0.c1023 tcontext=system_u:object_r:ephemeral_port_t:s0 tclass=tcp_socket permissive=0

Expected Results:
The SSH tunnel forwards traffic to 127.0.0.1:35793 and the connection succeeds normally.

Additional Information:
Packages / Environment:

- OS: Fedora Linux 44 (Server Edition) x86_64
- Kernel: 7.1.12-200.fc44.x86_64
- selinux-policy-targeted-44.8-1.fc44
- openssh-server-10.2p1-14.fc44

Root Cause:
In OpenSSH 9.8+, `sshd-session` handles session channel multiplexing. When an SSH client requests a direct-tcpip channel, the `sshd-session` process (running in domain `sshd_session_t`) initiates the TCP connection to the target port.

Because `sshd_session_t` was recently switched from Permissive to Enforcing mode (changelog 44.7-1: "- Remove permissive setting for sshd_auth_t and sshd_session_t"), and the policy lacks `name_connect` rules for `unreserved_port_t`, `ephemeral_port_t`, or generic `port_t`, any outbound TCP connection initiated by `sshd-session` to unreserved ports is denied by SELinux with EACCES.

Workaround verified:
Installing a custom policy module granting `sshd_session_t` the `name_connect` permission on `unreserved_port_t`, `ephemeral_port_t`, and `port_t` immediately restores functionality.

Suggested fix:
In `policy/modules/services/ssh.te`, allow `sshd_session_t` to connect to unreserved ports (e.g., via `corenet_tcp_connect_all_unreserved_ports(sshd_session_t)` or an appropriate boolean/macro).

Comment 1 Fedora Update System 2026-09-14 14:37:49 UTC
FEDORA-2026-1413268892 (selinux-policy-44.9-1.fc44) has been submitted as an update to Fedora 44.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-1413268892

Comment 2 Fedora Update System 2026-09-15 01:42:48 UTC
FEDORA-2026-1413268892 has been pushed to the Fedora 44 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2026-1413268892`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2026-1413268892

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2026-09-16 00:54:37 UTC
FEDORA-2026-1413268892 (selinux-policy-44.9-1.fc44) has been pushed to the Fedora 44 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 johannes.hack 2026-09-17 14:10:16 UTC
I was wondering if this problem still exists for me with selinux-policy-44.9-1.fc44 using Jetbrains Remote Development via SSH. 
Steps to Reproduce:
1. From a client Jetbrains (Clion) instance, connect to a Fedora 44 host running selinux-policy-targeted-44.9-1.fc44:

2. Connection hangs on last step: connecting to remote host, host alerts with following SELinux alert until clion stops trying to connect.

System info:
- OpenSSH_10.2p1
- Fedora Linux 44 KDE Plasma Desktop
- selinux-policy-targeted-44.9-1.fc44

I am receiving this SELinux Alert:
SELinux is preventing sshd-session from name_connect access on the tcp_socket port 5990.

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

If you believe that sshd-session should be allowed name_connect access on the port 5990 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 'sshd-session' --raw | audit2allow -M my-sshdsession
# semodule -X 300 -i my-sshdsession.pp

Additional Information:
Source Context                system_u:system_r:sshd_session_t:s0-s0:c0.c1023
Target Context                system_u:object_r:vnc_port_t:s0
Target Objects                port 5990 [ tcp_socket ]
Source                        sshd-session
Source Path                   sshd-session
Port                          5990
Host                          remote
Source RPM Packages           
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-44.9-1.fc44.noarch
Local Policy RPM              selinux-policy-targeted-44.9-1.fc44.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     remote
Platform                      Linux remote 7.2.5-200.fc44.x86_64 #1 SMP
                              PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026
                              x86_64
Alert Count                   98
First Seen                    2026-09-17 13:35:12 CEST
Last Seen                     2026-09-17 15:16:29 CEST
Local ID                      38ed459b-4b0f-4b83-966d-7d26b7d157a4

Raw Audit Messages
type=AVC msg=audit(1789650989.140:552): avc:  denied  { name_connect } for  pid=2151 comm="sshd-session" dest=5990 scontext=system_u:system_r:sshd_session_t:s0-s0:c0.c1023 tcontext=system_u:object_r:vnc_port_t:s0 tclass=tcp_socket permissive=0


Hash: sshd-session,sshd_session_t,vnc_port_t,tcp_socket,name_connect