[GoldSrc] Remote Code Execution using malicious WAD list in BSP file
The TEX_InitFromWad function copies a WAD file name from a path into a small stack buffer using COM_FileBase, which performs no boundary checks, so an overly long name overflows the stack. An attacker could use this to run arbitrary code on a victim's machine when they connect to a malicious server.
Originally disclosed on HackerOne
- Triaged in 7 months
- Fixed in 12 months
- Paid in 12 months
- Disclosed after 21 months
Summary by the program
Summary
TEX_InitFromWad function calls COM_FileBase to get file name from a path into a buffer on the stack. Since COM_FileBase does not have boundary checks and the buffer is small, long WAD file name can trigger a Stack Buffer Overflow, leading to arbitrary code execution.
Steps to reproduce
Environment: Windows 10 x64 18362
- Install Counter-Strike Dedicated Server. Let's call the directory where it's installed
SERVER_DIR - Install AMX Mod X for the dedicated server
- Compile F558348, install and enable it in AMX Mod X
plugins.ini - Copy any
.exefile toSERVER_DIR/cstrike/pwn.ed(pwn.edis the file name) - Extract F558346 to
SERVER_DIR/cstrike/maps/ - Start Counter-Strike Dedicated Server on map
cs_pwn - After the map is fully loaded, extract F558347 to
SERVER_DIR/cstrike/maps/ - Install Counter-Strike Client
- Start Counter-Strike Client
- Connect to the dedicated server
Expected behavior: pwn.ed will be downloaded and executed.
Impact
Attackers can remotely execute arbitrary code on victim's computer. The lack of ASLR on hl.exe makes the exploit 100% reliable.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the COM_FileBase helper copies the base file name into a fixed-size stack buffer without any length check, so a long WAD name overflows it.
Impact
An attacker could run arbitrary code on a victim's computer, and the absence of ASLR on the game executable makes the exploit fully reliable.
What the attacker needed
Victim connects to attacker's server; Server runs AMX Mod X with a plugin
How it was found
- Set up a Counter-Strike dedicated server with AMX Mod X and a custom plugin enabled.
- Place an executable file in the game's cstrike directory under a chosen name.
- Put the crafted map files on the server and start the server on that map.
- Add the remaining map files after the map has fully loaded.
- Start the Counter-Strike client and connect to the dedicated server.
- The executable is downloaded and run on the client.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Because the game executable has no ASLR, the attack is described as fully reliable.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.