I was recently reading some literature about data encryption and I stumbled across an interesting concept. The classic secure communication model is the one where the sender encrypts the message and sends it across the network, which is then decrypted at the receiver’s end. In real life, this is done over several networks and several routers. This method works well because we assume that the routers are completely secure and they do exactly what they are told. Now what if a router is compromised on the path? An attacker will be able to monitor all the traffic that goes through it. Once the attacker gains control of the router, many bad things can happen like decryption of secure messages, false communication, leakage of sensitive details etc. How do we prevent it?
What is onion routing?
In it’s most basic form, onion routing is a technique for anonymous communication over a computer network. The idea of onion routing is to protect the privacy of the sender and recipient of a message, while also providing protection for message content as it traverses a network. Onion routing achieves this by making the messages travel from source to destination via a sequence of proxies, which re-route messages in an unpredictable path. Proxies are like nodes in a graph. Messages are repeatedly encrypted on this path and then sent through several network nodes called onion routers. Each onion router removes a layer of encryption to uncover routing instructions, like peeling an onion, and sends the message to the next router where this process is repeated. This prevents the intermediary nodes from knowing the origin, destination, and contents of the message.
How about an actual example?
Sure, let’s consider a demonstrative example. In the olden days, people used messengers with horses to deliver messages. We will consider a case where someone wants to deliver a secret message. The sender leaves a box somewhere along with a key and informs the messenger anonymously. The messenger now has a key to the box. The messenger opens the box and finds out that there is a smaller box insider and also a sheet of paper with instructions on how to deliver this box to another messenger. He goes on and delivers this box to that messenger. That messenger has the key to the smaller box. He opens it and finds out that there is an even smaller box inside this box and also a sheet of paper with instructions. This process continues until it reaches the intended receiver. You see what happened here? None of the messengers knew anything about the content, the source or the destination.
Why do we need it?
To prevent an adversary from eavesdropping on message content, messages are encrypted between routers. The advantage of onion routing is that it is not necessary to trust each cooperating router. If any router is compromised, anonymous communication can still be achieved. This is because each router in at the network accepts messages, re-encrypts them, and transmits to another onion router. An attacker with the ability to monitor every onion router in a network might be able to trace the path of a message through the network, but that’s very rare. An attacker who has control over only a few routers on the path will have difficulty in getting any meaningful information.
What does an “onion” look like?
This is a popular figure of the routing onion you will see everywhere. A routing onion is a data structure formed by wrapping a plaintext message with successive layers of encryption, such that each layer can be unwrapped (decrypted) like the layer of an onion by one intermediary in a succession of intermediaries. The plaintext message is the actual message and the layers of onion are the encryption layers. This way, the original plaintext message is only viewable by the sender, the recipient and may be the last node. If there is end-to-end encryption between the sender and the recipient, then not even the last node can view the original message.
Are there any weaknesses?
As is the case with any data encryption protocol, onion routing also has some drawbacks. Usually it’s difficult for an attacker to establish if a node is an onion router or not. But an attacker could a determine this by correlating when messages are sent by a server and when messages are received by a node. Also, if there is no end-to-end encryption, the last node in a chain has complete access to the content being transmitted from the sender to the recipient.
Onion routing does not provide perfect sender or receiver anonymity against all possible eavesdroppers. It is possible for a local eavesdropper to observe that an individual has sent or received a message. It does provide for a strong degree of unlinkability, which means that that an eavesdropper cannot easily determine both the sender and receiver of a given message. It actually provides a way in which the degree of privacy depends on the number of participating routers and the number of compromised routers.