# [Half-Life 1] Malformed map name leads to memory corruption and code execution

A crafted map filename overflows a stack buffer in COM_ListMaps via sprintf when the user runs `maps *`, enabling arbitrary code execution.

- Payout: $1,500
- Severity: high
- Program: Valve
- Found by: kbeckmann
- Disclosed: 2020-09-22
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/402566
- Library page: https://bugbountylibrary.com/r/h1%3A402566
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:high tech:linux technique:source-review vuln:memory-corruption vuln:rce

**Target:** Half-Life 1 engine (hl.exe/hl_linux) COM_ListMaps map listing
**Root cause:** COM_ListMaps uses sprintf to copy map filenames into a fixed stack buffer without bounds checking, so an overlong map name overflows the stack.
**Steps:**
1. Place a map file with an overlong crafted name (e.g. generated by the provided python script) into /valve/maps.
2. Launch Half-Life.
3. Open the console and run `maps *`.
4. sprintf in COM_ListMaps (engine/common.c:2857) overflows the stack; control flow is hijacked (EIP=0x41414141 in crash).
5. Payload executes gnome-calculator as PoC.
**How found:** Researcher inspected COM_ListMaps/Host_Maps_f source and noticed sprintf into a fixed buffer with map filenames; crafted an overlong map name and confirmed stack overwrite via crash backtrace showing 0x41414141.
**Exploitation:** Attacker ships a crafted map file with an oversized name; when the victim lists maps via `maps *`, sprintf overflows the stack buffer and the attacker-controlled bytes overwrite the return address, redirecting execution to shellcode that spawns gnome-calculator (arbitrary code execution).
**Insight:** Map/resource filenames are attacker-controllable input that often flow into fixed-size buffers in legacy game engines; audit listing/formatting functions (sprintf on directory entries) rather than just network parsers.

