NAT (Network Address Translation) is essentially trying to make the internet feel larger, while we are running out of IPv4 spaces. Instead of giving all devices on the internet an IP address, we use NAT to use a single IP address that acts for the rest of the local network.
One great feature of routers essentially act as a Firewall, not allowing incoming connections to devices on the internal network (unless port forwarding or something else is setup).
Additionally, when a website attempts to make a connection (FTP, for example) the website says connect to me on 'X' port to connect to. However, with the protections of the router discussed above, this became impossible to do. So, the router notices that a particular port, on a particular computer is being asked for, the router allows this. This is called the application level gateway (alg).
10 years ago, Samy (yes, the MySpace worm guy) introduced a bypass for this protection by simply navigating to a malicious website, which opened a specific port on the router into the LAN. This is the 2.0 version.
This bypass worked by making a request directly to something on the internal network. But, web browsers are smart! They limited the usage of specific port, except that Samy found an integer overflow that allowed this port check to be bypassed. With this bypass at hand, it was possible to open an arbitrary TCP port on the router! For more information on this, view his original research at
samy.pl. For more fun, look into what
LiveConnect is!
Armed with the previous research (bugs were fixed), Samy wanted to see if he could find another bypass. He made a spreadsheet of Chrome restricted ports (to connect to) and a list of services (that were had connection port callbacks) to find a target. The most interesting one was SIP, or Sound over IP.
In order to launch this attack, the internal IP address must be known. The method for discovering this was an implicit timing attack. If a computer does not exist on the LAN, then it takes a significant amount of time to return and no data is sent back. Then, if there IS a computer with the IP with NO service running, then the connection is immediately refused. Using this timing attack, the LAN can be easily enumerated for local IPs.
To top this off, to find the computer that the current user is using, we can use another timing attack! Which computer on the LAN will respond the fastest? The one currently in the browser! Now, we know the local IP of the current user.
Now (back to the NAT pinning) we need to do some type of packet injection in order to trick the router to using an ALG when it should not.
Samy discovered that UDP stun can control the USERNAME of the packet at the very front of the request with unlimited length! With IP packet fragmentation (splitting of packets based upon the IP stack), we can do arbitrary UDP packet injection on the second packet. Whooo!
This time, he used simple form data and set the Maximum Segment Size to control the location of the boundary. As with the UDP attack, the splitting of packets (via fragmentation) allowed for the ability to control the header of any request! Because he controlled the starting portion of any header, he could trick the ALG to open arbitrary ports via a fake SIP call.
What can happen with the ability to access arbitrary ports? Well, instead of the services (on your computer) being local to yourself and the LAN, the malicious actor could now connect to the services!
A couple of wise words from Samy:
- Reads RFC when attempting to learn about a protocol
- Looks at Chrome flags, upcoming features and protocols that are supported by Chrome.
- When attempting to break the parsing, Samy bolded all inputs that he controlled to see how he could attack.
Fun fact: the last question asked in this video was me (totally forgot until I rewatched this video).