Is a GMod Map Safe? Check a BSP Before It Goes on Your Server
Can a GMod map harm your server? What lua_run may do, what GMod blocks, and how to check the entities and pakfile of a BSP before installing it.
Yes, a map can harm a GMod server, and the main risks can be checked beforehand. The most important route is the lua_run entity: it runs Lua code stored in the map's entity data on the server. Apart from that, a map can disrupt a server without any code at all, for example with a flood of entities. You spot both by listing the entities and the pakfile and loading the map on a separate server first.
What a BSP can and cannot contain
A BSP is not a program but a collection of data blocks called lumps. Two of them matter for security: the entity lump, a text list of all entities with their properties, and the pakfile, a ZIP archive with embedded files. The full structure is explained in What is a BSP file?. That leaves a map two ways to do more than display geometry: entities that execute something, and files that the game mounts while loading.
Garry's Mod has tightened the second way. Since the security patches of December 2023, the game has checked embedded files against a whitelist. Whatever fails is not mounted, and the console shows:
BSP embedded file failed whitelist check - '<path of the file>'
Facepunch's patch notes mention the whitelist by name and list entries that were allowed later, such as materials/*.raw and scripts/vehicles/*.txt. Facepunch has not documented the complete list. The file system library of the current game version contains a pattern list in exactly this format, covering among other things models, materials, sounds, particles, navmesh, soundscapes and text files under maps/ and data_static/, but no pattern for Lua files. That this list is the whitelist is our reading of the file and not confirmed by Facepunch, and we have not tested in a running game whether a .lua in the pakfile is loaded. So treat Lua files in a pakfile as an anomaly that the author should explain.
lua_run: Lua code straight from the map
garrysmod.fgd describes lua_run briefly as "Runs Lua Code". The entity has a Code keyvalue, the spawnflag "Run code on spawn" and two inputs: RunCode runs the stored code, RunPassedCode runs code that another output sends along as a parameter. The code runs on the server and has the same capabilities there as an installed addon.
It is a legitimate tool. gm_construct, which ships with the game, contains two lua_run entities itself, and one of them shows players a hint (shortened):
{
"targetname" "ColorRoomHint"
"Code" "if ( TRIGGER_PLAYER ) then TRIGGER_PLAYER:SendHint( 'ColorRoom', 0 ) else Msg( 'No Player!!?/n' ) end"
"classname" "lua_run"
}
So what matters is not whether a map contains lua_run, but what the code says. Watch for these warning signs while reading:
- Network access such as
http.FetchorHTTP. A map has no need to talk to a third-party server. - Code loaded at runtime through
RunStringorCompileString. The real code then lives somewhere else, and you are only checking the shell. - Unreadable strings, for example long sequences of numbers.
- Console commands and ranks, meaning
RunConsoleCommand,game.ConsoleCommandor changes to user groups. RunPassedCodein outputs. The code is then not in thelua_runbut in the output of another entity. So search the entire entity list.
We found no server setting that forbids maps to run Lua, neither on the GMod wiki nor in the convar list. Garry's Mod only blocks certain console commands for Lua, among them rcon_password and sv_cheats. That does not replace reading the code.
Trouble without a single line of code
Command entities. In other Source games, point_servercommand and point_clientcommand send commands to the console. In Garry's Mod both are switched off: the game's base.fgd lists them commented out with a note that they are disabled in GMod, and Facepunch removed them from Hammer because they do not work in Garry's Mod. The Valve Developer Community wiki names abuse as the reason. If you find them in a map, the map probably comes from another game.
Entity floods. A map can create entities at runtime, for example through point_template with env_entity_maker or through npc_maker, often driven by a logic_timer. If that runs unchecked, all edicts are eventually in use. According to the GMod wiki the limit is around 8176 networked entities; the server first reports Warning: free edicts below threshold and in the worst case quits with ED_Alloc: no free edicts. The cause can just as well be a construction mistake as intent. How to count edicts is covered in the article on the edict limit and "no free edicts".
Crafted data. Facepunch keeps hardening the game against maps that provoke crashes. The November 2025 update lists, among other things, protection against nonsensical fog controller values, against a reload loop through player_loadsaved, and limits on the number of static props. So keep the server up to date: an old version is more vulnerable to such maps.
Content. Missing textures and models or a very large download are not an attack, but they drive players away.
Where the file comes from
The risk depends more on the source than on the file format. The entity lump is plain text and can be changed with simple tools. Anyone re-uploading a map can therefore add a lua_run without changing its name or look. With leaked copies you do not know who touched the file last.
Besides the BSP itself, the package can be the problem: if the map comes in an archive with a lua folder or an addon, that code runs without any lua_run. Read it like any other addon. What to look for when buying is covered in buying GMod maps safely.
The check before installing
- Establish the source. Get the map from its author or from a platform that shows who uploaded it.
- Look at the package. Expect a
.bsp, possibly with a navmesh. Read any Lua files and addons in the package completely. - List the entities. The entity lump is plain text, so a text search in the BSP is enough. Search for
lua_run,RunPassedCode,point_servercommandandpoint_clientcommand. The Map Scanner finds risky entities such aspoint_servercommandorlua_runand checks whether a spawnpoint exists. Judging the code is up to you. - List the pakfile.
bspzip -dirfrom thebinfolder of Garry's Mod prints every embedded file with its path. The Map Scanner also lists embedded Lua and asset files. Expectmaterials/,models/,sound/and the like. - Test in isolation. Start the map on a server without real player data and without access to your database. Read the console: whitelist messages, Lua errors and edict warnings appear there.
- Keep the checked file. Repeat steps 3 to 5 for every update.
bspzip -dir rp_example_v2.bsp
bspzip -repack copy_rp_example_v2.bsp
You only need the second line for compressed maps. Their lumps are packed, so a plain text search in the file finds nothing, and bspzip -dir fails as well. According to its help text, -repack without -compress unpacks the file again. In our test, however, the bspzip of the current Garry's Mod version quit on a compressed map without any message, while the bspzip from Team Fortress 2 unpacked the same file. Work on a copy when you do this.
The Map Scanner additionally checks the header, magic bytes, lump table and offsets for consistency and accepts BSP files up to 50 MB. What a mapper works through before publishing is in the checklist for checking a BSP before release.
FAQ
Does sv_allowcslua 0 stop maps from running Lua?
No. According to the GMod wiki, sv_allowcslua controls whether clients may use lua_openscript_cl and lua_run_cl, meaning their own scripts on their own machine. The setting has nothing to do with the lua_run entity, which runs on the server.
What do I do if I find suspicious code in a map?
Do not install it, and ask the author what the code is for. If you get no plausible answer, report the file to the platform it came from and use a different map.
Is a scan enough, or do I still have to test the map?
Test it anyway. A scan shows which entities and files are inside the BSP. What a logic chain does at runtime, for example how many entities it creates, only becomes visible on a running server.