Bug 782177 - FTP servers may need to connect to ports outside 32768-61000
Summary: FTP servers may need to connect to ports outside 32768-61000
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 16
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-16 18:43 UTC by Göran Uddeborg
Modified: 2013-02-13 18:50 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-13 18:50:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Göran Uddeborg 2012-01-16 18:43:12 UTC
Description of problem:
Setroubleshoot reported that my FTP server was denied to connect to port number 62749.

type=AVC msg=audit(1326532148.24:8399): avc:  denied  { name_connect } for  pid=28036 comm="vsftpd" dest=62749 scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket

Using sesearch I figured out that by default ftpd_t is allowed to do name_connect to ephemeral_port_t, 32768-61000.  This is the range Linux uses for temporary ports.  But when the FTP server does connect() (in FTP's active mode) it is the client, not the server that selects the port.  According to Wikipedia (http://en.wikipedia.org/wiki/Ephemeral_port), IANA actually suggests the range 49152-65535, and some other OS:es use 1025-5000.

It probably doesn't add any value to restrict the port clients may use, so I would suggest to allow ftpd_t to name_connect to the full range 1024-65536.

I note that ftpd_t is similarly restricted to name_bind to the ephemeral port type.  In that case it IS the Linux kernel that control what port is selected.  So in that case it would make sense to keep the restriction.

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.10.0-71.fc16.noarch

How reproducible:
Only once in a while.  It happens when a client connects from a system that doesn't follow Linux' port assignment, when that client uses active mode, and when that system happens to choose a port outside the 32768-61000 range.

Steps to Reproduce:
1. Start vsftpd (or presumably, any other FTP server)
2. Connect in active mode from a system using a different range.
  
Actual results:
Selinux denies the server to connect to the client's port.

Expected results:
Successful transfer.

Additional info:
I noticed that if allow_ypbind is enabled, ftpd_t is allowed to name_connect to, among other things, unreserved_port_t.  So that is a workaround, but shouldn't be necessary to run an FTP server, I guess.  (I'm not quite sure what the connection is between ftpd_t and ypbind, but that's beside the point.)

Comment 1 Daniel Walsh 2012-01-16 19:02:46 UTC
I would prefer to add a boolean ftpd_connect_all_unreserved and allow it to connect to ports > 1023

Comment 2 Göran Uddeborg 2012-01-16 22:13:52 UTC
That would work too, if you prefer.

I don't really see under what circumstances one would have that turned off.  But it wouldn't cause any real problems either, I guess.

Comment 3 Fedora End Of Life 2013-01-16 15:42:37 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Fedora End Of Life 2013-02-13 18:50:23 UTC
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.


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