# [Source Engine] Material path truncation leads to Remote Code Execution

mat_crosshair_edit truncates a 256-byte material path on Windows MAX_PATH 260, letting a crafted .js path execute via ShellExecute for RCE.

- Payout: $2,500
- Severity: high
- Program: Valve
- Found by: nyancat0131
- Disclosed: 2021-05-06
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/544096
- Library page: https://bugbountylibrary.com/r/h1%3A544096
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:high tech:windows technique:source-review vuln:path-traversal vuln:rce

**Target:** Source Engine mat_crosshair_edit console command / material path handling
**Root cause:** The mat_crosshair_edit handler passes a 256-byte buffer to ShellExecute("open", path); Windows MAX_PATH is 260, so the path is truncated and the extension can be swapped to an executable-associated type like .js.
**Steps:**
1. Place crafted map/material files under `cstrike\download\` (CS:Source at default path)
2. Start CS:Source, run `map aim_path`
3. Run `sv_cheats 1`
4. Run `mat_crosshair_edit`
5. calc.exe executes via Windows Script Host on the truncated .js path
**How found:** Noticed the 256-byte buffer vs Windows MAX_PATH 260 mismatch, hypothesized truncation could change the file extension, and chose .js because it is WSH-associated and bypasses the engine download filter.
**Exploitation:** Attacker supplies a material path whose truncation at 256 bytes yields a .js file (not blocked by Source download filter); when victim triggers mat_crosshair_edit, ShellExecute opens the .js and Windows Script Host runs arbitrary commands.
**Insight:** When a fixed-size buffer is just under a platform path limit (256 vs MAX_PATH 260), truncation can silently rewrite the extension; pick an extension the app's download filter allows but the OS executes.

