# [GoldSrc] RCE via malformed BSP file

Malformed BSP WAD path overflows a 260-byte stack buffer in COM_FileBase, letting a crafted map file execute arbitrary code on any player who loads it.

- Payout: $450
- Severity: high
- Program: Valve
- Found by: gamer7112
- Disclosed: 2020-08-19
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/763403
- Library page: https://bugbountylibrary.com/r/h1%3A763403
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:high tech:windows technique:source-review vuln:memory-corruption vuln:rce

**Target:** GoldSrc engine (hl.exe) TEX_InitFromWad / COM_FileBase BSP WAD path parsing
**Root cause:** COM_FileBase copies the WAD filename from the BSP into a fixed 260-byte stack buffer (wadName) with no length validation, overflowing adjacent stack memory.
**Steps:**
1. Craft a BSP whose embedded WAD path string exceeds 260 bytes.
2. Place the BSP in the game's maps directory (e.g. cstrike/maps).
3. Launch the game, open console with `~`.
4. Run `map de_RCE` to load the map.
5. Overflow triggers and calc.exe pops, demonstrating code execution.
**How found:** Code review of TEX_InitFromWad revealed COM_FileBase writing into wadName[260] without bounds checking on the BSP-supplied WAD path.
**Exploitation:** Attacker distributes a malicious BSP map file; when a victim loads it via the map command, the oversized WAD path overflows the stack buffer and redirects execution to attacker-controlled code (calc pop as PoC).
**Insight:** Game asset parsers that embed external file references (WAD paths inside BSP) are prime overflow targets; audit fixed-size stack buffers fed by attacker-controlled strings inside map/model files, since players load untrusted content from servers.

