# [GoldSrc] RCE via 'spk' Console Command

Stack buffer overflow in GoldSrc VOX_GetDirectory via 'spk' console command lets an attacker run arbitrary code on a victim's client.

- Payout: $350
- Severity: high
- Program: Valve
- Found by: gamer7112
- Disclosed: 2020-08-19
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/769014
- Library page: https://bugbountylibrary.com/r/h1%3A769014
- 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 VOX sound loading (VOX_GetDirectory/VOX_LoadSound)
**Root cause:** VOX_GetDirectory memcpy's the sentence path into a 32-byte stack buffer szpath without length validation before VOX_LoadSound's later length check runs.
**Steps:**
1. Place crafted cfg in game root directory
2. Launch game and open console with `~`
3. Type `exec rce.cfg` and press enter
4. Overflow szpath via long sentence path in spk command, overwrite return address, calc pops
**How found:** Code review of VOX_LoadSound/VOX_GetDirectory revealed the memcpy into szpath[32] occurs before the strlen check on psz, indicating a missing length validation.
**Exploitation:** Attacker supplies a cfg invoking the spk console command with an overlong sentence path; VOX_GetDirectory copies it into szpath[32] on the stack, overwriting saved return address and achieving code execution on the client.
**Insight:** In VOX_LoadSound the length check on psz happens after VOX_GetDirectory already copied into szpath[32]; look for ordering bugs where validation follows a copy into a smaller fixed buffer.

