Monday, May 9, 2011

Two part network authentication

We've just changed to using two part authentication for google at work, and it seems to do the job well - unintrusive, unless you lose your phone. The idea is simple - retain your current password, but use a second one-time password which is generated by an app on your phone. When you first set it up, you paste a massive password into your phone if you're unlucky enough to not have an iPhone 3GS or higher (with a camera capable of reading the barcode on the screen). This acts as the seed for a random number generator, which is combined with the current time to the nearest minute to generate one-time passwords that can only be predicted if both sides have their time synchronised and share the same password.

This is cool in itself, but after a conversation with one of my colleagues I thought it would be cool to extend it, and combine it with the concept of port knocking.

Port knocking, for those who don't know, is at worst another layer of security through obscurity, but at best is another channel for confirming knowledge of shared secrets. Normal firewalls try to make it difficult for potential hackers by detecting when they scan for open ports (which correspond to network services) and then not confirming or denying whether or not any of the ports are open. Port knocking goes further, by making all ports appear closed, unless the IP attempting to connect to a service has recently queried a list of ports in the correct order (a sort of secret knock if you like).

A traditional port knock is a predictable sequence, which can be easily inspected by routers along the way. To add a further layer of security, setting the TCP sequence number to the value of a hash of the packet combined with a shared secret - thus ensuring a port knock from one IP can't be replayed later from another.

But what if we want to make the sequence itself unpredictable? If we restrict ourself to just 256 ports, and make our port knock sequence 16 ports long, then we can convert the output from a cryptographic hash into a sequence of ports to query. Sharing a secret in advance, and salting this with the current time to the nearest minute allows us to create per-session portknocks. And the icing on the cake? Add the IP to the time as a second salt, allowing the client to perform the portknock in plain sight, and then be allowed access to a totally hidden port.

OR..... we could just use IPSEC AH

No comments:

Post a Comment