new match extension to implement port knocking in one
Quoted 42 lines · Michael Rash
Quoted 32 lines · J. Federico Hernandez
Quoted 30 lines · Alexey Toptygin
Quoted 5 lines · Luis Floreani
Quoted 3 lines
Quoted 3 lines
If you're interested in port knocking, you might want to read this
paper: http://www.acsac.org/2005/abstracts/156.html It coverssecurity
Quoted 1 line
Quoted 1 line
Quoted 1 line
issues relating to port knocking in detail, and presents an
architecture
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
for solving most of them.
Full disclosure: I wrote that paper. Feel free to contact me if you have questions.
Rennie deGraaf
In our implementation, for security, we are using the Tumbler protocol,
we
Quoted 5 lines
Quoted 2 lines
found it simple yet powerful, check it out here:
http://tumbler.sourceforge.net/.It seems that Tumbler is not capable of working across NAT, unless the client can somehow obtain its public IP address. Also, it relies on
clocks
Quoted 4 lines
being synchronized, since authentication will fail if the UTC time in minutes is not identical on the client and server. Tumbler is not as stealthy as the techniques in Rennie deGraaf's paper, since it uses an open UDP port.
Quoted 8 lines
Quoted 1 line
Why not use fwknop in Single Packet Authorization mode?:
Why not using iptables to implement port knocking? You won't depend on any daemon.
If you know the iptables syntaxis, you don't need to learn the daemon syntaxis or its configuration.
Quoted 8 lines
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the reasons you mention. However, I would say that there are some design considerations that warrant userspace implementations as well. Users should be able to select the system that offers the best security properties, and putting both the authentication and authorization verification code in the kernel is not always going to meet everyone's needs.
We think that recognizing a port knocking sequence is an issue of the firewall (netfilter in this case), and if you want to open a port after a correct seq, the firewall is also the place. But sometimes you want to trigger a more complex action from this correct knock seq (e.g. start a webserver), so we allow to send a netlink msg from kernel to a listening userspace application that could decide what action to take. This userspace app is not scanning logs nor sniffing your iface, it's just waiting to receive an important message from kernel.
here is a nice intro to netlink sockets:
http://www.linuxjournal.com/article/7356
Quoted 8 lines
First, port knocking as opposed to single packet strategies have some serious problems:
- Hard to solve the replay problem
- Insufficient data transfer rate and reliability because of necessary time delays to enforce packet ordering to make reasonably sized data transfers (asymmetric encryption is not even an option)
- Knock sequences look like port scans
Tumbler is a Single Packet Authorization protocol. We offer 2 modes of
operation: the traditional port knock sequence and the SPA way.
Quoted 2 lines
- Trivially easy to bust a knock sequence just by spoofing a duplicate packet into the sequence
This is not possible with our anti-replay option.
Luis Floreani: "In our implementation there is no room for replay, cause each knock must change from minute to minute, and we just allow one knock per peer(IP) per minute. So if you knock(open), then connect, then knock(close), in the remaining minute, a replay would be useless cause that peer is "blocked" in that minute. Look at the function has_logged_during_this_minute(), that solves this issue."
Rennie deGraaf: "That's quite a clever idea. I never thought of using rate-limiting in my system."
Quoted 5 lines
The NAT issue and the lack of association between a knock sequence and follow-on connection mentioned in deGraaf's paper are important, but I think we basically have to live with it in any practical implementation that is generally deployable. And, these two limitations extend to single-packet solutions as well.
The NAT issue is a general problem with portknocking. Doesn't exist any portknocking application that solves it, for a while.
Quoted 6 lines
(Although, if you run both SPA and the
follow-on SSH connection over the Tor network - at the expense of having an established TCP connection for the SPA packet - and you use the MapAddress functionality to request a specific exit router, then it is possible to overcome the NAT issue, see
http://www.cipherdyne.org/fwknop/docs/talks/dc14_fwknop_slides.pdf).
I will read this paper soon.
Quoted 7 lines
Still, single-packet solutions are generally the way to go (assuming we are looking for a scheme that has good security properties).
So, your hmac method from within iptables is the most interesting. Some differences between this method and using a userspace daemon with an encrypted payload include:
Quoted 8 lines
- Clients cannot include information that the server might use to differentiate them. For example, the server might require that the client include both a valid username and
crypt()password on the local system that can be verified (or even talking with an LDAP server first) before opening the firewall. If you changed your protocol to include the hmac of the <secret, ip,epoch_min> and the appended additional information, that would work, but it would have to be sent in the clear.
Yes, adding users would allow granularity decisions, by now we prefer a more general and simple approach. Maybe in a near future we consider users.
Quoted 4 lines
- The above also extends to the clients determining the access rules themselves, and also sending complete commands across. (Neither of these are probably a big requirement on the part of users, but they are worth mentioning, and fwknop supports both).
Yes, sending commands could be seen as a good feature, but also could be a security issue, We prefer to "hardcode" the action in the iptables rule or let the userspace app (see netlink sockets) decide the action, rather than the client.
Quoted 10 lines
- The hmac non-replay functionality does allow replays for up to one minute, correct? I.e. multiple identical hmac packets could be sent for up to one minute and all would be honored by iptables? Suppose a user does:
knock.shopensecret; ssh user@host "do command";knock.shclosesecretThen an attacker would still have one minute in order to replay the first opensecret packet, and the IP would be allowed through until the attacker decides to voluntarily send the closesecret packet, yes?
as mentioned before, we just allow ONE knock PER peer(IP) PER minute. Replay attacks are not possible here, cause the epoch min do change every min.
Quoted 5 lines
- The hmac functionality allows new sessions to be initiated until a client decides to close access. This magnifies the NAT problem. In fwknop, because all ACCEPT rules are automatically deleted after a configurable amount of time and sessions remain open with Netfilter's conntrack facilities, the NAT problem is minimized.
Yes, we are thinking about this idea of conntrack to avoid the "manual" close knock, but remember that someone could cause a DoS, spoofing your IP and just trying to establish a connection before you.
Quoted 2 lines
I wonder if you could move to a timeout architecture within your pknock match?
We have a garbage collector that runs from time to time to clean already allowed and "defunct" peers.
Quoted 5 lines
- Finally, a userspace implementation is free to support any number of encryption schemes (as implemented by projects that concentrate in that area), many of which I doubt will ever be put within the kernel. Fwknop can take advantage of the benefits of asymmetric ciphers with GnuPG (as implemented by the GnuPG project itself) for example.
With a port knocking application any users manipulate firewall rules. Would you allow that any users or application change your firewall configuration on the fly?
What happens if a port knocking daemon is shutdowned by a remote attacker. If the daemon dies, then no further authentication is possible.
Quoted 5 lines
While I think that having the hmac functionality in iptables would meet the needs of many users, I think the above shows that the effort of learning a new daemon syntax is worth having a userspace implementation with more robust security properties. If I have misunderstood your architecture, please correct me.
We think our architecture is flexible enough so you can spread functionality between kernel and userspace (through netlink sockets), as we we mention before.
regards,
Signature · 1 line
Federico
Pablo Neira Ayuso
maintainerQuoted 11 lines · J. Federico Hernandez
Quoted 10 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the reasons you mention. However, I would say that there are some design considerations that warrant userspace implementations as well. Users should be able to select the system that offers the best security properties, and putting both the authentication and authorization verification code in the kernel is not always going to meet everyone's needs.
Quoted 9 lines
We think that recognizing a port knocking sequence is an issue of the firewall (netfilter in this case), and if you want to open a port after a correct seq, the firewall is also the place. But sometimes you want to trigger a more complex action from this correct knock seq (e.g. start a webserver), so we allow to send a netlink msg from kernel to a listening userspace application that could decide what action to take. This userspace app is not scanning logs nor sniffing your iface, it's just waiting to receive an important message from kernel.
Perhaps I'm just influenced by my first impression but I think that this thing should be in userspace. We are providing the appropiate netfilter netlink subsystems (nfqueue, nflog...) to implement this as a userland daemon.
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Quoted 22 lines · Pablo Neira Ayuso
Quoted 11 lines · J. Federico Hernandez
Quoted 10 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the reasons you mention. However, I would say that there are some design considerations that warrant userspace implementations as well. Users should be able to select the system that offers the best security properties, and putting both the authentication and authorization verification code in the kernel is not always going to meet everyone's needs.
Quoted 9 lines
We think that recognizing a port knocking sequence is an issue of the firewall (netfilter in this case), and if you want to open a port after a correct seq, the firewall is also the place. But sometimes you want to trigger a more complex action from this correct knock seq (e.g. start a webserver), so we allow to send a netlink msg from kernel to a listening userspace application that could decide what action to take. This userspace app is not scanning logs nor sniffing your iface, it's just waiting to receive an important message from kernel.
Quoted 5 lines
Perhaps I'm just influenced by my first impression but I think that this thing should be in userspace. We are providing the appropiate netfilter netlink subsystems (nfqueue, nflog...) to implement this as a userland daemon.
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition kernel->userspace->kernel.
In other more complex situations, you can recognize the knocks in the kernel and let a userspace app take an action using netlink sockets, as you say, but you should never allow a port knocking app to add or remove firewall rules on the fly.
Regards.
Signature · 1 line
Federico
Quoted 13 lines · J. Federico Hernandez
Quoted 11 lines · Pablo Neira Ayuso
Quoted 4 lines · J. Federico Hernandez
Quoted 4 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the
Perhaps I'm just influenced by my first impression but I think that this thing should be in userspace. We are providing the appropiate netfilter netlink subsystems (nfqueue, nflog...) to implement this as a userland daemon.
Quoted 5 lines
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
kernel->userspace->kernel is really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.
Quoted 4 lines
In other more complex situations, you can recognize the knocks in the kernel and let a userspace app take an action using netlink sockets, as you say, but you should never allow a port knocking app to add or remove firewall rules on the fly.
I don't think this was Pablo's intention : you can queue packet for all port including the one that must pass through and when the port knocking sequence is complete, allow packet to go through target port from userspace.
BR,
Signature · 3 lines
Éric Leblond, [email protected] Téléphone : 01 44 89 46 39, Fax : 01 44 89 45 01 INL, http://www.inl.fr
Quoted 20 lines · Eric Leblond
Quoted 13 lines · J. Federico Hernandez
Quoted 11 lines · Pablo Neira Ayuso
Quoted 4 lines · J. Federico Hernandez
Quoted 4 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the
Perhaps I'm just influenced by my first impression but I think that this thing should be in userspace. We are providing the appropiate netfilter netlink subsystems (nfqueue, nflog...) to implement this as a userland daemon.
Quoted 5 lines
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
Quoted 3 lines
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.
the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
By the way, Linux runs in a wide spectrum of devices, like mobile devices, where you musn't waste resources. (see linksys ap wireless, smart phones, etc)
regards,
Signature · 1 line
Federico
Pablo Neira Ayuso
maintainerQuoted 25 lines · J. Federico Hernandez
Quoted 24 lines · Eric Leblond
Quoted 6 lines · J. Federico Hernandez
Quoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · J. Federico Hernandez
Quoted 4 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing
for the
Quoted 2 lines
Quoted 2 lines
Perhaps I'm just influenced by my first impression but I think
that this
Quoted 1 line
Quoted 1 line
thing should be in userspace. We are providing the appropiate
netfilter
Quoted 1 line
Quoted 1 line
netlink subsystems (nfqueue, nflog...) to implement this as a
userland
Quoted 8 lines
Quoted 2 lines
daemon.
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
Quoted 6 lines
Quoted 3 lines
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
I'm unsure that putting things in kernel implies less complexity and correct design, it depends on the case.
Quoted 3 lines
By the way, Linux runs in a wide spectrum of devices, like mobile devices, where you musn't waste resources. (see linksys ap wireless, smart phones, etc)
I think that the main question is how many packets you would need to pass to userspace.
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Quoted 30 lines · Pablo Neira Ayuso
Quoted 29 lines · J. Federico Hernandez
Quoted 27 lines · Eric Leblond
Quoted 6 lines · J. Federico Hernandez
Quoted 5 lines · Pablo Neira Ayuso
Quoted 4 lines · J. Federico Hernandez
Quoted 4 lines · Michael Rash
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing
for the
Quoted 2 lines
Quoted 2 lines
Perhaps I'm just influenced by my first impression but I think
that this
Quoted 1 line
Quoted 1 line
thing should be in userspace. We are providing the appropiate
netfilter
Quoted 1 line
Quoted 1 line
netlink subsystems (nfqueue, nflog...) to implement this as a
userland
Quoted 8 lines
Quoted 2 lines
daemon.
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.
Quoted 6 lines
Quoted 2 lines
the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
I'm unsure that putting things in kernel implies less complexity and correct design, it depends on the case.
Putting things in kernel doesn't mean less complexity, but on port knocking case means a correct design and better performance.
WIth traditional port knocking applications you have to switch kernelspace ->userspase->kernelspace several times. Furthermore, you have to load the regex engine for parsing the firewall logs and you have to access the hard disk each minute for parsing logs files. In our opinion, this is not a correct design.
We don't want to say that you don't use port knocking applications, we just offer an alternative solution for port knocking.
Regards,
Signature · 1 line
Federico
Quoted 21 lines · J. Federico Hernandez
Quoted 13 lines · Pablo Neira Ayuso
Quoted 12 lines · J. Federico Hernandez
Quoted 10 lines · Eric Leblond
Quoted 6 lines
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.Quoted 6 lines
Quoted 2 lines
the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
I'm unsure that putting things in kernel implies less complexity and correct design, it depends on the case.
Quoted 8 lines
Putting things in kernel doesn't mean less complexity, but on port knocking case means a correct design and better performance.
WIth traditional port knocking applications you have to switch kernelspace ->userspase->kernelspace several times. Furthermore, you have to load the regex engine for parsing the firewall logs and you have to access the hard disk each minute for parsing logs files. In our opinion, this is not a correct design.
We do not understand each other about the way I (and pablo I think) propose you to do because the solution I thought off do not use log analysis...
Let's say port knocking is 4138 2345 4577 to open port 22
Then just do
iptables -A INPUT -p tcp -m multiport --dports 4138,2345,4577,22 -j QUEUE
Your userspace application wait for packets coming from queue, drop them when they come from knocking ports (but store the knock) and accept packet to port 22 if we just had a correct knocking sequence before.
This is simple, do not use complex algorithms and should fit on all small routers.
BR,
Signature · 2 lines
Eric Leblond <[email protected]> INL
Quoted 40 lines · Eric Leblond
Quoted 21 lines · J. Federico Hernandez
Quoted 13 lines · Pablo Neira Ayuso
Quoted 12 lines · J. Federico Hernandez
Quoted 10 lines · Eric Leblond
Quoted 6 lines
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.Quoted 6 lines
Quoted 2 lines
the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
I'm unsure that putting things in kernel implies less complexity and correct design, it depends on the case.
Quoted 8 lines
Putting things in kernel doesn't mean less complexity, but on port knocking case means a correct design and better performance.
WIth traditional port knocking applications you have to switch kernelspace ->userspase->kernelspace several times. Furthermore, you have to load the regex engine for parsing the firewall logs and you have to access the hard disk each minute for parsing logs files. In our opinion, this is not a correct design.
We do not understand each other about the way I (and pablo I think) propose you to do because the solution I thought off do not use log analysis...
Let's say port knocking is 4138 2345 4577 to open port 22
Then just do
iptables -A INPUT -p tcp -m multiport --dports 4138,2345,4577,22 -j QUEUE
Quoted 7 lines
Your userspace application wait for packets coming from queue, drop them when they come from knocking ports (but store the knock) and accept packet to port 22 if we just had a correct knocking sequence before.
This is simple, do not use complex algorithms and should fit on all small routers.
The idea of having an userspace application receiving the queued packets from netfilter is much better than scanning firewall logs.
Actually, I see this issues in the userspace solution:
1. (+) Could be safer to run the portknocking logic in userspace, rather than kernel.
2. It is not clear from a admin point of view that a portknocking system is running.
3. The port 22 traffic is suffering a small penalty because of travelling kenel->userspace->kernel before arriving to the service.
4. There is not a single point of configuration, if you want to change the knock sequence for instance, you have to change the app and then the iptables rule.
5. question: Is there a way to set two or more different queues? to avoid receiving in the userspace, packets from other rules with the "-j QUEUE"
Luis.
Hi,
Quoted 18 lines · Luis Floreani
Quoted 6 lines · Eric Leblond
Let's say port knocking is 4138 2345 4577 to open port 22
Then just do
iptables -A INPUT -p tcp -m multiport --dports 4138,2345,4577,22 -j QUEUEQuoted 7 lines
Your userspace application wait for packets coming from queue, drop them when they come from knocking ports (but store the knock) and accept packet to port 22 if we just had a correct knocking sequence before.
This is simple, do not use complex algorithms and should fit on all small routers.
The idea of having an userspace application receiving the queued packets from netfilter is much better than scanning firewall logs.
Quoted 8 lines
Actually, I see this issues in the userspace solution:
1. (+) Could be safer to run the portknocking logic in userspace, rather than kernel.
2. It is not clear from a admin point of view that a portknocking system is running.
3. The port 22 traffic is suffering a small penalty because of travellingkenel->userspace->kernelbefore arriving to the service.
By just queuing the SYN Packets you will introduce a ridiculous delay on this first packet. The rest of the connectio is handled by conntrack and there is thus no differences.
Quoted 3 lines
4. There is not a single point of configuration, if you want to change the knock sequence for instance, you have to change the app and then the iptables rule.
All can be bundle in a single script. A cleaner way could be to use ipset to specify the ports list and not to change the rules set.
Quoted 3 lines
5. question: Is there a way to set two or more different queues? to avoid receiving in the userspace, packets from other rules with the "-j QUEUE"
No, you have to use NFQUEUE to do so (which come with 2.6.14+). QUEUE is limited to one queue.
BR,
Signature · 2 lines
Eric Leblond <[email protected]> INL
Hello,
Quoted 29 lines · Eric Leblond
Hi,
Quoted 17 lines · Luis Floreani
Quoted 6 lines · Eric Leblond
Let's say port knocking is 4138 2345 4577 to open port 22
Then just do
iptables -A INPUT -p tcp -m multiport --dports 4138,2345,4577,22 -j QUEUEQuoted 6 lines
Your userspace application wait for packets coming from queue, drop them when they come from knocking ports (but store the knock) and accept packet to port 22 if we just had a correct knocking sequence before.
This is simple, do not use complex algorithms and should fit on all small routers.
The idea of having an userspace application receiving the queued packets from netfilter is much better than scanning firewall logs.
Quoted 8 lines
Actually, I see this issues in the userspace solution:
1. (+) Could be safer to run the portknocking logic in userspace, rather than kernel.
2. It is not clear from a admin point of view that a portknocking system is running.
3. The port 22 traffic is suffering a small penalty because of travellingkenel->userspace->kernelbefore arriving to the service.
Quoted 3 lines
By just queuing the SYN Packets you will introduce a ridiculous delay on this first packet. The rest of the connectio is handled by conntrack and there is thus no differences.
That design is very good. We think that it is the best among all the "hybrid" port knocking applications that we know.
Quoted 6 lines
Quoted 3 lines
4. There is not a single point of configuration, if you want to change the knock sequence for instance, you have to change the app and then the iptables rule.
All can be bundle in a single script. A cleaner way could be to use ipset to specify the ports list and not to change the rules set.
This is debatable. A cleaner way for who? Someone might want to configure the firewall only through iptables, without depending on other applications or daemons.
Quoted 6 lines
Quoted 3 lines
5. question: Is there a way to set two or more different queues? to avoid receiving in the userspace, packets from other rules with the "-j QUEUE"
No, you have to use NFQUEUE to do so (which come with 2.6.14+). QUEUE is limited to one queue.
We didn't know the NFQUEUE target extension. We thought it was very good.
Finally, we don't want to say that other port knocking applications aren't useful. We just offer an alternative, than in our opinion has more advantages than other solutions.
We would like know any suggestions about our pknock extension match. If you have some, they will be welcome.
Regards,
Signature · 1 line
Federico
Quoted 40 lines · Eric Leblond
Quoted 21 lines · J. Federico Hernandez
Quoted 13 lines · Pablo Neira Ayuso
Quoted 12 lines · J. Federico Hernandez
Quoted 10 lines · Eric Leblond
Quoted 6 lines
When all you want is to open a port after a correct sequence of knocks, instead of sending from the kernel all the knocks to the userspace, and then setting a new iptables rule so the kernel firewall takes an action, it would be better to leave the whole work to the kernel and avoid the transition
kernel->userspace->kernel.
kernel->userspace->kernelis really not a problem for nowadays computer. Simply think about snort-inline which is able to handle a great amount of traffic.Quoted 6 lines
Quoted 2 lines
the fact that nowadays computers have much more power, doesn't mean that you can forget about a simple, less complex and correct design.
I'm unsure that putting things in kernel implies less complexity and correct design, it depends on the case.
Quoted 8 lines
Putting things in kernel doesn't mean less complexity, but on port knocking case means a correct design and better performance.
WIth traditional port knocking applications you have to switch kernelspace ->userspase->kernelspace several times. Furthermore, you have to load the regex engine for parsing the firewall logs and you have to access the hard disk each minute for parsing logs files. In our opinion, this is not a correct design.
We do not understand each other about the way I (and pablo I think) propose you to do because the solution I thought off do not use log analysis...
Let's say port knocking is 4138 2345 4577 to open port 22
Then just do
iptables -A INPUT -p tcp -m multiport --dports 4138,2345,4577,22 -j QUEUE
Quoted 7 lines
Your userspace application wait for packets coming from queue, drop them when they come from knocking ports (but store the knock) and accept packet to port 22 if we just had a correct knocking sequence before.
This is simple, do not use complex algorithms and should fit on all small routers.
The idea of having an userspace application receiving the queued packets from netfilter is much better than scanning firewall logs.
Actually, I see this issues in the userspace solution:
1. (+) Could be safer to run the portknocking logic in userspace, rather than kernel.
2. It is not clear from a admin point of view that a portknocking system is running.
3. The port 22 traffic is suffering a small penalty because of travelling kenel->userspace->kernel before arriving to the service.
4. There is not a single point of configuration, if you want to change the knock sequence for instance, you have to change the app and then the iptables rule.
5. question: Is there a way to set two or more different queues? to avoid receiving in the userspace, packets from other rules with the "-j QUEUE"
Luis.
Quoted 70 lines · J. Federico Hernandez
Quoted 44 lines · Michael Rash
Quoted 7 lines · J. Federico Hernandez
Quoted 5 lines · Alexey Toptygin
Quoted 3 lines · Luis Floreani
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If you're interested in port knocking, you might want to read this
paper: http://www.acsac.org/2005/abstracts/156.html It coverssecurity
Quoted 1 line
Quoted 1 line
Quoted 1 line
issues relating to port knocking in detail, and presents an
architecture
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
for solving most of them.
Full disclosure: I wrote that paper. Feel free to contact me if
you
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
have questions.
Rennie deGraaf
In our implementation, for security, we are using the Tumbler
protocol,
Quoted 12 lines
Quoted 12 lines
we
Quoted 5 lines
Quoted 2 lines
found it simple yet powerful, check it out here:
http://tumbler.sourceforge.net/.It seems that Tumbler is not capable of working across NAT, unless the client can somehow obtain its public IP address. Also, it relies on
clocks
Quoted 4 lines
being synchronized, since authentication will fail if the UTC time in minutes is not identical on the client and server. Tumbler is not as stealthy as the techniques in Rennie deGraaf's paper, since it uses an open UDP port.
Quoted 8 lines
Quoted 1 line
Why not use fwknop in Single Packet Authorization mode?:
Why not using iptables to implement port knocking? You won't depend on any daemon.
If you know the iptables syntaxis, you don't need to learn the daemon syntaxis or its configuration.
Quoted 8 lines
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the reasons you mention. However, I would say that there are some design considerations that warrant userspace implementations as well. Users should be able to select the system that offers the best security properties, and putting both the authentication and authorization verification code in the kernel is not always going to meet everyone's needs.
We think that recognizing a port knocking sequence is an issue of the firewall (netfilter in this case), and if you want to open a port after a correct seq, the firewall is also the place. But sometimes you want to trigger a more complex action from this correct knock seq (e.g. start a webserver), so we allow to send a netlink msg from kernel to a listening userspace application that could decide what action to take. This userspace app is not scanning logs nor sniffing your iface, it's just waiting to receive an important message from kernel.
here is a nice intro to netlink sockets:
http://www.linuxjournal.com/article/7356
Quoted 3 lines
First, port knocking as opposed to single packet strategies have some serious problems:
Quoted 8 lines
Quoted 5 lines
- Hard to solve the replay problem
- Insufficient data transfer rate and reliability because of necessary time delays to enforce packet ordering to make reasonably sized data transfers (asymmetric encryption is not even an option)
- Knock sequences look like port scansTumbler is a Single Packet Authorization protocol. We offer 2 modes of
operation: the traditional port knock sequence and the SPA way.
Right, I was treating the two modes separately (port knocking vs. SPA). I'm trying to make the case that port knocking has enough problems to motivate people to use an SPA solution instead.
Quoted 12 lines
Quoted 2 lines
- Trivially easy to bust a knock sequence just by spoofing a duplicate packet into the sequence
This is not possible with our anti-replay option.
Luis Floreani: "In our implementation there is no room for replay, cause each knock must change from minute to minute, and we just allow one knock per peer(IP) per minute. So if you knock(open), then connect, then knock(close), in the remaining minute, a replay would be useless cause that peer is "blocked" in that minute. Look at the function
has_logged_during_this_minute(), that solves this issue."
Quoted 2 lines
Rennie deGraaf: "That's quite a clever idea. I never thought of using rate-limiting in my system."
Spoofing a duplicate packet into a port knock sequence is not a replay attack. This is a DoS attack against your knock server; an attacker can force the client to appear to not know the correct knock sequence. This is yet another reason to switch to an SPA solution because it is so trivially easy to do.
Quoted 34 lines
Quoted 5 lines
The NAT issue and the lack of association between a knock sequence and follow-on connection mentioned in deGraaf's paper are important, but I think we basically have to live with it in any practical implementation that is generally deployable. And, these two limitations extend to single-packet solutions as well.
The NAT issue is a general problem with portknocking. Doesn't exist any portknocking application that solves it, for a while.
Quoted 6 lines
(Although, if you run both SPA and the
follow-on SSH connection over the Tor network - at the expense of having an established TCP connection for the SPA packet - and you use the MapAddress functionality to request a specific exit router, then it is possible to overcome the NAT issue, see
http://www.cipherdyne.org/fwknop/docs/talks/dc14_fwknop_slides.pdf).I will read this paper soon.
Quoted 7 lines
Still, single-packet solutions are generally the way to go (assuming we are looking for a scheme that has good security properties).
So, your hmac method from within iptables is the most interesting. Some differences between this method and using a userspace daemon with an encrypted payload include:
Quoted 8 lines
- Clients cannot include information that the server might use to differentiate them. For example, the server might require that the client include both a valid username and
crypt()password on the local system that can be verified (or even talking with an LDAP server first) before opening the firewall. If you changed your protocol to include the hmac of the <secret, ip,epoch_min> and the appended additional information, that would work, but it would have to be sent in the clear.
Quoted 3 lines
Yes, adding users would allow granularity decisions, by now we prefer a more general and simple approach. Maybe in a near future we consider users.
Ok, but doesn't "considering users" imply more user space type functions? Sure, I suppose you can read the /etc/shadow file from kernel space and then do crypt() from within the kernel, but this is limited and seems wrong. What if you want to tie access to a remote LDAP server for example? Your user space app could do it, but then user-specific information would have to be transmitted over the netlink socket as well, correct?
Quoted 9 lines
Quoted 4 lines
- The above also extends to the clients determining the access rules themselves, and also sending complete commands across. (Neither of these are probably a big requirement on the part of users, but they are worth mentioning, and fwknop supports both).
Yes, sending commands could be seen as a good feature, but also could be a security issue, We prefer to "hardcode" the action in the iptables rule or let the userspace app (see netlink sockets) decide the action, rather than the client.
Yes, sending commands could be a security issue, and this is not enabled by default in fwknop; it is just there for those who find it useful (and also find that the security risks are acceptable given that fwknop is compatible with things like GnuPG, etc.).
Quoted 7 lines
Quoted 7 lines
- The hmac non-replay functionality does allow replays for up to one minute, correct? I.e. multiple identical hmac packets could be sent for up to one minute and all would be honored by iptables? Suppose a user does:
knock.shopensecret; ssh user@host "do command";knock.shclosesecret
Quoted 7 lines
Quoted 3 lines
Then an attacker would still have one minute in order to replay the first opensecret packet, and the IP would be allowed through until the attacker decides to voluntarily send the closesecret packet, yes?
as mentioned before, we just allow ONE knock PER peer(IP) PER minute. Replay attacks are not possible here, cause the epoch min do change every min.
Ok, that's cool.
Quoted 9 lines
Quoted 5 lines
- The hmac functionality allows new sessions to be initiated until a client decides to close access. This magnifies the NAT problem. In fwknop, because all ACCEPT rules are automatically deleted after a configurable amount of time and sessions remain open with Netfilter's conntrack facilities, the NAT problem is minimized.
Yes, we are thinking about this idea of conntrack to avoid the "manual" close knock, but remember that someone could cause a DoS, spoofing your IP and just trying to establish a connection before you.
I'm not sure I understand. It seems like this would be an issue only if you allow just one follow-on connection per SPA packet, yes? Fwknop uses a timeout window, so it doesn't matter how many connections are established as long as it is within the window.
Quoted 12 lines
Quoted 2 lines
I wonder if you could move to a timeout architecture within your pknock match?
We have a garbage collector that runs from time to time to clean already allowed and "defunct" peers.
Quoted 5 lines
- Finally, a userspace implementation is free to support any number of encryption schemes (as implemented by projects that concentrate in that area), many of which I doubt will ever be put within the kernel. Fwknop can take advantage of the benefits of asymmetric ciphers with GnuPG (as implemented by the GnuPG project itself) for example.
Quoted 3 lines
With a port knocking application any users manipulate firewall rules. Would you allow that any users or application change your firewall configuration on the fly?
With strong enough security properties and a good design, yes. Fwknop always keeps rules within a custom chain in order to separate them from an existing iptables policy, has a well-defined mechanism for manipulating rules, etc.
Quoted 3 lines
What happens if a port knocking daemon is shutdowned by a remote attacker. If the daemon dies, then no further authentication is possible.
Fwknop has a process monitoring daemon, and is written in a (mostly) buffer safe language (perl). Being able to be shutdown by an attacker implies a bug or design flaw - these can exist in the kernel as well to more damaging effect.
Quoted 6 lines
Quoted 5 lines
While I think that having the hmac functionality in iptables would meet the needs of many users, I think the above shows that the effort of learning a new daemon syntax is worth having a userspace implementation with more robust security properties. If I have misunderstood your architecture, please correct me.
Quoted 8 lines
We think our architecture is flexible enough so you can spread functionality between kernel and userspace (through netlink sockets), as we we mention before.
regards,
Signature · 1 line
Federico
--
Michael Rash
http://www.cipherdyne.org/
Key fingerprint = 53EA 13EA 472E 3771 894F AC69 95D8 5D6B A742 839F
Quoted 78 lines · Michael Rash
Quoted 76 lines · J. Federico Hernandez
Quoted 44 lines · Michael Rash
Quoted 7 lines · J. Federico Hernandez
Quoted 5 lines · Alexey Toptygin
Quoted 3 lines · Luis Floreani
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If you're interested in port knocking, you might want to read this
paper: http://www.acsac.org/2005/abstracts/156.html It coverssecurity
Quoted 1 line
Quoted 1 line
Quoted 1 line
issues relating to port knocking in detail, and presents an
architecture
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
for solving most of them.
Full disclosure: I wrote that paper. Feel free to contact me if
you
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
have questions.
Rennie deGraaf
In our implementation, for security, we are using the Tumbler
protocol,
Quoted 12 lines
Quoted 12 lines
we
Quoted 5 lines
Quoted 2 lines
found it simple yet powerful, check it out here:
http://tumbler.sourceforge.net/.It seems that Tumbler is not capable of working across NAT, unless the client can somehow obtain its public IP address. Also, it relies on
clocks
Quoted 4 lines
being synchronized, since authentication will fail if the UTC time in minutes is not identical on the client and server. Tumbler is not as stealthy as the techniques in Rennie deGraaf's paper, since it uses an open UDP port.
Quoted 8 lines
Quoted 1 line
Why not use fwknop in Single Packet Authorization mode?:
Why not using iptables to implement port knocking? You won't depend on any daemon.
If you know the iptables syntaxis, you don't need to learn the daemon syntaxis or its configuration.
Quoted 8 lines
Well, I agree that having an implementation that builds some port knocking capabilities directly into iptables is a good thing for the reasons you mention. However, I would say that there are some design considerations that warrant userspace implementations as well. Users should be able to select the system that offers the best security properties, and putting both the authentication and authorization verification code in the kernel is not always going to meet everyone's needs.
We think that recognizing a port knocking sequence is an issue of the firewall (netfilter in this case), and if you want to open a port after a correct seq, the firewall is also the place. But sometimes you want to trigger a more complex action from this correct knock seq (e.g. start a webserver), so we allow to send a netlink msg from kernel to a listening userspace application that could decide what action to take. This userspace app is not scanning logs nor sniffing your iface, it's just waiting to receive an important message from kernel.
here is a nice intro to netlink sockets:
http://www.linuxjournal.com/article/7356
Quoted 8 lines
First, port knocking as opposed to single packet strategies have some serious problems:
- Hard to solve the replay problem
- Insufficient data transfer rate and reliability because of necessary time delays to enforce packet ordering to make reasonably sized data transfers (asymmetric encryption is not even an option)
- Knock sequences look like port scans
Quoted 6 lines
Quoted 2 lines
Tumbler is a Single Packet Authorization protocol. We offer 2 modes of
operation: the traditional port knock sequence and the SPA way.Right, I was treating the two modes separately (port knocking vs. SPA). I'm trying to make the case that port knocking has enough problems to motivate people to use an SPA solution instead.
we agree, that's why we offer both solutions.
<snip>
Quoted 14 lines
Quoted 10 lines
Quoted 9 lines
- Clients cannot include information that the server might use to differentiate them. For example, the server might require that the client include both a valid username and
crypt()password on the local system that can be verified (or even talking with an LDAP server first) before opening the firewall. If you changed your protocol to include the hmac of the <secret, ip,epoch_min> and the appended additional information, that would work, but it would have to be sent in the clear.Quoted 3 lines
Yes, adding users would allow granularity decisions, by now we prefer a more general and simple approach. Maybe in a near future we consider users.
Quoted 8 lines
Ok, but doesn't "considering users" imply more user space type functions? Sure, I suppose you can read the
/etc/shadowfile from kernel space and then docrypt()from within the kernel, but this is limited and seems wrong. What if you want to tie access to a remote LDAP server for example? Your user space app could do it, but then user-specific information would have to be transmitted over the netlink socket as well, correct?
the listening(netlink sockets) userspace app can receive as much information as you want, in fact, the bytes received from the socket are casted to a struct, containing n items.
<snip>
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
- The hmac functionality allows new sessions to be initiated until a client decides to close access. This magnifies the NAT problem. In fwknop, because all ACCEPT rules are automatically deleted after a configurable amount of time and sessions remain open with Netfilter's conntrack facilities, the NAT problem is minimized.
Quoted 9 lines
Quoted 3 lines
Yes, we are thinking about this idea of conntrack to avoid the "manual" close knock, but remember that someone could cause a DoS, spoofing your IP and just trying to establish a connection before you.
I'm not sure I understand. It seems like this would be an issue only if you allow just one follow-on connection per SPA packet, yes? Fwknop uses a timeout window, so it doesn't matter how many connections are established as long as it is within the window.
ok, in our case, if you do not do the "close" knock, you also have a timeout window configurable as a the kernel module param.
<snip>
seems that fwknop is an interesting app, but we are looking for a more kernel oriented feedback. ;-)
regards,
Signature · 1 line
Federico