# [GoldSrc] Remote Code Execution using malicious WAD list in BSP file

Malicious WAD filename in a BSP triggers a stack buffer overflow in TEX_InitFromWad via unchecked COM_FileBase, letting a server execute code on connecting clients.

- Payout: $750
- Severity: critical
- Program: Valve
- Found by: nyancat0131
- Disclosed: 2021-05-04
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/675710
- Library page: https://bugbountylibrary.com/r/h1%3A675710
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:critical tech:windows technique:source-review vuln:file-upload vuln:memory-corruption vuln:rce

**Target:** GoldSrc engine hl.exe, TEX_InitFromWad / COM_FileBase WAD path parsing
**Root cause:** TEX_InitFromWad calls COM_FileBase to copy a WAD filename from a path into a fixed-size stack buffer without bounds checking, so an overlong WAD name overflows the stack.
**Steps:**
1. Install CS Dedicated Server (SERVER_DIR) and AMX Mod X.
2. Compile/install plugin F558348 to serve a crafted map.
3. Place any .exe as SERVER_DIR/cstrike/pwn.ed.
4. Extract F558346 into SERVER_DIR/cstrike/maps/ and start server on cs_pwn.
5. After map loads, extract F558347 (malicious BSP with long WAD name) into maps/.
6. Start CS client and connect to the server.
7. Client downloads pwn.ed and executes it via the overflow.
**How found:** Code review of TEX_InitFromWad revealed COM_FileBase copies a path-derived filename into a small stack buffer with no length check; long WAD names in BSP files were the trigger.
**Exploitation:** Attacker controls a game server and serves a BSP whose WAD list contains an overlong filename; when a victim client connects and loads the map, TEX_InitFromWad overflows the stack buffer, and the absence of ASLR on hl.exe makes the ROP/shellcode payload 100% reliable, executing the downloaded pwn.ed.
**Escalation:** Chained map-loading with a malicious WAD list plus a file-download mechanism to deliver and execute an arbitrary .exe on the client.
**Insight:** BSP/WAD asset lists are attacker-controlled when joining a server; audit engine asset-loading paths (COM_FileBase-style helpers) for fixed stack buffers, and note that non-ASLR game binaries turn small overflows into reliable RCE.

