Slashdot Mirror


"Port Knocking" For Added Security

Jeff writes "The process of Port Knocking is a way to allow only people who know the "secret knock" access to a certain port on a system. For example, if I wanted to connect via SSH to a server, I could build a backdoor on the server that does not directly listen on port 22 (or any port for that matter) until it detects connection attempts to closed ports 1026,1027,1029,1034,1026,1044 and 1035 in that sequence within 5 seconds, then listens on port 22 for a connection within 10 seconds. The web site explains it in some detail, and there is even an experimental perl implementation of it that is available for download. I can't think of any easy ways you could get around a system using this security method - let alone even know that a system is implementing it. Another article on port knocking is here."

62 of 950 comments (clear)

  1. Invasive Security by Anonymous Coward · · Score: 2, Interesting

    This is secure in the same way 50-character passphrases are secure, sure they are harder to crack but who the hell is goig to remember them. The harder you make something to use, users will start trying to find ways around it.

    whats more, connection attempts are easy to sniff, you might as well be using telnet...THIS THING IS BEGGING FOR A "REPLAY ATTACK".

  2. My idea by Catskul · · Score: 4, Interesting

    I though about this along time ago as a way of hiding a trojan. Of course I didnt patent it so no money for me : /

    --

    Im not here now... Im out KILLING pepperoni
  3. Worse? by glpierce · · Score: 4, Interesting

    Right now, script kiddies have their computers automatically try to access other peoples' computers, looking for ones without firewalls, etc.. If this happens, wouldn't you expect them to just send out random knocks in the hopes of getting something? If that happens, you will be more secure personally, but the increased traffic may cause more problems that it solves.

    --
    G
  4. Re:not bad by Kenja · · Score: 5, Interesting
    "But it does seem like a layer of obscurity to what should otherwise be a secure port. What if someone is sniffing your network? Unlike an encrypted password, they could easily replay this sequence and gain access to your "hidden" port."

    And? It is still more secure. By using "port knocking" they HAVE to sniff out your network traffic and find the port combo. Without "port knocking" they just need to run nmap and see what ports they can try to attack.

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
  5. One-time port knocking? by sleepingsquirrel · · Score: 2, Interesting

    Interesting. So the next step would be to have one-time port knock sequences a-la one-time passwords (to defeat adversaries who are grabbing a copy of all your packets). But it seems like there is a race condition between the delay after the knock and the actual connection. Anyone have a solution to this?

    1. Re:One-time port knocking? by v_1_r_u_5 · · Score: 2, Interesting

      After the knock has been verified, open the desired port for a brief time, but only accept incoming connections to that port from the verified IP address. There's still a slight race condition, but at least 99.99999% of the internet is now ineligible to get access.

  6. Equivalent to a password by crow · · Score: 3, Interesting

    I was thinking about implementing this a while ago; I guess it's an obvious enough idea that others have been thinking along the same lines. This is equivalent to to putting a password on access to the port.

    Ideally, the implementation will only consider connection attempts originating from the same IP address.

    1. Re:Equivalent to a password by pla · · Score: 4, Interesting

      This is equivalent to to putting a password on access to the port.

      This seems much better than a password, I would think (Though I certainly would still use a password as well).

      As an analogy, if you want to get into a house, and find a locked door, you have a few options... You can try one of those M x N position key blanks, which will take a very very long time (exhaustive search). You can try to pick it (exploit a weakness in the password algorithm). You can try to get ahold of a copy of the real key (packet sniffing, "shoulder surfing", etc). But you have no doubt that somewhere, a key exists that will open that door.

      Now compare that to a solid block of concrete, roughly the size of a house. What does it do? Do helicopters land on it? Does it cover something, or hold something down? Does it have something sealed inside it? You'd never suspect that that, if you utter the magic phrase "Sim sala bim bamba sala do saladim", a door will appear in the side of this large concrete block, allowing those with a key to gain entrance.

      The main difference involves knowing whether or not a way in exists. With just a passworded port, an attacker knows that enough effort will pay off. Adding in port knocking, that attacker doesn't know whether or not their hard work can ever gain them entrance, since a port might well not exist.


      Now, in my opinion, the more interesting question here involves how to hide this from one's ISP (ie, make it snoop-proof).

  7. Re:Oh, really. by Anonymous Coward · · Score: 2, Interesting

    I predict a flood of commenters whining about this being "security through obscurity."

    Yeah, just like passwords are "security through obscurity."

    This is essentially another level of passwords, but sounds useful for hiding those services that could have vulnerabilities *cough* OpenSSH *cough*.

    Will this technique itself have possible vulnerabilities?

  8. Re:not bad by LostCluster · · Score: 5, Interesting

    Think of it this way... it's an extra password combined with bonus security-by-obscurity of not having a visible password prompt.

    The "knocking ports" could also be configured that if there are random hits to the standard port without the proper knock, the system could lock down for 30 seconds and even ignore the proper knock so that if somebody's trying to brute force all the possible knocks, they'll never get feedback when they have the right one.

    Yeah, this is no substitute for properly securing the original service, but it's an extra layer that means there's even more that needs to be captured for a successful hack...

  9. NOT security through obscurity by 3Suns · · Score: 5, Interesting

    It should be noted that this is NOT (necessarily) an example of security through obscurity. One could treat the port-knocking sequence as a "key". Long enough keys could make port-scanning impossible for anyone who doesn't know the key. Real mathematical cryptography is based on a similar principle.

    Also, this is only a defense against port-scanning. Even if someone did manage to break the knocking sequence, they would still have to use some kind of exploit against the machine on the port they discovered.

    --

    -3Suns

    ~~~~
    The Revolution will be Slashdotted
  10. Re:not bad by 26199 · · Score: 5, Interesting

    Hmm, lots of people have pointed this out, but it's easy to set up a system of one-time passwords... provided it's done in a cryptographically secure way, there's little point in sniffing for combinations.

    Of course, you can still sniff to see what ports are actually in use...

  11. Possible problems by Mr.+McGibby · · Score: 4, Interesting

    What if multiple attempts from the same IP are made to access the port at the same time? Wouldn't the knocks get all mixed up?

    --
    Mad Software: Rantings on Developing So
    1. Re:Possible problems by Mr.+McGibby · · Score: 2, Interesting

      RTFC. That's what I asked. What they *are* from the same IP.

      --
      Mad Software: Rantings on Developing So
    2. Re:Possible problems by Anonymous Coward · · Score: 1, Interesting

      You havent looked at how TCP/IP works evidently.

      Lets say you had to knock on port 333, 555, then 444. And you did this with two applications at once. The firewall should see it like this if your knocking application is programed properly.

      TCP SRCIP PORT 1024 DESTIP PORT 333
      TCP SRCIP PORT 1024 DESTIP PORT 555
      TCP SRCIP PORT 1026 DESTIP PORT 333
      TCP SRCIP PORT 1024 DESTIP PORT 444
      (the first connection has authenticated now)
      TCP SRCIP PORT 1026 DESTIP PORT 555
      TCP SRCIP PORT 1026 DESTIP PORT 444
      (the second connection has authenticated now)

      It looks like if it was programmed correctly port knocking would work fine.

  12. Great for SSH by zulux · · Score: 2, Interesting



    OpenSSH is a great peice of sodtware - but it's so huge that I can't help but think that their could be flaws in it (like the one of 6 months ago)

    I would love to layer another peice of security infront of OpenSSH and this seems like a great idea.

    --

    Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

  13. Reverse-knock by Seft · · Score: 5, Interesting

    Has anyone implemented a system where a service would be stopped if the ports next to it were scanned? i.e. if 1024, 1025, 1026, 1027 were scanned, a service running on 1028 would stop.

    1. Re:Reverse-knock by dk.r*nger · · Score: 2, Interesting

      That's easy.. hit three unassigned ports, and you buy your IP-adress a nice firewall rule for an hour or so...

      Your legit users (' software, anyway) usually knows how to connect to the real port first time.

    2. Re: Reverse-knock by rk · · Score: 2, Interesting

      Not at all, and it's not a half-bad idea, but it's also not what the other poster was saying. He was talking about temporarily shutting down a service, which I interpret differently than firewalling a single IP out.

      What I used is really just a variant of your idea, just taken to paranoid extremes. Instead of blocking just port 80, I blocked all of them. Instead of temporarily, it was essentially permanent, except that I was too lazy to work up a "save the updated rules automatically" script, so when I rebooted, those IPs could play again. Since that system had an average uptime of months, those IPs were effectively banned for quite some time.

  14. Re:Well, there go the logfiles by mabu · · Score: 2, Interesting

    This isn't going to catch on. It's not more secure and it wastes more resources.

    Why would this be any more secure than listening on a single port for the "unique knock sequence?" Any good admin knows the most secure system is one that is listening on as few ports as possible.

  15. Implementations? by crow · · Score: 2, Interesting

    Could this be implemented with IP Tables under Linux? I remember seeing a set of rules to detect a port scan; could a similar set of rules be used to unlock a port for a given remote IP number?

    Of course, this won't take off unless there's also knocking support built into the clients (like ssh).

  16. rotate the knock by CSIP · · Score: 2, Interesting

    one could also change the sequence of ports that are used to be based on some key/progression/timestamp? so the knock is constantly changing... so even if someone sniffs the knock, it wont help.

    --
    "Nyquil - The stuffy, sneezy, why-the-hell-is-the-room-spinning medicine."
  17. hmm... by Kitsune · · Score: 5, Interesting

    Improperly done, the knock sentry could become a security/QOS issue in itself.

    This definitely is security through obscurity and perhaps would work in the same way as a car alarm. There's lots more systems out there that are easier to break into, and if someone does try, just hope that they get fed up and moves on to the next one.

    If you've gone this far, why not do something like they do on radio. Open up severable ports at the same time and multiplex your signal over several of them while sending noise over the ununsed ports randomly switching between ports using a syncronized random selector.

  18. go a step further by Casca · · Score: 5, Interesting

    Implement it in combination with a onetime type password arrangement. You look up what the series of knocks is supposed to be on your secureID card (or whatever), then knock in the combination it tells you to use. Tie it in with the server you want to get into, and the port you actually connect to for ssh can be different every time.

    IE, secureID says sequence is "1234 1441 1114 5123", you knock on the first three, and 5123 is the ssh port activated for you only.

    --
    Casca
  19. Re:Well, there go the logfiles by aldousd666 · · Score: 4, Interesting

    It doesn't have to be listening on the 'knock' ports, it can be dropping the packets and either logging the drop or setting a flag via some daemon. There are a million ways to tell if someone attempted to access a closed port without having to open the port. All of this, by my calculation, makes port knocking indeed more secure.

    --
    Speak for yourself.
  20. Re:Well, there go the logfiles by RollingThunder · · Score: 5, Interesting

    Actually, an interesting potential of this is to have you "knock" at the NAT gateway. Proper knocking opens up a given service and knock ports to an internal system.

    Different knock patterns at the NAT open you to different internal hosts. Quite interesting possibilities there.

  21. Re:Well, there go the logfiles by Mod+Me+God · · Score: 5, Interesting

    That is the point.

    1. Many ports getting a sequence is much more like noise than one port getting it -> much harder to identify an attempt of intrusion.

    2. If you have a backdoor, as mentioned in the article, how will you know it has not been accessed? It was not listening, it gets activated, does its duty, deactivates. If it is a good backdoor it is invisible to that system (only visible though an additional layer).

    So it is a better way of getting a connection, but not a solve-all for the intruder, and I doubt the intruder cares about any waste of your resources.

    --
    --

    FreeNET user? Comfortable with the adverse selection?
  22. Knock Knock Honey Pot by ifreakshow · · Score: 5, Interesting

    One interesting way to use this would be to forward incorrect knocks to a honeypot instead of the legitamite service. Then the attacker could never determine if he had indeed knocked successfully and would waste time running around in a fake system giving you valuable data about there intrusion methods and freeing up the actual service for legit users.

  23. A Question about packet sniffing by Stone316 · · Score: 2, Interesting
    I've always been curious of packet sniffing but really never investigated it indepth. Would the person who wants to sniff your network be on the same subnet or have access to some major hub? ie, How is a guy in Russia going to sniff and find the right port combo if the server is in Seattle?

    Wouldn't he have had to hack a computer closer to his target in order to be successful?

    Wouldn't the best option be to have some type of SecurID based password in order to access the port? Unless there is a bug or hole in the software isn't a randomly changing password that requires a pin about as good as it gets?

    And as they say, Security through obscurity isn't.

    --
    "Thanks to the remote control I have the attention span of a gerbil."
  24. I thought of this 2 years ago by cr@ckwhore · · Score: 3, Interesting

    Interesting concept... I thought of this 2 years ago and I'm now kicking myself in the balls for not acting on it! (not literally)

    In my version of "port knocking", everything was going to be controled via ICMP echo packets.. aka "ping".

    A single Ping packet can contain arbitrary data of an arbitrary length less than 64k. Through a config file, the system admin could define ping sequences using time, data, and/or packet size, along with a specified script to execute on each successful reception of the ping sequence.

    Then, remotely, people who know the ping sequences could use almost any available ping utility on any machine to open remote ports, etc.

    The concept of executing a script, rather than opening or closing ports, allows for more flexibility. Not only can the admin open and close ports via scripts, but could do other useful things.

    --
    Skiers and Riders -- http://www.snowjournal.com
  25. Re:not bad by orthogonal · · Score: 2, Interesting

    Of course you could also have a new combination generated every minute for the super paranoid.

    No, if you were "super paranoid" you'd have two identical one-time pads, one residing on the computer to be accessed, one in the hands of a single person trying to connect.

    Every minute, the computer would consult its copy of the pad to determine what that minute's secret knock sequence would be.

    The person connecting would look up in his copy of the pad that minute's sequence. You'd need to synchronize both participants' clocks, of course.

    Less secure would be generating a new combination -- using some continuous function -- every minute.

    Less secure than the pad, but more secure than a continuous function, would be a cellular automaton -- life Conway's Game of Life -- where any particular minute's knock sequence could only determined by first determining the previous minute's sequence.

    Of course, to prevent the rules from being extrapolated by anyone analyzing your traffic, you'd have to agree on a new function or automaton to use for the next connection before ending the current connection. To guard against interruption of the connection, agreeing on the next connection's function would be the first thing you'd do after making a connection, and to guard against that being interrupted you'd need some fallback combinations -- which brings us back to the one-time pad.

  26. Re:Well, there go the logfiles by rgmoore · · Score: 2, Interesting

    But you're missing the point that this doesn't require any extra ports being open. The listener waits for the correct series of attempted connections to closed ports, and then transiently opens an otherwise closed port. Thus the approach lets you leave a port open temporarily when you would otherwise have to leave it open all the time, so it should add safety by your known good administration practices.

    --

    There's no point in questioning authority if you aren't going to listen to the answers.

  27. freq. hopping analogy- by Samuel+Nitzberg · · Score: 5, Interesting

    This looks similar to how frequency-hopping is used on secure radios.

    Two radios synchronize, based on a key, and both change frequency every so many milliseconds. If you don't know the key, you can't send or receive to either of them.

    I would like to see this extended to a port-hopping system for all ports and services. Sure -- it will burn some clock cycles, but I like the approach.

    - Sam
    http://www.iamsam.com

  28. Re:not bad by Jerf · · Score: 5, Interesting

    ignore the proper knock so that if somebody's trying to brute force all the possible knocks, they'll never get feedback when they have the right one.

    Re "brute forcing"... the number of possible knocks is (ports used for knocking) ** (ports in knock sequence). Yes, that's exponentiation.

    In fact, I'd suggest making the knock sequence much longer then in the article; ten might be good. Then, if you allocate 100 ports to the knocked and randomly select a 10 port sequence for the knocking, you get 100 ** 10 possible knocks, or 100,000,000,000,000,000,000 (100 sextillion) possible knocks.

    With just a few more ports in the sequence and just a modest investment in ports, you can make brute forcing impossible.

    (And if you mix up the ports so they aren't sequential and the attacker has to guess THOSE ports, it goes to approx. (2**16)**(number of knock), so for a 10-port sequence on potentially all TCP ports it's 1,461,501,637,330,902,918,203,684,832,716,283,019, 655,932,542,976 possible knocks, a.k.a. "way the hell more then can be brute-forced".

    (I love posting big numbers on Slashdot.)

    You need to worry about sniffers way more then brute forcers. (And as this is another layer of security, hopefully on top of an already fairly secure protocol like SSH, it's a good thing; now the 'man in the middle' has to have advanced knowlege to even know there's something to get into the middle of!)

  29. Re:not bad by pantycrickets · · Score: 2, Interesting

    It isn't more secure. It's just more obfuscated, because it's more complex. But that doesn't make it more secure, it makes it potentially _less_ secure.

    I think the idea is that an attacker would install a hidden sshd on your system, and you wouldn't know. You wouldn't even see an open port. You wouldn't see concentrations of connections to one "closed" port, but sporatic attempts at a few seemingly random ports. The attacker would use this as a backdoor into your system. I think you got the wrong impression that this would be a keen tool for system administrators for some reason. I didn't RTFA, but jeez.. at least read the summary.

  30. Re:not bad by Roofus · · Score: 3, Interesting

    It's like saying that if sshd asked consecutively for two passwords before granting access, that would be more secure.

    In a way it does. It firsts asks for a username, and then a password. If one of them is incorrect, you don't get access. But SSH doesn't tell you which one was incorrect.

    Port knocking is very similar (but not exactly the same). You need to have both keys (port combination) and login info in order to get access.

    The difference is, without the port combinations, you can't tell if the service is up, or your port combination is wrong.

  31. not so shady... by Hubert_Shrump · · Score: 4, Interesting

    i've been running SSH on a nonstandard port with this in the way:


    iptables -N ${SSH_TABLE}
    iptables -Z ${SSH_TABLE}
    iptables -A ${SSH_TABLE} -m state --state NEW -m limit --limit 2/minute --limit-
    burst 2 -j DROP
    iptables -A ${SSH_TABLE} -m state --state NEW -m limit --limit 7/hour --limit-bu
    rst 7 -j DROP
    iptables -A ${SSH_TABLE} -m state --state NEW -m limit --limit 10/day --limit-bu
    rst 10 -j ACCEPT
    iptables -A ${SSH_TABLE} -j DROP


    well, I thought it was cool...

    --
    Keep your packets off my GNU/Girlfriend!
  32. Re:Security through obscurity by HeelToe · · Score: 2, Interesting

    But if your knock sequence was generated similar to a one time password, the knock sequence would be unique each time and not replayable.

  33. Re:Well, there go the logfiles by diablobynight · · Score: 4, Interesting

    does it only open the port for that one IP somehow, using also advanced IP filtering, cause otherwise this is dumb, it would be like unlocking your door for the first customer to knock right, but having to leave it open the whole time the customer is shopping.

    --
    Anonymous Cowards - Oh God, How I hate you
  34. Not a new idea by ftzdomino · · Score: 2, Interesting

    I wrote proof of concept code for this a few years ago. Mine is implemented as modified network sniffer code (with promisc disabled), so it doesn't require any weird firewall configs. I was considering some other things which could be useful, such as transmitting data via a fake network scan.

  35. Re:Obscurity IS Security by TrollBridge · · Score: 2, Interesting
    I don't think he's reaching at all, and I think the great-grandparent post illustrates his point very well.

    In the context of the theoretical shifting door in the wall, part of what makes it secure is that outsiders don't know how the door works; they only know that it moves away when an unauthorized person tries to open it.

    However, people who oppose "security through obscurity", especially when in conjunction with blind open source advocacy, would argue that giving would-be intruders the blueprints of the door system would somehow deter them and make the system more secure.

    --
    There's a Mercedes gap too. I want one and can't afford one, but it's not government's job to do anything about it.
  36. Re:Well, there go the logfiles by pegr · · Score: 2, Interesting

    Sadly, most people who probably think port knocking is great security probably have yet to learn how to use DSA keys.

    Think "in addition to" and not "instead of". No reason why you couldn't do both. In fact, you could rotate your port knocks to be different everytime you connect. That way, if someone does try to fake their way in, you could detect it and react.

  37. Re:Well, there go the logfiles by S.Lemmon · · Score: 5, Interesting

    That doesn't seem right. If the order of the knocks is important, how do you get around that there's never a guarantee in what order network packets arrive? If no packets are sent back at all, how do you know when to send the next knock or even if the knock made it to the server?

  38. Re:Obscurity IS Security by Daniel+Boisvert · · Score: 2, Interesting

    Most security is based on secrets of one kind or another---that doesn't make it "obscurity."

    I think that's the point the grandparent is making. The key to this is that folks around here aren't real clear on the difference between "obscurity" and "secrets". One is touted as being worthless by itself, the other is accepted as the cornerstone of electronic security in general (I posit that the cornerstone of physical security is violence).

    the phrase "security through obscurity" means obscurity of system design.

    This is an excellent point, and deserves to be modded up because *way* too many people both here and elsewhere miss this fundamental concept. In my opinion any method that makes accessible hosts look the same as unaccessible hosts to a port scan is a great idea, no matter what folks here choose to call it.

    Dan

  39. It's _not_ just another password... by jdreed1024 · · Score: 4, Interesting

    I see a lot of comments saying "Well, why not just have two passwords?". It seems that people didn't read the article (the first link is /.ed, the second is not). The whole point is that with this, until you knock, the machine appears as a closed machine. No ports open. All ports will simply drop packets on the floor, meaning that a hacker scanning your subnet will not bother with that machine. The machine essentially appears invisible until knocked. Even with the most secure system, the hacker can still see that you're running, say, sshd, Apache, CUPS, and a few other services. And if a buffer overflow was announced 5 minutes ago for, say, sshd, they know that they can attempt to exploit the machine, since they see port 22 open. If you are using Port Knocking, you can have a vulnerable sshd, and it's a hell of a lot less likely to get exploited since the cracker has no way of knowing that you're running sshd...

    --
    There is no sig, there is only Zuul.
  40. Re:Obscurity IS Security by Anonymous Coward · · Score: 1, Interesting

    By that definition port knocking isn't security by obscurity either. The secret is the sequence of knocks and the server port number, the protocol is that connections to the server port will only be accepted after the knock sequence has arrived from the same ip address as the connection to the server port. The security of this protocol doesn't drop if the protocol is revealed. If you know about the port knocking protocol (you do now), can you tell if a server uses it without knowing the secret?

  41. Re:VPNs already solved this problem... by Tet · · Score: 2, Interesting
    I already have a solution for this scenario. It's called a VPN.

    Congratulations. You've just extended your "secure" corporate network beyond the physical walls of the office, and into the house of one of your employees. Are you sure that the machine they're using as a VPN client hasn't been rooted? VPNs have their uses, but they're far from solving this problem, and in many ways weaken your overall security. The correct solution is to change the authorisation criteria from things you know (password, "secret handshake") to things you know plus something else, for example, things you have. We do this with one time passwords sent to a user's mobile phone. Once that's been entered, they're prompted for their normal password. Thus even if the box has been rooted, and has keystroke and network sniffers galore, it doesn't matter. So long as the black hats don't have my trusted employee's mobile phone, they're not going to get in (and furthermore, the unexpected passwords being sent to the phone act as an early warning system to let us know someone's trying to break in). Of course, no security measures are perfect, and theoretically, with root access, they could hijack an existing ssh connection once it's been opened, but it's non-trivial, and we've raised the bar considerably.

    --
    "The invisible and the non-existent look very much alike." -- Delos B. McKown
  42. Simpler Implementation by John.P.Jones · · Score: 3, Interesting
    You could, more simply, have your little script listen for messages (UDP) sent to port x. If the message has the following form.

    "open port Y for ip Z using key K"

    if the port opening policy accepts this command then it is opened otherwise it is not. Better yet 'REAL' crypto could be used to protect the ports. Fore example...

    "open port Y for ip Z @ TIMESTAMP" Encrypted by K.

    This simpler implementation (more likely to be correct) will provide equivalent security.

  43. Still vulnerable to packet sniffing by me.nick() · · Score: 3, Interesting

    This is a great way to hinder people from randomly picking to hack your box by scanning for open ports. However, if someone is dedicated to hack YOU specifically, they could still use a man-in-the-middle attack, sniff the packets to see which port sequence you were using, etc, etc.

    Of course, there really is no way to block a skilled hacker who is intent on breaking into a specific network/box by any means necessary.

  44. Re:Well, there go the logfiles by Penguinshit · · Score: 2, Interesting


    An additional step here would be to have both machines (server, client) seeded with the same randomly-generated number and then, utilizing the same algorithm, generate a random port sequence for knocking. This sequence would be valid for 10 to 30 seconds, at which point the sequence for proper knocking is re-generated.

    I'm guessing this would need to be tied to Time of Day, necessitating accurate time; so either an external GPS device or an NTP connection would be required.

    This is just some off-the-cuff speculation, so don't flame me for the holes.

  45. All the time the same arguments by phoenix321 · · Score: 5, Interesting

    This is security by obscurity, but it is useful. Don't repeat this mantra just because "the experts" say so.

    Since some still don't understand its use, i'll be speaking metaphorical:

    Assume you need to have a special key to open a certain otherwise secure door. OpenSSH might be that door and your passphrase and your certificate are the key.

    An attacker can still forge the key or attack the lock with a different approach, picking etc. - comparable to "social engineering" to get the password, brute forcing or exploits.

    And that port knocking sequence now effectively hides the lock, leaving an attacker without a first approach to pick or break the lock. It just adds another layer of security. You just don't know where to start your attack. You can't use exploits, you can't try brute force - nothing, heck you don't even know what type of daemon your target is.

    A clean stainless steel door with a covert RFID-detector one square inch in size, hidden somewhere, sure as hell beats the same door with a clearly visible lock. You still need to pick the lock, but you can't poke your lockpicking tools into solid steel and you can't crack something you cannot discern.

    --- Still one addition to say: having a machine connected to the internet with no ports open makes you a prime suspect for the port knocking scheme.

    A good stealth scheme may be implemented, so a potential attacker (excuse for this metaphor again) does not even see the door (or the building, for that matter).

  46. I did this about 5 years ago by Skapare · · Score: 4, Interesting

    I did this about 5 years ago. But my method was a bit different. Instead of using port numbers to contain the information (and that's all it really is, is just information), I sent a single UDP packet, with a source port of 53 (so it looks like a DNS answer), formatted like a DNS answer, that contained the information in the DNS answer data. Then it opened the SSH filter for that IP address to come in (I did it for 5 minutes, not 10 seconds). It still had to fully authenticate via SSH, so even if someone sniffed my DNS packet and tried to fake it, they could at most have a locked door to jiggle the handle on. Next time I do this, it will be to generate an MD5 checksum from the client IP and a secret salt, and send that as an IPv6 address in the packet. Then it can't even be faked from some other IP address.

    --
    now we need to go OSS in diesel cars
  47. Counter Proposal: Port Traps by henrypijames · · Score: 5, Interesting

    What if I turn this whole thing around and install fake services on a number of ports?

    For example, whenever you make a connection to a port between 1025 and 2048 on my system, you're greeted with "OpenSSH ...", and prompted to authenticate. But only behind one among those 1024 ports is the real SSH. On any other port, the fake service takes the username and password you've entered, wait a few seconds (just idling around), and tell you "Authentication failed". If you try too often to connect to faked services, you're put on the black list to avoid DOS, of course.

  48. Why not use a listening socket on UDP+encryption? by jelle · · Score: 3, Interesting

    This is a neat trick, but it does not really increase protection against targeted attacks.

    It really is nothing more than a password to get access to the front gate... When somebody eavesdrops (sniffing), they will know the passwords, thus get access to the gate. They can sucessfully detect the knocking sequence because it is followed by a successfull ssh connection (duh!).

    The password is this 'secret sequence' in this 'port knocking'. Why not just use a daemon that listens on a UDP socket for a packet with an encrypted password in its payload? The payload could even be an RSA-signed and/or encrypted request (that includes a timestamp). That would be unscannable too, because UDP is connectionless, and be a lot more secure because of the real encryption/protection of the request data (the server can verify the identity of the sender of the request from the RSA signature, and can deny the request if one was made earlier with the same time stamp, twarting even sniffing of the UDP packet).

    Except for not having the ssh daemon 'connected' to the internet at all times and thus evading many port-scanning worms/scripts, this port knocking is nothing more than just some security through obscurity: At best it will delay the attacker somewhat, but probably not at all while giving the user a false sense of being secured.

    --
    --- Hindsight is 20/20, but walking backwards is not the answer.
  49. Re:Well, there go the logfiles by WNight · · Score: 4, Interesting

    You can also open up inbound ports from specific external IP addresses only, and do many at once. So ten inbound connections can reach ten different internal webservers, and at the next request, reach the same one again.

    This can be done dynamically as a form of load balancing which is a neat hack. Expire the specific forward rule after 30s or something. Means similar requests cluster - less DB traffic.

    But, combine this with knocking and you've got the next step. Secret services on a 'stealthed' IP, where you can request which quake server (for instance) by knocking in a different way.

    Port scanning isn't what it once was. Especially once you factor in time-sensitive keys (easily doable - both machines need a net connect to reach each other, ntp is then trivial) and ID-sensitive keys (so my key isn't like yours, even at the same time). Even if you managed to snoop on a 'knock' you couldn't repeat it.

  50. Re:Well, there go the logfiles by Billly+Gates · · Score: 2, Interesting

    I suppose a way around this would be to have an old 486 running BSD or Linux act as a first layer firewall and knocking device between your nat/router and ISP. You could just keep open port 22 on your nat/router and have the BSD box decide based on knocks which client to forward the packets the packets too.

    Another method I would like is some sort of handshake authentication where the firewall would reconigze who you were after logging in and would open ports up appropriately depending on your private key. I think MS proxy server does this with NTLM authentication but I am not too sure. There is IPSEC but this does not work over the internet or many campus wide networks if your at a unviversity.

    A unix equilivant would be nice with Kerbos, LPAD or Samba support.

    Having a dual firewall this way is rudant but it would work since I use my nat/router more as a hub then just a firewall.

  51. Reminds me of xringd by Yeechang+Lee · · Score: 2, Interesting

    Back when I depended on a dialup connection, I used xringd. By having the phone line the modem was on ring in a certain pattern, I could command the computer to dial up (using diald). Then a line in /etc/ppp/ip-up.local would mail me the IP address the PPP server assigned the computer (this was before DynIP or DynDNS). I'd then be able to log into the machine. Pretty darn cool for 1996.

  52. Different kinds of "listening", different places. by billstewart · · Score: 2, Interesting
    If your listener program is secure, it's not a risk; the big security question is whether you can make a knocking-listener that's secure enough that it doesn't increase the risk. The less big security question is whether it can make things harder for attackers without breaking too many other things. For instance, if it runs as root (or as a kernel module) and has buffer overflow problems, it's an entertaining target of attack. On the other hand, if all it does is detects connection requests, passes the IP address and port number to a validator program, and sends a TCP or ICMP reject message, it might be safe enough.

    It doesn't actually use significant resources unless it's getting pounded with lots of packets, and you can limit this by only listening on a few ports, blocklisting IP addresses that knock on the wrong ports, and limiting the rate that you actually respond to requests from a given IP address. On the other hand, you have to be careful not to let the attacker spoof a bunch of _bad_ requests, causing you to blocklist a real site. Depending on how much eavesdropping capability the attacker has, this may be easy or hard.

    The security advantage of this method over a single-port method with a password is that there are applications that you run which may have bugs in them, such as your SSH server or SNMP monitors, which you're not going to rewrite, and it lets you block access to them except from authorized users. It's a defense-in-depth strategy, possibly good (though it looks clumsy to me.) It can cut down on lots of the script kiddies.

    Also, this doesn't have to be in your main server. This is the kind of application you could build into your firewall box, so it reduces the number of ports that can pass through the firewall, except when somebody knocked successfully, and the firewall doesn't allow passthough on the knocking ports. Of course, you could accomplish almost the same thing wiht better security by accepting SSL requests to an application on the firewall...

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  53. encoding for noise rejection by firewood · · Score: 4, Interesting

    This is a great idea.

    It adds security to any existing methods (passwords, etc.).

    It can be implemented behind a firewall that doesn't even respond on any port probes, so an attacker can't even tell if the firewall was just unplugged.

    If the firewall stays closed, the protocol can't be used by an exploited machine, unless a method for exploiting the firewall is also known.

    Or the method can be implemented in user space of a machine behind a completely closed firewall, just by pre-arranging for the logging of firewall port probes, and the forwarding of appropriately filtered contents of the firewall logs into user space.

    They key sequence can also be made long enough to make it just as hard to crack as a long pgp private key, e.g. nobody except (3 letter agency) and distributed.net will even bother to try.

    The sequence key can be from a one-time pad, meaning that even if the protocol is completely revealed to a local sniffer, they'll just end up with a useless password.

    And lastly, it's possible to additionally encode the key sequence with a modulation wrapper and enough redundancy to withstand a given signal to noise ratio and mis-sequencing rate, which means one could even make the sequence key usable in the face of probing or an outright DoS attack against the protocol up to a certain attack bandwidth and knowledge of which ports might be in the sequence.

    Where's my coding textbook and patent attorney...

  54. Re:Open a whole range of ports by Bill+Privatus · · Score: 4, Interesting

    Sorry, wrong. There are several messages in this thread that mention REJECT (response to packet) instead of DROP (total silence). With this scheme in place, you need not listen on *any* ports, and you need not respond in any way. You can have a totally silent box, even with 10 or 20 services "listening". Nothing gets through until your iptables/ipchains software allows the traffic through.

    Admittedly, if you're running a public site, you're mixing two kinds of solution --- publicly available vs secured, but analogous statements can be made here - you can't tell a public site using port knocking for some special services from a public site that doesn't support same.

    This is like a void fn() in C (no return status). You knock on the 5, 10, or 25 ports in the right sequence to "send your message". You get nothing back. You then try to open the port that is your ultimate destination - if it's open, you're fine, if it's not, you have issues. This isn't a full-duplex kind of protocol, folks. I love it :-)

    Thus, it is impossible to distinguish a totally silent box (listening on no ports, dropping all packets) that has implemented port knocking from a box that is merely totally silent.

    As a two-laptop user who attaches to corporate LANs and public high-speed networks in hotels, I just love the idea of having all packets dropped until someone sends "shave & a haircut!" - then letting them in for a bit.

    It would certainly be better than my current approach - using ethernet addresses (maclist in Shorewall! :-) to allow ftp and http etc to my linux box.

    --
    Redundancy is good; triple redundancy is twice as good! - Me.
  55. one way around it by Anonymous Coward · · Score: 1, Interesting

    i think by watching the traffic, it would be possible to figure out what the knock is. logging the sequence of port accesses by a particular ip address would make the pattern apparent.

  56. Seem quite vulnerable.. but neat for crypto!? by mattr · · Score: 2, Interesting

    Seems vulnerable to traffic analysis, as someone mentioned you don't use a combination lock that sends packets all over the world. People will want more complicated sequences, but it will take more time to send them and they may have to resend due to TCP packets coming in different order. But even so anybody on your network or the server's network should be able to see what's going on, how secure is that? And if the server ever responds to your ip from any port then you likewise hosed.

    On the other hand this does seem to be an interesting way to one-way send information to the server. I was thinking of playing solitaire using Bruce Schneier's algorithm using a port for each card of a deck.

    IANA cypherpunk, but there seem to be a number of ways to treat the set of all closed ports as a numerical space that would be interesting for encrypted communications.

    For example you could convert a one-time pad, a private key, or a set of communication channels into a list of port numbers. For a short message at least, you could send with pretty good security (although the list of ports, if not their hash values, would be known to the outside world).

    To me this knocking stuff sounds like it only *reduces* security and provides lots of interesting clues to men in the middle. The intriguing part seems to be that you can send a good deal of information through a large number of half-connections in parallel, but this may have already been tried by other people. Of course if the message is simple enough that a single ping to a single prearranged port number is enough to convey it, then you would seem to have a pretty strong system though its existence would certainly be uncovered sooner or later. But if this became popular I suppose the advantage would be in being able to assign certain ports to prearranged values, both for encryption purposes and also to reduce the amount of data you actually need to send.