Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-29-2009, 06:00 PM
|
#1
|
Member
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35
Rep:
|
ip_conntrack_ftp and SSL / TLS
FTP, i.e., FTPS, needs open ports for data transfer; these ports are negotiated by the PORTS command. There are numerous threads explaining that ip_conntrack_ftp can not decrypt TLS-encrypted traffic to figure out which ports to open in the firewall. This is certainly true if the firewall runs on a different machine than the FTP server.
However, I also have a firewall (iptables) running on the same machine that hosts the ftp server (vsftpd). Did anybody figure out whether it is possible for iptables and ip_conntrack_ftp to make use of ssl and the private key to effectively track which ports to open?
If no solution using ip_conntrack_ftp is available, I need to keep some ports permanently and unconditionally open for input. SFTP (FTP over SSH) is no alternative for me.
Regards, A_
|
|
|
09-30-2009, 02:54 AM
|
#2
|
LQ Newbie
Registered: Feb 2005
Posts: 3
Rep:
|
Please post what is your real problem? The client can't connect? Server can't connect to client after PORT command?
|
|
|
09-30-2009, 12:22 PM
|
#3
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep:
|
Quote:
Originally Posted by Al_
However, I also have a firewall (iptables) running on the same machine that hosts the ftp server (vsftpd). Did anybody figure out whether it is possible for iptables and ip_conntrack_ftp to make use of ssl and the private key to effectively track which ports to open?
|
I don't know whether said module can be enticed into working with ftps, but IMO your solution is acceptable.
Code:
# sysctl -a | grep 'port_range'
net.ipv4.ip_local_port_range = 32768 61000
So you open x - y (32768 - 61000 in my case) on your host-level firewall and let the passive ftp clients do their thing. I do the same thing on a FreeBSD host w/ PF.
-------
By the way: you could make the range that you open much smaller by specifying pasv_min_port and pasv_max_port in vsftpd.conf.
Last edited by anomie; 09-30-2009 at 12:26 PM.
Reason: removed comment about tcp connection state.
|
|
|
09-30-2009, 05:06 PM
|
#4
|
Member
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35
Original Poster
Rep:
|
Quote:
Originally Posted by panky
Please post what is your real problem? The client can't connect? Server can't connect to client after PORT command?
|
Is it a problem? I do not know. Fact is that my tight iptables settings on the computer hosting the vsftp server work fine for unencrypted FTP in passive mode but not for FTPS. The reason is very obvious: I have an iptables rule that accepts incoming ftp data if 'state RELATED,ESTABLISHED'. ip_conntrack_ftp correctly inspects unencrypted FTP traffic (on port 21) and thus knows, which traffic on data ports is RELATED. ip_conntrack_ftp is not able to inspect encrypted traffic (after all, avoiding 'inspection' is the goal of encryption), thus data traffic is not identified as RELATED and is thus dropped.
Consequence: login by FTPS works, but as soon as passive mode is switched on for directory listing, the firewall blocks.
As said, this behavior is fully understandable and due to encryption of the PASV / PORT commands. However, the option of having ports open seems to me to be a potential safety risk.
Regards
A_
|
|
|
09-30-2009, 05:19 PM
|
#5
|
Member
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35
Original Poster
Rep:
|
Quote:
Originally Posted by anomie
...So you open x - y (32768 - 61000 in my case) on your host-level firewall and let the passive ftp clients do their thing. I do the same thing on a FreeBSD host w/ PF. ...
|
Thanks. Is it safe to have ports (restricted in vsftpd.conf to a small range) continuously open / unprotected?
I could speculate on another solution: is it possible using ip_conntrack (NOT ip_conntrack_ftp) to dynamically figure out which client ip-address is connected to port 21? Is the following iptables rule (in pseudocode) possible? How to word?
Code:
iptables -A INPUT -p tcp -s the ip-address that is currently connected to port 21 -i eth0 -j ACCEPT
A_
|
|
|
10-01-2009, 12:19 PM
|
#7
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep:
|
Right, the vsftpd-related ports in that range are only opened when a PASV mode transfer is set up.
|
|
|
10-02-2009, 02:55 AM
|
#8
|
Member
Registered: Jun 2009
Location: Switzerland
Distribution: Ubuntu
Posts: 35
Original Poster
Rep:
|
@anomie and chrism01: you seem in agreement that it is safe to have iptables accept packets on ports that vsftpd might choose for the data connection. Thanks.
This leaves me with the more philosophical question: why did somebody take the effort to write ip_conntrack_ftp (for use with non-encrypted ftp), if it is equally safe without ip_conntrack_ftp?
Regards, A_
|
|
|
10-02-2009, 03:58 AM
|
#9
|
LQ Newbie
Registered: Feb 2005
Posts: 3
Rep:
|
Maybe you should ask: What for is firewall?
Leaving this ports range accepted on firewall can lead to abuse of your server. In case you have untrusted users on your server or one of services (ftp, www, smtp, etc.) running on it can be compromised your server can be abused to set up arbitrary service accepting connections on port from passive-ftp range. It can be for eg. psyBNC bot used as 'Command Center' for botnets.
If in your case you are the only user you don't have to worry about it.
|
|
|
10-02-2009, 03:37 PM
|
#10
|
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Rep:
|
As I said earlier, IMO this solution is acceptable (not ideal).
@Al_: please check post #3 again for tips on how to restrict the passive port range that vsftpd uses. You can set up your iptables rule to match that same range, thus narrowing the potential attack surface.
Moreover, like any service, this is not something you put into place and then forget about for a few years. I'm giving advice with the assumption that you are actually reading your logs and monitoring system activity.
|
|
|
All times are GMT -5. The time now is 08:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|