why-am-i-even-here
Member
- Nov 7, 2015
- 53
- 78
- 53
Follow up on this post.
This guide aims to provide some ideas regarding how you, as a server administrator, can protect your server against various attacks. This guide does not discuss correctly configuring your server and the permissions system. If you're a server admin, you should already know these things. Instead this guide focuses on constructing an effective firewall for your TeamSpeak server.
Basic knowledge of computer networks and protocols is expected from the reader. This guide is primarily only interesting for admins who host their server themselves. The concepts presented here have been tested in production systems and served me well. If you come from a DevOps / NetSec background, you'll recognize most of the patterns discussed here. This guide contains no code. You'll have to come up with your own implementation.
The ideas proposed in this guide will mainly combat these threats:
First off, some terminology and definitions:
Firewalls
A firewall is a system that is located in between a service and the clients. The firewall is responsible for filtering the incoming traffic and in the best case only allows legit requests to pass through. In our case one could also imagine the firewall as a reverse proxy on steroids. We'll call these access points gateways.
A firewall is only effective, if it can not be sidestepped. Your TeamSpeak server must not be accessible directly by (regular) clients. If your server's running on a machine with a "secret" IP address, that's sufficient, as long as that IP address really is secret and does not get exposed by accident.
Single point of failure
Modern servers are programmed with high availability and reliability in mind. Take most professional websites as an example; Google can reboot servers without a service interruption. It's also no problem when servers fail and crash. The end user doesn't notice this. This behaviour is achieved by using clusters of servers that run micro-services and load balancers.
As we all know, TeamSpeak is a shitty piece of software. If you're running a server, you'll surely have experienced what a SPOF is first-handedly. There's nothing more frustrating than being in a game and then having some 14 years old small-dicked shit-face DDoS your server with a cheap as fuck botnet like exitus.to. And there's nothing you could do about it. And it's not even like it's your fault or that the fucking script kiddy is such a skilled hacker. No. It's the TeamSpeak devs' fault.
Servers do fail from time to time. There is nothing you can do about that. However, you could make it so that the service as a whole keeps up. If only the devs of TS had implemented such a thing as clustering.
Protocols
The TeamSpeak 3 server (and its accompanying services) uses multiple protocols. Most of which are used for "home calling". They can be disregarded mostly. We'll talk about these protocols:
Naming things
Ask any programmer. Naming things is hard. I'm so lucky I don't intend to have children. So we'll just go with this naming scheme for the sake of this guide: servers protected by the firewall are named after famous scientists, gateways are assigned International Air Transport Association airport codes. How fitting. Assume that the associated A records have been set correctly.
Basic structure
We'll start off with the most basic scenario and then expand upon that.
Okay. So we need to keep our real TS server IP address secret and then proxy all traffic through gateways that act as a firewall. How do we do that?
Well, you'll need at least two independent servers. These can be VPS on different host systems or even two root servers. It doesn't matter for now. One server runs the TeamSpeak server (Einstein) and the other server acts as a gateway (LAX).
Einstein
... runs the TeamSpeak server. There is one important bit of configuration you must not forget: turn off the weblist. If your server broadcasts its real IP address to the TeamSpeak weblist your firewall loses all effectiveness.
LAX
... is a gateway to Einstein. In the most trivial case this means that it forwards all incoming traffic to Einstein and proxies the responses back to the correspondig clients. "All incoming traffic" being UDP 9987 (voice and data), TCP 10011 (ServerQuery) and file transfer (TCP 30033).
What now?
All clients then connect to lax.example.com instead of einstein.example.com. To them it will look like LAX actually is running the TeamSpeak server.
For some admins, this might already be enough and they can stop here. You now have two different ways of accessing your server. The public LAX gateway and the private direct connection. For instance, you could give the secret IP address only to people you trust. This way, if some ass-hat tries to DDoS your server, only the public LAX gateway will go down. But everyone who connected directly to Einstein will not notice anything. Well, maybe they'll notice all clients conencted via LAX timing out.
But hey! No random disconnects for you and your buddies while being ingame. ~~yeah~~
One more thing: Nobody likes remembering names. Be considerate of your users and create an SRV record, will ya?
The weblist
"But w-a-i-e-h, I want my server to appear on the weblist b/c I want moar of dem usas!"
No problem. Just emulate the weblist protocol. It's not very hard to reverse engineer. Sniff the traffic from and to weblist.teamspeak.com:2010 (UDP). If you speak German you might as well read this: http://yat.qa/ressourcen/protokolle/#weblist-server
The emulator should of course run on LAX. Faking the weblist protocol obviously comes with a few advantages. I'm sure you know what I mean.
Stepping up your game
"Two is one, and one is none."
One gateway doesn't really get you anywhere. You don't want to give out your secret IP address. Not even to friends. You'll much rather have different gateways for different groups of users.
It's time to add additional gateways, depending on how many users you have and how much money you want to spend. I recommend a minimum of three gateways.
Why give users that connect via the weblist their very own gateway? We have discovered that most of the DDoS attacks are performed by fucktards that randomly connect high-ranking servers. If my penis was ingrown I'd probably do the same to get off.
Luckily, we can isolate this group on their own gateway, so when they do perform an attack, only this gateway fails. Of course you don't want users to permanently connect via this gateway for this very reason. We solve this situation by automatically messaging these users when they've been on the server for more than 2 hours (in total in the last 3 days). No troll invests that much time. In this message we ask them to only connect via our domain example.com (which directs them to LAX) and keep nagging them until they do. Easy as pie.
AMS is the gateway that is supposed to guarantee uninterrupted service to all its clients. Therefore only users of whom you are certain that will not attack you should be able to connect to this gateway.
You can set up arbitrarily many additional gateways. There are many ways in which you can segregate users into groups of varying trust levels. Online time, server group, etc.
However, you now have a problem. How do you tell ther user's client which gateway it should use? Give each group of users their own SRV record? lol nope.
--- snip snip, max post length reached ^^ ---
This guide aims to provide some ideas regarding how you, as a server administrator, can protect your server against various attacks. This guide does not discuss correctly configuring your server and the permissions system. If you're a server admin, you should already know these things. Instead this guide focuses on constructing an effective firewall for your TeamSpeak server.
Basic knowledge of computer networks and protocols is expected from the reader. This guide is primarily only interesting for admins who host their server themselves. The concepts presented here have been tested in production systems and served me well. If you come from a DevOps / NetSec background, you'll recognize most of the patterns discussed here. This guide contains no code. You'll have to come up with your own implementation.
The ideas proposed in this guide will mainly combat these threats:
- DDoS attacks
- All exploits and hacks based on ServerQuery or file transfer
First off, some terminology and definitions:
Firewalls
A firewall is a system that is located in between a service and the clients. The firewall is responsible for filtering the incoming traffic and in the best case only allows legit requests to pass through. In our case one could also imagine the firewall as a reverse proxy on steroids. We'll call these access points gateways.
A firewall is only effective, if it can not be sidestepped. Your TeamSpeak server must not be accessible directly by (regular) clients. If your server's running on a machine with a "secret" IP address, that's sufficient, as long as that IP address really is secret and does not get exposed by accident.
Single point of failure
Modern servers are programmed with high availability and reliability in mind. Take most professional websites as an example; Google can reboot servers without a service interruption. It's also no problem when servers fail and crash. The end user doesn't notice this. This behaviour is achieved by using clusters of servers that run micro-services and load balancers.
As we all know, TeamSpeak is a shitty piece of software. If you're running a server, you'll surely have experienced what a SPOF is first-handedly. There's nothing more frustrating than being in a game and then having some 14 years old small-dicked shit-face DDoS your server with a cheap as fuck botnet like exitus.to. And there's nothing you could do about it. And it's not even like it's your fault or that the fucking script kiddy is such a skilled hacker. No. It's the TeamSpeak devs' fault.
Servers do fail from time to time. There is nothing you can do about that. However, you could make it so that the service as a whole keeps up. If only the devs of TS had implemented such a thing as clustering.
Protocols
The TeamSpeak 3 server (and its accompanying services) uses multiple protocols. Most of which are used for "home calling". They can be disregarded mostly. We'll talk about these protocols:
- INBOUND UDP 9987: voice and data
- INBOUND TCP 10011: ServerQuery
- INBOUND TCP 30033: file transfer
- INBOUND TCP 41144: TSDNS
- OUTBOUND UDP 2010: weblist
Naming things
Ask any programmer. Naming things is hard. I'm so lucky I don't intend to have children. So we'll just go with this naming scheme for the sake of this guide: servers protected by the firewall are named after famous scientists, gateways are assigned International Air Transport Association airport codes. How fitting. Assume that the associated A records have been set correctly.
Basic structure
We'll start off with the most basic scenario and then expand upon that.
Okay. So we need to keep our real TS server IP address secret and then proxy all traffic through gateways that act as a firewall. How do we do that?
Well, you'll need at least two independent servers. These can be VPS on different host systems or even two root servers. It doesn't matter for now. One server runs the TeamSpeak server (Einstein) and the other server acts as a gateway (LAX).
Einstein
... runs the TeamSpeak server. There is one important bit of configuration you must not forget: turn off the weblist. If your server broadcasts its real IP address to the TeamSpeak weblist your firewall loses all effectiveness.
LAX
... is a gateway to Einstein. In the most trivial case this means that it forwards all incoming traffic to Einstein and proxies the responses back to the correspondig clients. "All incoming traffic" being UDP 9987 (voice and data), TCP 10011 (ServerQuery) and file transfer (TCP 30033).
What now?
All clients then connect to lax.example.com instead of einstein.example.com. To them it will look like LAX actually is running the TeamSpeak server.
For some admins, this might already be enough and they can stop here. You now have two different ways of accessing your server. The public LAX gateway and the private direct connection. For instance, you could give the secret IP address only to people you trust. This way, if some ass-hat tries to DDoS your server, only the public LAX gateway will go down. But everyone who connected directly to Einstein will not notice anything. Well, maybe they'll notice all clients conencted via LAX timing out.
But hey! No random disconnects for you and your buddies while being ingame. ~~yeah~~
One more thing: Nobody likes remembering names. Be considerate of your users and create an SRV record, will ya?
The weblist
"But w-a-i-e-h, I want my server to appear on the weblist b/c I want moar of dem usas!"
No problem. Just emulate the weblist protocol. It's not very hard to reverse engineer. Sniff the traffic from and to weblist.teamspeak.com:2010 (UDP). If you speak German you might as well read this: http://yat.qa/ressourcen/protokolle/#weblist-server
The emulator should of course run on LAX. Faking the weblist protocol obviously comes with a few advantages. I'm sure you know what I mean.
Stepping up your game
"Two is one, and one is none."
One gateway doesn't really get you anywhere. You don't want to give out your secret IP address. Not even to friends. You'll much rather have different gateways for different groups of users.
It's time to add additional gateways, depending on how many users you have and how much money you want to spend. I recommend a minimum of three gateways.
- LAX: the "default" gateway, regular users connect via this one.
- FRA: this gateway only serves weblist users.
- AMS: the "premium" gateway for personally trusted and / or paying users.
Why give users that connect via the weblist their very own gateway? We have discovered that most of the DDoS attacks are performed by fucktards that randomly connect high-ranking servers. If my penis was ingrown I'd probably do the same to get off.
Luckily, we can isolate this group on their own gateway, so when they do perform an attack, only this gateway fails. Of course you don't want users to permanently connect via this gateway for this very reason. We solve this situation by automatically messaging these users when they've been on the server for more than 2 hours (in total in the last 3 days). No troll invests that much time. In this message we ask them to only connect via our domain example.com (which directs them to LAX) and keep nagging them until they do. Easy as pie.
AMS is the gateway that is supposed to guarantee uninterrupted service to all its clients. Therefore only users of whom you are certain that will not attack you should be able to connect to this gateway.
You can set up arbitrarily many additional gateways. There are many ways in which you can segregate users into groups of varying trust levels. Online time, server group, etc.
However, you now have a problem. How do you tell ther user's client which gateway it should use? Give each group of users their own SRV record? lol nope.
--- snip snip, max post length reached ^^ ---
Last edited: