Skip to content
Memory corruption Disclosed report Advanced

[CS:GO] Unchecked texture file name with TEXTUREFLAGS_DEPTHRENDERTARGET can lead to Remote Code Execution

A texture file with an overly long name and a specific flag set causes a stack buffer overflow in CS:GO, overwriting the return pointer. An attacker can host a malicious server with a custom map to execute arbitrary code on a victim's computer when they connect.

nyancat0131 Follow

Originally disclosed on HackerOne

Bounty$2,500 High 8.0 View original
  • Triaged in 22 days
  • Fixed in 2.0 years
  • Paid in 4 months
  • Disclosed after 2.0 years

Summary by the program

Title: [CS:GO] Unchecked texture file name with TEXTUREFLAGS_DEPTHRENDERTARGET can lead to Remote Code Execution Scope: csgo.exe Weakness: Stack Overflow Severity: High (8.0) Link: https://hackerone.com/reports/550625 Date: 2019-04-29 17:52:46 +0000 By: @nyancat0131

Details:

Summary

A texture with long file name and has TEXTUREFLAGS_DEPTHRENDERTARGET set can trigger a Stack Buffer Overflow, which leads to Arbitrary Code Execution due to return pointer (EIP) being overwritten.

Affects

Tested: CS:GO Potentially affected: All Valve's Source Engine games

Steps to reproduce

  • Download F478261, extract it to <csgo_install_dir>/csgo folder
  • Start CS:GO, attach WinDBG or any other debugger
  • Host a new game on map aim_pwn
  • Observe the crash with the attached debugger. The EIP will be overwritten to 0x61616161

NOTE: The path to CS:GO installation directory must not be too long, so that the accompanied texture file can be extracted successfully.

Attack scenario

This vulnerability can be exploited remotely because anyone can host a CS:GO server with custom maps. When the victim connects to a malicious server, the custom map will be downloaded along with its resources.

Impact

Attackers can execute arbitrary code on victim's computer. They can compromise victim's important data, accounts, ... and many things more.

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 game does not check the length of the texture file name before copying it into a fixed-size stack buffer when the TEXTUREFLAGS_DEPTHRENDERTARGET flag is set.

Impact

Attackers can execute arbitrary code on the victim's computer, potentially compromising important data and accounts.

What the attacker needed

Victim connects to a malicious server; server hosts a custom map with a malicious texture

How it was found

  1. Download the provided file and extract it to the csgo folder inside the CS:GO installation directory.
  2. Start CS:GO and attach a debugger such as WinDBG.
  3. Host a new game on the map aim_pwn.
  4. Observe the crash in the debugger, where the instruction pointer (EIP) is overwritten with 0x61616161.

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 texture is an image file used in games. When the game loads a texture with a very long name and a special setting, it writes more data than the space reserved on the stack (a small memory area), causing a stack buffer overflow. This lets an attacker overwrite the return address, which tells the program where to continue after a function, so they can run their own code.

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.