Skip to content
RCE Write-up Advanced

Remote Code Execution in Source Games

A buffer overflow in the Source SDK's tokenizer allowed remote code execution when processing a crafted ragdoll model, triggered by fragging a player. An attacker could execute arbitrary code on clients and servers.

oneupsecurity.com

Published on oneupsecurity.com

Valve’s Source SDK contained a buffer overflow vulnerability, allowing remote code execution on clients and servers. The vulnerability was exploited by fragging a player, which caused a specially crafted ragdoll model to be loaded.

The author, on oneupsecurity.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The `nexttoken` function copies characters into a fixed-size buffer without checking the length, leading to a stack buffer overflow.

Impact

An attacker could execute arbitrary code on clients and servers running vulnerable Source games, potentially leading to botnets or targeted attacks.

What the attacker needed

Victim joins a game with the malicious map; attacker can craft and pack a model file; steamclient.dll lacks ASLR

The fix

The `nexttoken` function should accept a token length argument to perform bounds checking, and ASLR should be enabled for all executables.

How it was found

  1. Craft a ragdoll model file with a collisionpair rule longer than 256 characters.
  2. Pack the malicious model into a map file with the same resource path as an original model.
  3. When a player is fragged, the game loads the crafted model and processes the rule.
  4. The oversized token overflows the stack buffer, overwriting the return address.
  5. Use ROP gadgets from steamclient.dll (which lacks ASLR) to bypass mitigations and execute shellcode.
  6. The shellcode launches cmd.exe via LoadLibraryA and ShellExecuteA.

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 write-up has not been written yet. The Original tab links to the source.

A buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, overwriting nearby data. Here, a game function that reads model data copied a too-long string into a small stack buffer, letting an attacker control the program's execution flow. This could let someone run their own code on another player's computer or on a game server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.