# Signedness issue in ClassInfo message handler leads to RCE on CS:GO client

Negative class_id in CSVCMsg_ClassInfo handler causes OOB write in CS:GO client, chained with cvar heap leak and ROP for RCE.

- Payout: $7,500
- Severity: critical
- Program: Valve
- Found by: teapotd
- Disclosed: 2021-05-27
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/876719
- Library page: https://bugbountylibrary.com/r/h1%3A876719
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:critical technique:chained technique:recon technique:source-review vuln:memory-corruption vuln:rce

**Target:** CS:GO client (csgo.exe) Source Engine Protobuf network message handler
**Root cause:** class_id is only checked for upper bound (>= nClasses) but not for negative values, so a negative int32 indexes pClasses out of bounds, giving an OOB write.
**Steps:**
1. Craft malicious server sending CSVCMsg_ClassInfo with negative class_id to trigger OOB write in ProcessClassInfo
2. Heap spray 500+ entities, delete last 20 to leave vtable pointers on heap
3. Set a cvar string to land after a stale vtable pointer, use OOB write to overwrite its null terminator, query cvar to leak vtable pointer and compute client_panorama.dll base
4. Deliver ROP chain via CCSUsrMsg_ShowMenu into global buffer at known address
5. Spray entities, use OOB write to overwrite an entity vtable pointer with fake vtable pointing to ROP chain
6. Queue `retry` command so client reconnects after sanity check; on disconnect entities deallocate and ROP chain runs calc.exe
**How found:** Code review of the Protobuf message handler revealed the class_id bounds check only tested the upper bound, missing negative values; the researcher then reasoned about heap layout predictability to turn the OOB write into a leak and control-flow hijack.
**Exploitation:** Attacker runs a malicious CS:GO server; victim connects (manually or via Steam browser protocol from a webpage). Two-phase exploit: first leaks client_panorama.dll base via cvar string null-terminator overwrite adjacent to stale entity vtable pointer, then overwrites an entity vtable with a fake vtable pointing to a ROP chain staged in the ShowMenu global buffer, triggering on entity deallocation after forced disconnect.
**Escalation:** Chained info leak (ASLR bypass) with OOB write to vtable hijack and ROP; delivered via Steam browser protocol for zero-click from web.
**Insight:** When auditing array indexing from network-controlled signed integers, check both bounds; and note that Source Engine's cvar string storage plus entity vtable pointers on the heap give a reliable leak primitive when you can corrupt a null terminator adjacent to a stale vtable.

