# [Portal 2] Remote Code Execution via voice packets

Stack buffer overflow in Portal 2 voice packet handling lets a malicious client send oversized voice data to execute code on other players' machines.

- Payout: $5,000
- Severity: critical
- Program: Valve
- Found by: gamer7112
- Disclosed: 2021-05-10
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/733267
- Library page: https://bugbountylibrary.com/r/h1%3A733267
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:critical tech:windows technique:source-review vuln:memory-corruption vuln:rce

**Target:** Portal 2 game client CGameClient::ProcessVoiceData voice packet handler
**Root cause:** CLC_VoiceData m_nLength (in bits) is used to read into a fixed 4096-byte stack buffer without validating that Bits2Bytes(m_nLength) fits, allowing attacker-controlled length to overflow the stack.
**Steps:**
1. Victim invites attacker into a Portal 2 game and both load in.
2. Attacker injects a crafted DLL into their own Portal 2 process that sends a CLC_VoiceData packet with m_nLength exceeding 4096 bytes worth of bits.
3. Victim's client calls SV_BroadcastVoiceData with Bits2Bytes(msg->m_nLength) and voiceDataBuffer.
4. Victim's ProcessVoiceData reads oversized data into voiceDataBuffer[4096], overflowing the stack and hijacking control flow (calc.exe spawned).
**How found:** Code review of CGameClient::ProcessVoiceData revealed the missing length validation when reading into the stack buffer via ReadBits.
**Exploitation:** Attacker crafts a malicious voice packet with an oversized m_nLength, delivered through the normal in-game voice chat path; the victim's client overflows the stack buffer and executes attacker-supplied code, demonstrated by launching calc.exe.
**Insight:** Voice/chat data relayed between clients is attacker-controlled and often parsed with length fields in bits vs bytes; audit Bits2Bytes conversions against fixed stack buffers in multiplayer message handlers.

