Skip to content
Memory corruption Disclosed report Advanced

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.

nyancat0131 Follow

Originally disclosed on HackerOne

Bounty$350 Medium View original
  • 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.txt in cstrike/maps folder
  • 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.txt in cstrike/maps folder on the server
  • Write an AMXX plugin that does the following:
  • Use precache_generic to precache maps/cs_assault_detail.txt
  • Use client_cmd to force clients to execute r_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.

The original report as published on HackerOne, by nyancat0131. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Place the crafted detail texture file in the game's maps folder
  2. Start the game and enable detailed textures from the console
  3. Host a new game on the affected map
  4. 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.

More by nyancat0131

View all

5 more disclosed reports, best first.

More from Valve

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.