netfilter bypassed by nessus using UDP packets with source port 53
Hi,
I'm using netfilter/iptables on my Debian woody box (kernel 2.6.11-5), and when I want to audit the security of this box with nessus, it tells me :
"It is possible to by-pass the rules of the remote firewall by sending UDP packets with a source port equal to 53.
An attacker may use this flaw to inject UDP packets to the remote hosts, in spite of the presence of a firewall.
Solution : Review your firewall rules policy
Risk factor : High
BID : 7436, 11237"
It's quite annoying !
here his the output of iptables-save :
# Generated by iptables-save v1.2.6a on Wed Mar 30 16:12:56 2005 *filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [37566:1649215]
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP -A INPUT -i eth0 -p icmp -m icmp ! --icmp-type 13 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 3000 -j ACCEPT -A INPUT -i eth0 -j REJECT --reject-with icmp-port-unreachable -A INPUT -i eth1 -j ACCEPT
-A OUTPUT -o eth1 -j REJECT --reject-with icmp-net-prohibited COMMIT
# Completed on Wed Mar 30 16:12:56 2005
NB: I have a web server on port 3000 since I'm using ntop to monitor the network with eth1
regards,
grumpy
Quoted 6 lines · grumpy
I'm using netfilter/iptables on my Debian woody box (kernel 2.6.11-5), and when I want to audit the security of this box with nessus, it tells me :
"It is possible to by-pass the rules of the remote firewall by sending UDP packets with a source port equal to 53.
An attacker may use this flaw to inject UDP packets to the remote hosts, in spite of the presence of a firewall.
[...]
Quoted 1 line
It's quite annoying !
Have you checked if this alert is true, and not some false positive ? I don't think so. I mean, if Nessus sends an UDP packet (any port), it will get an ICMP port unreachable. That's typically the normal behaviour of an unfiltered box. So Nessus thinks "OK, if there's a firewall between me and this box, then this packet went through".
Speaking of your ruleset, what's the point of :
Quoted 1 line
-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
Linux treats SYN/FIN packets as SYN ones, just as it should be on any RFC compliant stack.
You ICMP rule is also quite bizarre. First, we can get your timestamp looking at your SYN/ACK TCP options when querying port 22 or 3000. Second, your rule implicitly accepts any ICMP paquets, even with INVALID state... Why not instead having something like this :
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p icmp -m icmp --icmp-type 8
ICMP errors will be handled by RELATED state and ping will be accepted (info and netmask requests are not answered by Linux).
Signature · 2 lines
http://sid.rstack.org/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines
Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!
Quoted 9 lines · Cedric Blancher
Quoted 6 lines · grumpy
I'm using netfilter/iptables on my Debian woody box (kernel 2.6.11-5), and when I want to audit the security of this box with nessus, it tells me :
"It is possible to by-pass the rules of the remote firewall by sending UDP packets with a source port equal to 53.
An attacker may use this flaw to inject UDP packets to the remote hosts, in spite of the presence of a firewall.
Quoted 7 lines
[...]
Quoted 1 line
It's quite annoying !
Have you checked if this alert is true, and not some false positive ? I don't think so.
You are right, I do not know how to check this (by the way If you know any documentation that would help, I would be glad to read it).
Quoted 4 lines
I mean, if Nessus sends an UDP packet (any port), it
will get an ICMP port unreachable. That's typically the normal behaviour of an unfiltered box. So Nessus thinks "OK, if there's a firewall between me and this box, then this packet went through".
In that case nessus would think the packets it sent to port 1-65635 (except 22 and 3000) went through as well. Wouldn't it ?
Quoted 10 lines
Speaking of your ruleset, what's the point of :
Quoted 1 line
-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
Linux treats SYN/FIN packets as SYN ones, just as it should be on any RFC compliant stack.
nessus told me something like that :
"the remote host does not discard TCP SYN packet which have FIN flag set. This can allow an attacker to defeat your firewall rules set"
According to you, this is a false positive, thanks for your correction :)
Quoted 3 lines
You ICMP rule is also quite bizarre. First, we can get your timestamp looking at your SYN/ACK TCP options when querying port 22 or 3000.
Yes, that's right, I have not thought about it.
Quoted 2 lines
Second, your rule implicitly accepts any ICMP paquets, even with INVALID state...
I have not thought about it either ...
Quoted 7 lines
Why not instead having something like this :
(quoted diff) +0
-2-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p icmp -m icmp --icmp-type 8ICMP errors will be handled by RELATED state and ping will be accepted (info and netmask requests are not answered by Linux).
Since, it is impossible to prevent somebody to get the timestamp (if I am not mistaken), I think I will try this :)
(If you would know, I tried to prevent someone to get the timestamp after nessus told me something like : "the remote host replies to icmp timestamp requests, it allow an attacker to know about the time set one the machine and defeat all you time based authentication system")
thanks a lot for all these information
regards
grumpy
Quoted 2 lines · grumpy
Quoted 1 line
Have you checked if this alert is true, and not some false positive ?
You are right, I do not know how to check this
You could just hping your box on a port you would listen with netcat and see if data you send it received.
Quoted 2 lines
In that case nessus would think the packets it sent to port 1-65635 (except 22 and 3000) went through as well. Wouldn't it ?
Not for TCP. Because TCP normal behaviour for a closed port is to send a RST/ACK. As you send an ICMP port unreachable, Nessus detects port is in fact filtered.
Quoted 3 lines
nessus told me something like that :
"the remote host does not discard TCP SYN packet which have FIN flag set. This can allow an attacker to defeat your firewall rules set"
Notice the "can". There has been packet filters that got fooled by SYN/FIN packets, because they didn't see them as SYN packets, although destination host did. That's not the case with Linux.
Quoted 1 line
According to you, this is a false positive
I think so.
Quoted 2 lines
Since, it is impossible to prevent somebody to get the timestamp (if I am not mistaken), I think I will try this :)
You can try this (I think it's a better way to filter you stuff) and still block timestamp in TCP packets :)
# echo 0 > /proc/sys/net/ipv4/tcp_timestamps
PS : just beware a typo in my previous post (forgot the ACCEPT target
for pings) -A INPUT -i eth0 -p icmp -m icmp --icmp-type 8 -j ACCEPT
Signature · 2 lines
http://sid.rstack.org/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 2 lines
Quoted 2 lines
Hi! I'm your friendly neighbourhood signature virus. Copy me to your signature file and help me spread!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[SNIP]
Quoted 6 lines
Quoted 6 lines
Speaking of your ruleset, what's the point of :
Quoted 1 line
-A INPUT -i eth0 -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j DROP
Quoted 9 lines
Quoted 2 lines
Linux treats SYN/FIN packets as SYN ones, just as it should be on any RFC compliant stack.
nessus told me something like that :
"the remote host does not discard TCP SYN packet which have FIN flag set. This can allow an attacker to defeat your firewall rules set"According to you, this is a false positive, thanks for your correction :)
The advice or the porition posted to you on this might not be totally correct, if linux indeed does this poor stack behaviour, it is corrected by droppping INVALID packets, I know I tested with various tools to determine how well thpse drop INVALID rules work. INVALID drops also drop packets whence no flags are set, like a default hping packet. So, folks using INVALID drops will find some of their firewall testing tools failing as well.
As this can break some poorly designed apps and windows based protocols, it's best to log these first, then drop so one has a record of what's happening should something start to fail after invoking the drop INVALID rule.
Thanks,
Ron DuFresne
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
admin & senior security consultant: sysinfo.com
http://sysinfo.com
...Love is the ultimate outlaw. It just won't adhere to rules. The most any of us can do is sign on as it's accomplice. Instead of vowing to honor and obey, maybe we should swear to aid and abet. That would mean that security is out of the question. The words "make" and "stay" become inappropriate. My love for you has no strings attached. I love you for free...
-Tom Robins <Still Life With Woodpecker>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFCTY4lst+vzJSwZikRAjMbAKDPOldneWlk3RWnOsBYEGWlwTv12ACeKG7D AyAYtgQvqDvbrNCSkYxo6NY=
=l0ft
-----END PGP SIGNATURE-----