Malformed map detailed texture files in GoldSrc games lead to Remote Code Execution
A crafted map detail texture file causes a stack overflow in the game's rendering library when detailed textures are loaded. An attacker could use a malicious server to send the file to clients and trigger remote code execution on their machines.
Originally disclosed on HackerOne
- Triaged in 10 days
- Fixed in 49 days
- Paid in 49 days
- Disclosed after 6 months
A crafted map detailed texture file (maps/<map_name>_detail.txt) can be used to exploit a stack overflow vulnerability in hw.dll that can lead to remote code execution.
Reproduction
I used Counter-Strike for PoCs.
Using a listen server
- Place attached
cs_assault_detail.txtincstrike/mapsfolder - Start the game
- Open the console, type
r_detailtextures 1 - Host a new game on
cs_assault - The game crashes when trying to load detailed textures
Using a dedicated server
- Place attached
cs_assault_detail.txtincstrike/mapsfolder on the server - Write an AMXX plugin that does the following:
- Use
precache_genericto precachemaps/cs_assault_detail.txt - Use
client_cmdto force clients to executer_detailtextures 1 - Host a new server on
cs_assault - Open the client and connect to the server
- The client crashes when trying to load detailed textures
Note: precache_generic has some bug (https://github.com/ValveSoftware/halflife/issues/1551). The workaround is to setup sv_downloadurl for the server.
Exploitability
Since the file can be sent from the server using precache_generic, and the server has the ability to slowhack clients, attackers can use this to trigger RCE on clients.
Impact
Attackers can exploit this bug to execute arbitrary unauthorized codes on victim's computer.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code that parses the detail texture file copies its contents into a fixed-size stack buffer without checking the length.
Impact
Attackers could execute arbitrary code on a victim's computer, and a malicious server can deliver the file to connecting clients.
What the attacker needed
Victim connects to a malicious server; detailed textures enabled on client
How it was found
- Place the crafted detail texture file in the game's maps folder
- Start the game and enable detailed textures from the console
- Host a new game on the affected map
- The game crashes while loading detailed textures
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A game reads a small text file that describes how surfaces look. If that file contains far more data than the program reserved space for, it overflows a fixed-size memory area and can crash or let an attacker run their own code. Because a game server can push this file to players, a malicious server could attack anyone who connects.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.