Exploring Counter-strike: Global Offensive Attack Surface
A relative heap out-of-bounds write in the MDL file parser of Counter-Strike: Global Offensive could be triggered remotely by a malicious server, potentially leading to remote code execution on the client. The bug was reported but never patched before the affected code was removed in Counter-Strike 2.
Published on synacktiv.com
Rédigé par Victor Cutillas, Louis Jacotot - 08/01/2024 - dans Exploit, Reverse-engineering - Téléchargement
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.
Context
Counter-Strike: Global Offensive (CS:GO) is built on Valve's Source Engine, a multiplayer 3D game engine first released in 2004 and also used by games such as Half-Life 2 and Team Fortress 2. The research described here targeted the remote attack surface of the game, with the client side as the focus because the server is authoritative and the client surface is considerably larger.
The attack surface is broad. Beyond game-specific network and message logic, it includes remote file downloads and parsers for additional content, voice codecs that the server broadcasts client-to-client, an in-game Chromium Embedded Framework browser used to display a message of the day popup from a server-controlled URL, the Remote Console (RCON) for server administration, Half-Life TV (HLTV) for spectating, and the Panorama UI framework, which leaves room for XSS.
Source Engine networking runs over UDP. Connectionless packets, used to retrieve information about a server or establish a connection, are raw datagrams with no additional layer. In-game data travels over a proprietary NetChannel layer that supports encryption, fragmentation and compression of reliable, ordered packets.
The work produced one remotely triggerable relative heap out-of-bounds write in code that is no longer present with the release of Counter-Strike 2. No patch was released in the meantime despite multiple follow-ups.
Setup
The research was carried out in 2021 during a six-month reverse-engineering internship, over approximately 25 days as a side project separate from the main internship subject. The lab consisted of a Windows client and a Linux server version 1305 [redacted] (July 21, 2021). The 2017 source code, available through public GitHub repositories, was retrieved and used for the audit, with parts of it compared against the compiled up-to-date version.
Fuzzing used AFL++ against file formats that can be loaded and transmitted from server to client: MDL and BSP, the proprietary formats that define 3D models and maps respectively. The harness was taken from a blogpost by niklasb about a RealWorldCTF 2018 challenge and slightly modified; it targets the Linux server implementation.
Finding it
Connectionless messages
The connectionless surface is simple to study. A loop in NET_ProcessSocket() polls and forwards incoming datagrams that start with a \xff\xff\xff\xff header to ProcessConnectionlessPacket(). A command number is then read and dispatched to a specific handler. The command groups are split by role, where A means any, S means server and C means client:
- Server implements
A2A,A2SandC2Scommand groups. - Client implements
A2A,S2A,S2Ccommand groups. - The special command
\0is used in the client implementation to transmit matchmaking messages in LAN networks as aOnNetLanConnectionlessPacketevent.

The report notes that the Steam server browser, which implements some Source Engine client commands, was vulnerable in 2018 to a stack-buffer overflow in the S2A_PLAYER handler.
Network channels
Netchannel traffic is encrypted with the ICE block cipher. On CS:GO community servers a fixed key is used, derived from the build version number with a simple algorithm:
N = int(BUILD.replace(b'.', b'')) # BUILD = b'[redacted]'
key = b'CSGO' + bytes([(N >> k) & 0xff for k in [0, 8, 16, 24, 2, 10, 18, 26, 4, 12, 20, 28]])
After decryption, packets are handled by CNetChan::ProcessPacket(), where the custom transport logic applies: duplicated or out-of-order packets are discarded and ACKs are sent. Packets flagged as reliable are then processed in a subchannel, with fragmentation and compression, in CNetChan::ReadSubChannelData(). In CNetChan::ProcessMessages() a message type is decoded using a 32-bit ZigZag algorithm and the payload is deserialised, with protobuf on CS:GO and as a bitstream on other Source Engine branches.
NET_MESSAGE messages are implemented on both client and server. Files sent and then parsed via subchannels account for a significant part of the attack surface: corrupted BSP maps and unrestricted VPK archive uploads have already been shown to lead to RCE.

On the server side, the SVC_MESSAGE category includes around 30 server-to-client messages and encapsulates other game features, which makes it a large surface:
- User messages: the
CSVCMsg_UserMessagesubcategory encapsulates another layer of protobuf-serialised payload and is used by CS:GO for game-specific logic such as votes. - Game events:
CSVCMsg_GameEventdispatchesKeyValuesevents. - Entities netcode: entity-specific events are transmitted with
CSVCMsg_EntityMsg, andCSVCMsg_PacketEntitiesencapsulates a bitstream-serialised payload to handle entities netcode.
Fuzzing results
After two nights of fuzzing, around a hundred unique crashes had been triggered. About 95% were out-of-bounds reads from unchecked offsets and did not look interesting. A few incorrect write crashes in datacache.so also occurred while parsing MDL files, and all of them were side effects of the same root cause. The vulnerable code sits in datacache/mdlcache.cpp, at the entrypoint of MDL file parsing:
//-----------------------------------------------------------------------------
// Attempts to load a MDL file, validates that it's ok.
//-----------------------------------------------------------------------------
bool CMDLCache::ReadMDLFile( MDLHandle_t handle, const char *pMDLFileName, CMDLCacheData &cacheData ){
bool bOk = cacheData.ReadFileNative( pFileName, "GAME" );
// [...]
studiohdr_t *pStudioHdr = (studiohdr_t*)cacheData.Data();
// [...]
if ( pStudioHdr->studiohdr2index == 0 )
{
DevWarning( "Model %s doesn't have a studiohdr2, which should've been fixed. This is required of all models now.\n", pMDLFileName );
return false;
}
// critical! store a back link to our data
// this is fetched when re-establishing dependent cached data (vtx/vvd)
pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );
// [...]
}
The studiohdr_t structure is defined in public/studio.h:
struct studiohdr_t
{
int id;
int version;
// [...]
int studiohdr2index;
studiohdr2_t* pStudioHdr2() const
{
return (studiohdr2_t *)( ( (byte *)this ) + studiohdr2index );
}
// [...]
void SetVirtualModel( void* ptr )
{
Assert( studiohdr2index );
if ( studiohdr2index ) { pStudioHdr2()->virtualModel = ptr; }
}
}
And the conversion function is defined in public/datacache/imdlcache.h:
typedef unsigned short MDLHandle_t;
// [...]
inline void* MDLHandleToVirtual( MDLHandle_t hndl )
{
return (void*)(uintp)hndl;
}
pStudioHdr->studiohdr2index is read directly from the MDL file and used to write a value with no bound checking. That makes it a relative heap out-of-bounds write. The MDLHandle_t parameter is zero-extended to void * before being written, so the two most significant bytes are null because of the unsigned short to pointer expansion. The two least significant bytes depend on the context of the CMDLCache, since the value is linked to the number of previously cached MDL objects, which the attacker does not know.
Exploitation
Step 1: crash with a minimal payload
Building a proof of concept is straightforward: setting studiohdr2index to a huge offset will most likely access unmapped memory. The following hexadecimal dump is a minimal payload file with the index set to 0x1ffff00d, which usually crashes during the call to studiohdr_t::SetVirtualModel():
00000000 49 44 53 54 00 00 00 00 00 00 00 00 00 00 00 00 |IDST............|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000190 0d f0 ff 1f 00 00 00 00 |........|
00000198
Reproduction uses three steps:
- Copy the payload file to
C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models\payload.mdl. - Open the console during an offline game and enable flag
sv_cheats 1. - Load the model with command
prop_dynamic_create payload.
The root cause can be confirmed by setting a breakpoint on the inlined studiohdr_t::SetVirtualModel() call: the ECX register contains the offset stored in the file, and EAX represents the identifier of the virtual model being loaded.

Because the primitive was limited and the research had just started, the authors looked for other memory corruption primitives and moved to manual source review.
Step 2: source code audit
The 2017 source code is still available through public GitHub repositories but has been updated since; it was used for the audit and compared in places with the compiled up-to-date version. The codebase is old-school C++ and C, and some dangerous patterns stand out.
There are many uses of signed int wherever a size is represented. This carries incorrect semantics and can lead to bugs where a developer does not consider that a size variable may be negative, for example when checking an out-of-bound index. Very little bound checking is done, which has caused many bugs, including an RCE when handling CSVCMsg_SplitScreen messages. Many C-style functions are called to manipulate strings and copy memory. Reading the source turned up 13 out-of-bounds bugs, and some fixes are shallow: bound checks are sometimes placed inside the callers of functions that fetch data rather than in the getters themselves. That is dangerous because forgetting a single call path leaves the vulnerability reachable, although this was not observed in the actual fixes.
The audit also identified two stack-buffer overflows with controlled size and data in the pre-authentication connectionless messages feature. The S2C_CHALLENGE handler reads two sizes from the received message at [1] and [2], then copies the corresponding number of bytes into local stack variables at [3] and [4]:
bool CBaseClientState::ProcessConnectionlessPacket(netpacket_t *packet)
{
/* [...] */
bf_read &msg = packet->message;
/* [...] */
int c = msg.ReadByte();
switch (c) { /* [...] */
case S2C_CHALLENGE: /* [...] */
byte chKeyPub[1024] = {};
byte chKeySgn[1024] = {};
int cbKeyPub = msg.ReadLong(); /* [[1]] */
msg.ReadBytes(chKeyPub, cbKeyPub); /* [[3]] */
int cbKeySgn = msg.ReadLong(); /* [[2]] */
msg.ReadBytes(chKeySgn, cbKeySgn); /* [[4]] */
/* [...] */
}
}
After reverse-engineering the corresponding up-to-date binary, these simple vulnerabilities turned out to be already fixed. The source review did not produce an interesting vulnerability, but it did reveal the exploitation primitives described below.
Step 3: triggering the model parsing bug remotely
To trigger the bug on a client connecting to a malicious server, the server must force the client to load a custom MDL file. While the client loads the current map during connection, the server transmits a string table called downloadables describing the resources required to play. The client downloads missing resources from the server using CNETMsg_File requests only if the configuration directive sv_allowupload is enabled. Since February 2018 the CS:GO client disables this option by default, but community servers usually require clients to enable it in order to load custom maps.
One way to load the model remotely is to create an entity that refers to the malicious model and render it to the client at any moment, but creating an entity is tedious. A simpler route came from reading the client code that handles the downloadables string table.
The server can enforce client consistency checks on downloaded files through the network-transmitted boolean sv_consistency. The checks are implemented in CClientState::ConsistencyCheck(), called when the sign-on state reaches SIGNONSTATE_NEW. The method iterates over the transmitted filenames and performs either CRC or model size checks depending on server-transmitted metadata: files tagged CONSISTENCY_EXACT have their CRC checked, while files tagged CONSISTENCY_BOUNDS are loaded as models to perform size checks. A consistency check error disconnects the client from the server.
The proof of concept instruments the Linux server with Frida: the method CDownloadListGenerator::SetStringTable() is hooked to alter the downloadables string table by adding a malicious model tagged CONSISTENCY_BOUNDS, which triggers the vulnerability remotely. On connection, the client loads the server resources and crashes before the loading screen ends.
Step 4: assessing exploitability
Months later the authors revisited the only bug that looked viable for exploitation, spending one week on it. The aim was not a working exploit but an estimate of how much time remote code execution on the CS:GO Windows client would need.
Every PE and DLL shipped with the Windows client has basic mitigations:
- ASLR enabled (
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) - DEP enabled (
IMAGE_DLLCHARACTERISTICS_NX_COMPAT) - No stack smashing protection
With only a relative heap out-of-bounds write, several steps are needed to gain control over the client's memory:
- Find a reliable heap massaging technique to place an interesting object next to the
studiohdr_t. - Gain a relative memory leak primitive by partially overwriting a size or pointer to bypass ASLR.
- Get an arbitrary memory read primitive, preferably without massaging again, to maximise reliability.
- Abuse the bug again to get a write-what-where primitive.
- Gain remote code execution.
The heap is heavily used by complex components on the default Windows 10 allocator: CS:GO embeds the V8 JavaScript engine, a shader compiler and the Valve GUI framework, all of which manipulate the main heap state. Getting a state deterministic enough to reliably place interesting objects next to the studiohdr_t does not look easy.
The resulting attack scenario is:
- A client with
sv_allowupload 1connects to an attacker-controlled server. - During resource loading, the server enforces a bounds check for a custom MDL.
- The client downloads the custom MDL from the server.
- The client loads it to check against the previously given server bounds.
- The bug is triggered, corrupting client memory and handing full control of the client computer to the server.
Step 5: heap spraying with player avatars
The server can authoritatively update a player avatar by sending a CNETMsg_PlayerAvatarData message, defined in common/netmessages.proto:
message CNETMsg_PlayerAvatarData
{ // 12 KB player avatar 64x64 rgb only no alpha
// WARNING-WARNING-WARNING
// This message is extremely large for our net channels
// and must be pumped through special fragmented waiting list
// via chunk-based ack mechanism!
// See: INetChannel::EnqueueVeryLargeAsyncTransfer
// WARNING-WARNING-WARNING
optional uint32 accountid = 1;
optional bytes rgb = 2;
}
The rgb field is typed as bytes, so an arbitrary number of bytes can be sent. The client handler is:
// engine/baseclientstate.cpp
bool CBaseClientState::NETMsg_PlayerAvatarData( const CNETMsg_PlayerAvatarData& msg )
{
PlayerAvatarDataMap_t::IndexType_t idxData = m_mapPlayerAvatarData.Find( msg.accountid() );
if ( idxData != m_mapPlayerAvatarData.InvalidIndex() )
{
delete m_mapPlayerAvatarData.Element( idxData );
m_mapPlayerAvatarData.RemoveAt( idxData );
}
CNETMsg_PlayerAvatarData_t *pClientDataCopy = new CNETMsg_PlayerAvatarData_t;
pClientDataCopy->CopyFrom( msg );
m_mapPlayerAvatarData.Insert( pClientDataCopy->accountid(), pClientDataCopy );
return true;
}
The handler deletes an existing avatar for the account if present, then allocates a new copy and inserts it into a map. Any account ID is accepted, allocations are persistent and the size is attacker-controlled, which makes this a powerful heap spraying primitive.
Step 6: writing to a fixed memory location
A reliable exploit benefits from writing arbitrary data to a fixed location, such as a variable in the .data section of a loaded executable or library. The server can do this through the CCSUsrMsg_ShowMenu message. The client handler is CHudMenu::MsgFunc_ShowMenu():
// game/client/menu.cpp
bool CHudMenu::MsgFunc_ShowMenu( const CCSUsrMsg_ShowMenu &msg)
{
// [...]
if ( m_bitsValidSlots )
{
Q_strncpy( g_szPrelocalisedMenuString, msg.menu_string().c_str(), sizeof( g_szPrelocalisedMenuString ) );
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
m_nSelectedItem = -1;
// we have the whole string, so we can localise it now
char szMenuString[MAX_MENU_STRING];
Q_strncpy( szMenuString, ConvertCRtoNL( hudtextmessage->BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ), sizeof( szMenuString ) );
g_pVGuiLocalize->ConvertANSIToUnicode( szMenuString, g_szMenuString, sizeof( g_szMenuString ) );
// [...]
}
else
{
HideMenu();
}
return true;
}
The global g_szPrelocalisedMenuString is a char[512] string defined in game/client/menu.cpp. Although the code treats it as a null-terminated string, writing it multiple times lets the server craft arbitrary data in a section of engine.dll.
Root cause
The bug is a missing bound check on studiohdr2index, a value read straight from the attacker-supplied MDL file. SetVirtualModel() computes pStudioHdr2() as this + studiohdr2index and writes the handle-derived pointer to virtualModel at that address, so any offset in the file becomes a write offset relative to the heap object. The written value is limited: the MDLHandle_t is an unsigned short zero-extended to a pointer, so the top two bytes are null and the low two bytes depend on cache state the attacker does not control.
Existing mitigations did not stop the write itself. ASLR and DEP are enabled on the shipped binaries, but the primitive is a write, not a control-flow hijack, and there is no stack smashing protection.
Impact
A malicious server can crash a connecting client before the loading screen ends, and the authors believe a motivated attacker could achieve remote code execution, which would hand full control of the client computer to the server. Exploitation depends on the client having sv_allowupload 1 enabled, which the report describes as widespread among CS:GO players who play on community servers. The bug affects the Windows client; the impacted code is no longer present with the release of Counter-Strike 2, and no patch was released in the meantime despite multiple follow-ups.
The bug was reported to Valve through its HackerOne managed program. The ticket was closed with the release of Counter-Strike 2, and the timeline records a $750 reward on 2023.04.25.
Fix
No fix was shipped for CS:GO: the report states that no patch was released despite multiple follow-ups, and the code was removed with Counter-Strike 2.
Variants to test
- Other MDL fields used as offsets. Look for fields read from the file and added to a base pointer before a write. A positive result is a crash whose faulting address tracks a value you control in the file.
- Other server-driven file loads. Check paths where the server names a resource the client must load, such as consistency checks and the
downloadablestable. A positive result is a client-side parse of an attacker-supplied file without user interaction. - Other
S2Cconnectionless handlers. Compare length fields read from the datagram with the destination buffer size, as in theS2C_CHALLENGEexample. A positive result is a stack overflow reachable before authentication. - Other
bytesfields in protobuf messages. Test whether the client copies them into persistent allocations with attacker-chosen size, as withCNETMsg_PlayerAvatarData. A positive result is repeated, size-controlled allocations that survive between messages. - Other writes into fixed globals. Look for handlers that copy message strings into global buffers, as with
g_szPrelocalisedMenuString. A positive result is attacker data landing at a predictable address in a loaded module.
What happened, in plain words
In 2021, two researchers spent about 25 days, as a side project during a six-month reverse-engineering internship, looking for security bugs in the online game Counter-Strike: Global Offensive (CS:GO). They found a bug that a malicious game server could use to crash a player's game, and they believe a determined attacker could go further and take control of the player's computer. They reported it to Valve, the company that makes the game, and eventually received a $750 reward. No patch was ever released for CS:GO; the affected code disappeared when the successor game, Counter-Strike 2, came out.
This article walks through the whole story in the same order as the researchers told it: how the game talks over the network, how they found the bug, how they proved it could be triggered remotely, and what building blocks an attacker would need to turn it into full control of a machine. Every concept is explained from scratch, so you only need to know how to use a computer and a browser.
Background: what the game is and why its network matters
CS:GO is a multiplayer shooter built on Valve's Source Engine, a 3D game engine first released in 2004 and also used by games such as Half-Life 2 and Team Fortress 2. An engine is the shared software foundation a game is built on: graphics, sound, physics and, importantly here, networking.
When you play online, your computer (the client) connects to a server, a computer that runs the match. In Source Engine games the server is authoritative: it decides what is true in the game world, and the client follows. That is why the researchers focused on the client side. The client has to accept and process a lot of data coming from the server, and that incoming data is a large attack surface, meaning all the places where an attacker could send something the program will read and act on.
The attack surface of CS:GO is broad. Besides the game's own network messages, it includes:
- remote file downloads and the parsers that read extra content;
- voice codecs, which the server broadcasts from one client to another;
- an in-game web browser (Chromium Embedded Framework) used to show a "message of the day" popup loaded from a server-controlled URL;
- the Remote Console (RCON) used to administer servers;
- Half-Life TV (HLTV) for watching matches;
- the Panorama UI framework, which leaves room for cross-site scripting (XSS), a class of bug where an attacker gets their own code to run inside a page or interface.
A parser is a piece of software that reads a file or message and turns its raw bytes into meaningful data. Parsers are classic bug territory because they must trust the structure of what they read, and an attacker can craft a file that breaks the rules.
Source Engine networking runs over UDP, one of the basic protocols computers use to send data across a network. UDP is like sending postcards: each one travels on its own, with no built-in guarantee of order or delivery. Two kinds of traffic exist here:
- Connectionless packets, used to ask a server for information or to start a connection. These are raw datagrams with no extra layer.
- In-game data, which travels over a proprietary layer called
NetChannelthat supports encryption, fragmentation (splitting big messages into pieces) and compression, and that keeps reliable, ordered packets.
The research produced one remotely triggerable relative heap out-of-bounds write. Breaking that down:
- A heap is the region of memory a program uses for data it creates while running, as opposed to fixed structures decided when the program was compiled.
- An out-of-bounds write means the program writes data past the end of the area it was supposed to write to, landing in memory that belongs to something else.
- Relative means the wrong destination is calculated as "the start of my data plus some offset", where the offset comes from the attacker's file.
Setting up the lab
The work happened in 2021. The lab had a Windows client and a Linux server running version 1305 [redacted] (July 21, 2021). The researchers also downloaded the 2017 source code of the game, which is publicly available through GitHub repositories, and compared parts of it against the compiled, up-to-date version. Source code is the human-readable text a program is written in; the compiled version is the machine code that actually runs. Having the old source is useful for understanding the logic, but you must check the live binary because the code has changed since.
To find bugs automatically they used fuzzing, a technique where a program (a fuzzer) feeds thousands of slightly mutated inputs to a target and watches for crashes. They used a fuzzer called AFL++ against two file formats that a server can send to a client:
- MDL, the proprietary format that defines 3D models;
- BSP, the proprietary format that defines maps.
The harness is the small wrapper program that hands inputs to the code under test. Theirs was taken from a blogpost by niklasb about a RealWorldCTF 2018 challenge and slightly modified; it targets the Linux server implementation.
Finding it
Connectionless messages
The connectionless part of the protocol is simple, which makes it pleasant to study. A loop in a function called NET_ProcessSocket() polls incoming datagrams and forwards any that start with a \xff\xff\xff\xff header to ProcessConnectionlessPacket(). That header is simply a marker: four bytes of value 255 that say "this is a connectionless packet". A command number is then read and sent to the matching handler.
Commands are grouped by who may send and receive them, where A means any, S means server and C means client:
- Server implements
A2A,A2SandC2Scommand groups. - Client implements
A2A,S2A,S2Ccommand groups. - The special command
\0is used in the client implementation to transmit matchmaking messages in LAN networks as aOnNetLanConnectionlessPacketevent.

The report notes that the Steam server browser, which implements some Source Engine client commands, was vulnerable in 2018 to a stack-buffer overflow in the S2A_PLAYER handler. A stack-buffer overflow is the same idea as an out-of-bounds write but on the stack, the small, fast memory area a program uses for the variables of the function it is currently running.
Network channels
Netchannel traffic is encrypted with the ICE block cipher. A cipher is a mathematical recipe for scrambling data so that only someone with the right key can unscramble it. On CS:GO community servers a fixed key is used, derived from the build version number with a simple algorithm:
N = int(BUILD.replace(b'.', b'')) # BUILD = b'[redacted]'
key = b'CSGO' + bytes([(N >> k) & 0xff for k in [0, 8, 16, 24, 2, 10, 18, 26, 4, 12, 20, 28]])
Line by line:
N = int(BUILD.replace(b'.', b''))takes the build string, removes the dots, and turns the result into a number. WithBUILD = b'[redacted]'you get13796.key = b'CSGO' + ...builds the key by starting with the four literal charactersCSGOand appending twelve bytes.- The list
[0, 8, 16, 24, 2, 10, 18, 26, 4, 12, 20, 28]lists bit positions. For each positionk,(N >> k) & 0xffshifts the number right bykbits and keeps the lowest eight bits, which is one byte of the number. The result is a fixed, predictable key.
A fixed key means anyone who knows the algorithm and the version number can decrypt the traffic.
After decryption, packets are handled by CNetChan::ProcessPacket(), where the custom transport logic applies: duplicated or out-of-order packets are discarded and acknowledgements (ACKs, short "I got it" replies) are sent. Packets flagged as reliable are then processed in a subchannel, with fragmentation and compression, in CNetChan::ReadSubChannelData(). In CNetChan::ProcessMessages() a message type is decoded using a 32-bit ZigZag algorithm and the payload is deserialised. Deserialisation is turning a stream of bytes back into structured data. On CS:GO this uses protobuf, a format for encoding structured messages; on other Source Engine branches it is a raw bitstream.
NET_MESSAGE messages are implemented on both client and server. Files sent and then parsed via subchannels account for a significant part of the attack surface: corrupted BSP maps and unrestricted VPK archive uploads have already been shown to lead to RCE, remote code execution, meaning an attacker gets their own code running on the victim's machine.

On the server side, the SVC_MESSAGE category includes around 30 server-to-client messages and encapsulates other game features, which makes it a large surface:
- User messages: the
CSVCMsg_UserMessagesubcategory encapsulates another layer of protobuf-serialised payload and is used by CS:GO for game-specific logic such as votes. - Game events:
CSVCMsg_GameEventdispatchesKeyValuesevents. - Entities netcode: entity-specific events are transmitted with
CSVCMsg_EntityMsg, andCSVCMsg_PacketEntitiesencapsulates a bitstream-serialised payload to handle entities netcode. An entity is any object in the game world, such as a player or an item.
Fuzzing results
After two nights of fuzzing, around a hundred unique crashes had been triggered. About 95% were out-of-bounds reads from unchecked offsets and did not look interesting. A read is much less useful to an attacker than a write: reading the wrong memory may crash the program, but it does not let you change anything. A few incorrect write crashes in datacache.so also occurred while parsing MDL files, and all of them were side effects of the same root cause. The vulnerable code sits in datacache/mdlcache.cpp, at the entrypoint of MDL file parsing:
//-----------------------------------------------------------------------------
// Attempts to load a MDL file, validates that it's ok.
//-----------------------------------------------------------------------------
bool CMDLCache::ReadMDLFile( MDLHandle_t handle, const char *pMDLFileName, CMDLCacheData &cacheData ){
bool bOk = cacheData.ReadFileNative( pFileName, "GAME" );
// [...]
studiohdr_t *pStudioHdr = (studiohdr_t*)cacheData.Data();
// [...]
if ( pStudioHdr->studiohdr2index == 0 )
{
DevWarning( "Model %s doesn't have a studiohdr2, which should've been fixed. This is required of all models now.\n", pMDLFileName );
return false;
}
// critical! store a back link to our data
// this is fetched when re-establishing dependent cached data (vtx/vvd)
pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );
// [...]
}
Line by line:
- The function
ReadMDLFileis called when the game wants to load an MDL model file. It receives a handle (an identifier for the cached model), the file name, and a cache object. cacheData.ReadFileNative( pFileName, "GAME" )reads the file from disk into memory.studiohdr_t *pStudioHdr = (studiohdr_t*)cacheData.Data();treats the start of that memory as astudiohdr_tstructure, the header of a model file. The cast tells the compiler to interpret the raw bytes that way.- The
ifchecks whether the fieldstudiohdr2indexis zero. If it is, the function prints a warning and returnsfalse, refusing the file. pStudioHdr->SetVirtualModel( MDLHandleToVirtual( handle ) );is the important line. It stores a back link to the cached data, which is needed later when related files (vtx/vvd) are re-established. The comment calls it "critical".
The studiohdr_t structure is defined in public/studio.h:
struct studiohdr_t
{
int id;
int version;
// [...]
int studiohdr2index;
studiohdr2_t* pStudioHdr2() const
{
return (studiohdr2_t *)( ( (byte *)this ) + studiohdr2index );
}
// [...]
void SetVirtualModel( void* ptr )
{
Assert( studiohdr2index );
if ( studiohdr2index ) { pStudioHdr2()->virtualModel = ptr; }
}
}
Line by line:
struct studiohdr_tdescribes the layout of the model header: anid, aversion, and laterstudiohdr2index, an integer read straight from the file.pStudioHdr2()computes an address by taking the address of the current structure (this), converting it to a byte pointer, and addingstudiohdr2index. In plain terms: "start where I am and jump forward by the number stored in the file".SetVirtualModel( void* ptr )checks thatstudiohdr2indexis not zero, then writesptrinto thevirtualModelfield of the structure found at that computed address.
And the conversion function is defined in public/datacache/imdlcache.h:
typedef unsigned short MDLHandle_t;
// [...]
inline void* MDLHandleToVirtual( MDLHandle_t hndl )
{
return (void*)(uintp)hndl;
}
Line by line:
typedef unsigned short MDLHandle_t;says a model handle is an unsigned short, a number that can hold values from 0 to 65535 (two bytes).MDLHandleToVirtualtakes that handle and converts it to a pointer, a memory address. Because the handle is only two bytes, the resulting address has its top two bytes set to zero and its low two bytes equal to the handle.
pStudioHdr->studiohdr2index is read directly from the MDL file and used to write a value with no bound checking. That makes it a relative heap out-of-bounds write. The MDLHandle_t parameter is zero-extended to void * before being written, so the two most significant bytes are null because of the unsigned short to pointer expansion. The two least significant bytes depend on the context of the CMDLCache, since the value is linked to the number of previously cached MDL objects, which the attacker does not know. In everyday terms: the attacker controls where the write lands (the offset from the file) but only partly controls what is written (a small number whose exact value depends on how many models the game has already loaded).
Exploitation
Step 1: crash with a minimal payload
Building a proof of concept is straightforward: setting studiohdr2index to a huge offset will most likely access unmapped memory. Unmapped memory is an address the program has no right to touch; the operating system stops it and the program crashes. The following hexadecimal dump is a minimal payload file with the index set to 0x1ffff00d, which usually crashes during the call to studiohdr_t::SetVirtualModel():
00000000 49 44 53 54 00 00 00 00 00 00 00 00 00 00 00 00 |IDST............|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000190 0d f0 ff 1f 00 00 00 00 |........|
00000198
This is a hex dump: each line shows a memory offset on the left, the bytes in hexadecimal in the middle, and the printable characters on the right. The first four bytes 49 44 53 54 spell IDST, the magic marker of an MDL file. The * means a run of identical lines is skipped. At offset 0x190 the bytes 0d f0 ff 1f are the little-endian encoding of 0x1ffff00d, the huge studiohdr2index value. When the game adds that offset to the start of the structure, it lands far outside the allocated memory and crashes.
Reproduction uses three steps:
- Copy the payload file to
C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models\payload.mdl. - Open the console during an offline game and enable flag
sv_cheats 1. - Load the model with command
prop_dynamic_create payload.
Step 1 places the crafted file where the game looks for models. Step 2 enables the developer console and the cheat flag, which is needed to run the model-loading command. Step 3 asks the game to create a visible object using the model, which makes the game parse the file and hit the bug.
The root cause can be confirmed by setting a breakpoint on the inlined studiohdr_t::SetVirtualModel() call: the ECX register contains the offset stored in the file, and EAX represents the identifier of the virtual model being loaded. A breakpoint is a marker that tells a debugger (a tool for inspecting a running program) to pause execution at a chosen line. Registers are small storage slots inside the processor; ECX and EAX are two of them on 32-bit x86 processors.

Seeing the attacker-controlled offset in the register confirms the write is going where the file says.
Because the primitive was limited and the research had just started, the authors looked for other memory corruption primitives and moved to manual source review. A primitive here means a small, reliable capability an attacker can build on, such as "write a controlled value to a controlled address".
Step 2: source code audit
The 2017 source code is still available through public GitHub repositories but has been updated since; it was used for the audit and compared in places with the compiled up-to-date version. The codebase is old-school C++ and C, and some dangerous patterns stand out.
There are many uses of signed int wherever a size is represented. A signed integer can be negative, while a size should never be. This carries incorrect semantics and can lead to bugs where a developer does not consider that a size variable may be negative, for example when checking an out-of-bound index. Very little bound checking is done, which has caused many bugs, including an RCE when handling CSVCMsg_SplitScreen messages. Many C-style functions are called to manipulate strings and copy memory. Reading the source turned up 13 out-of-bounds bugs, and some fixes are shallow: bound checks are sometimes placed inside the callers of functions that fetch data rather than in the getters themselves. That is dangerous because forgetting a single call path leaves the vulnerability reachable, although this was not observed in the actual fixes.
The audit also identified two stack-buffer overflows with controlled size and data in the pre-authentication connectionless messages feature. Pre-authentication means the bug can be reached before the client has logged in or proven who it is, which makes it more serious. The S2C_CHALLENGE handler reads two sizes from the received message at [1] and [2], then copies the corresponding number of bytes into local stack variables at [3] and [4]:
bool CBaseClientState::ProcessConnectionlessPacket(netpacket_t *packet)
{
/* [...] */
bf_read &msg = packet->message;
/* [...] */
int c = msg.ReadByte();
switch (c) { /* [...] */
case S2C_CHALLENGE: /* [...] */
byte chKeyPub[1024] = {};
byte chKeySgn[1024] = {};
int cbKeyPub = msg.ReadLong(); /* [[1]] */
msg.ReadBytes(chKeyPub, cbKeyPub); /* [[3]] */
int cbKeySgn = msg.ReadLong(); /* [[2]] */
msg.ReadBytes(chKeySgn, cbKeySgn); /* [[4]] */
/* [...] */
}
}
Line by line:
ProcessConnectionlessPacketreceives a packet and gets a reader over its bytes.int c = msg.ReadByte();reads one byte, the command number, and theswitchpicks the handler.- In the
S2C_CHALLENGEcase, two local arrays of 1024 bytes are created on the stack:chKeyPubandchKeySgn. int cbKeyPub = msg.ReadLong();reads a four-byte length from the message at[1].msg.ReadBytes(chKeyPub, cbKeyPub);copies that many bytes into the 1024-byte array at[3]. If the length is larger than 1024, the copy overflows the array.- The same pattern repeats for
cbKeySgnandchKeySgnat[2]and[4].
After reverse-engineering the corresponding up-to-date binary, these simple vulnerabilities turned out to be already fixed. Reverse-engineering here means taking the compiled program and working backwards to understand what it does. The source review did not produce an interesting vulnerability, but it did reveal the exploitation primitives described below.
Step 3: triggering the model parsing bug remotely
To trigger the bug on a client connecting to a malicious server, the server must force the client to load a custom MDL file. While the client loads the current map during connection, the server transmits a string table called downloadables, a list of names describing the resources required to play. The client downloads missing resources from the server using CNETMsg_File requests only if the configuration directive sv_allowupload is enabled. A configuration directive (or console variable) is a setting that controls the game's behaviour. Since February 2018 the CS:GO client disables this option by default, but community servers usually require clients to enable it in order to load custom maps.
One way to load the model remotely is to create an entity that refers to the malicious model and render it to the client at any moment, but creating an entity is tedious. A simpler route came from reading the client code that handles the downloadables string table.
The server can enforce client consistency checks on downloaded files through the network-transmitted boolean sv_consistency. A boolean is a true/false value. Consistency checks exist so that all players see the same files; the server can ask the client to verify that its copy of a file matches. The checks are implemented in CClientState::ConsistencyCheck(), called when the sign-on state reaches SIGNONSTATE_NEW. The method iterates over the transmitted filenames and performs either a CRC check or a model size check depending on server-transmitted metadata. A CRC is a checksum, a short number computed from a file's contents so that any change is detectable. Files tagged CONSISTENCY_EXACT have their CRC checked, while files tagged CONSISTENCY_BOUNDS are loaded as models to perform size checks. A consistency check error disconnects the client from the server.
The proof of concept instruments the Linux server with Frida, a tool that lets you inject code into a running program to observe or change its behaviour. The method CDownloadListGenerator::SetStringTable() is hooked (intercepted and replaced) to alter the downloadables string table by adding a malicious model tagged CONSISTENCY_BOUNDS, which triggers the vulnerability remotely. On connection, the client loads the server resources and crashes before the loading screen ends. The trick is that the client loads the model itself, as part of a routine consistency check, so the attacker does not need to create any game entity.
Step 4: assessing exploitability
Months later the authors revisited the only bug that looked viable for exploitation, spending one week on it. The aim was not a working exploit but an estimate of how much time remote code execution on the CS:GO Windows client would need.
Every PE and DLL shipped with the Windows client has basic mitigations. A PE (Portable Executable) is the standard file format for Windows programs, and a DLL is a shared library that programs load at runtime. The mitigations are:
- ASLR enabled (
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE). Address Space Layout Randomisation means the program's parts are placed at random addresses each time it starts, so an attacker cannot hard-code where things are. - DEP enabled (
IMAGE_DLLCHARACTERISTICS_NX_COMPAT). Data Execution Prevention means memory holding data cannot be executed as code, which blocks a common attack trick. - No stack smashing protection, a compiler feature that detects some stack overflows at runtime.
With only a relative heap out-of-bounds write, several steps are needed to gain control over the client's memory:
- Find a reliable heap massaging technique to place an interesting object next to the
studiohdr_t. Heap massaging (or heap spraying) means arranging allocations so that a chosen object ends up at a predictable place relative to the bug. - Gain a relative memory leak primitive by partially overwriting a size or pointer to bypass ASLR. A leak means getting the program to reveal a memory address, which defeats ASLR because the attacker then knows where things are.
- Get an arbitrary memory read primitive, preferably without massaging again, to maximise reliability.
- Abuse the bug again to get a write-what-where primitive, meaning the ability to write a chosen value to a chosen address.
- Gain remote code execution.
The heap is heavily used by complex components on the default Windows 10 allocator: CS:GO embeds the V8 JavaScript engine, a shader compiler and the Valve GUI framework, all of which manipulate the main heap state. Getting a state deterministic enough to reliably place interesting objects next to the studiohdr_t does not look easy. Deterministic means the same setup produces the same result every time, which an exploit needs to be reliable.
The resulting attack scenario is:
- A client with
sv_allowupload 1connects to an attacker-controlled server. - During resource loading, the server enforces a bounds check for a custom MDL.
- The client downloads the custom MDL from the server.
- The client loads it to check against the previously given server bounds.
- The bug is triggered, corrupting client memory and handing full control of the client computer to the server.
Step 5: heap spraying with player avatars
The server can authoritatively update a player avatar by sending a CNETMsg_PlayerAvatarData message, defined in common/netmessages.proto:
message CNETMsg_PlayerAvatarData
{ // 12 KB player avatar 64x64 rgb only no alpha
// WARNING-WARNING-WARNING
// This message is extremely large for our net channels
// and must be pumped through special fragmented waiting list
// via chunk-based ack mechanism!
// See: INetChannel::EnqueueVeryLargeAsyncTransfer
// WARNING-WARNING-WARNING
optional uint32 accountid = 1;
optional bytes rgb = 2;
}
Line by line:
message CNETMsg_PlayerAvatarDatadeclares a protobuf message, a structured packet with named fields.- The comments explain that this is meant to carry a 12 KB avatar image, 64 by 64 pixels, RGB only with no alpha (transparency), and that it is extremely large for the network channels, so it must go through a special fragmented waiting list using a chunk-based acknowledgement mechanism.
optional uint32 accountid = 1;is the account identifier, a 32-bit unsigned number.optionalmeans it may be absent.optional bytes rgb = 2;is the image data as a raw byte string. Because it is typed asbytes, its length is not fixed by the format.
The rgb field is typed as bytes, so an arbitrary number of bytes can be sent. The client handler is:
// engine/baseclientstate.cpp
bool CBaseClientState::NETMsg_PlayerAvatarData( const CNETMsg_PlayerAvatarData& msg )
{
PlayerAvatarDataMap_t::IndexType_t idxData = m_mapPlayerAvatarData.Find( msg.accountid() );
if ( idxData != m_mapPlayerAvatarData.InvalidIndex() )
{
delete m_mapPlayerAvatarData.Element( idxData );
m_mapPlayerAvatarData.RemoveAt( idxData );
}
CNETMsg_PlayerAvatarData_t *pClientDataCopy = new CNETMsg_PlayerAvatarData_t;
pClientDataCopy->CopyFrom( msg );
m_mapPlayerAvatarData.Insert( pClientDataCopy->accountid(), pClientDataCopy );
return true;
}
Line by line:
- The function receives the message and looks up the account ID in a map, a data structure that stores values under keys.
- If an entry already exists (
idxData != InvalidIndex()), it deletes the old avatar and removes it from the map. This means repeated messages for the same account replace the old allocation. new CNETMsg_PlayerAvatarData_tallocates a fresh copy on the heap.CopyFrom( msg )copies the message contents, including the attacker-sizedrgbbytes, into that allocation.Insert( ... )stores the copy in the map under the account ID.
The handler deletes an existing avatar for the account if present, then allocates a new copy and inserts it into a map. Any account ID is accepted, allocations are persistent and the size is attacker-controlled, which makes this a powerful heap spraying primitive. By sending many messages with different account IDs and chosen sizes, the server can fill the heap with data of its choosing.
Step 6: writing to a fixed memory location
A reliable exploit benefits from writing arbitrary data to a fixed location, such as a variable in the .data section of a loaded executable or library. The .data section is the part of a program file that holds global variables with initial values, and it sits at a predictable address relative to the module. The server can do this through the CCSUsrMsg_ShowMenu message. The client handler is CHudMenu::MsgFunc_ShowMenu():
// game/client/menu.cpp
bool CHudMenu::MsgFunc_ShowMenu( const CCSUsrMsg_ShowMenu &msg)
{
// [...]
if ( m_bitsValidSlots )
{
Q_strncpy( g_szPrelocalisedMenuString, msg.menu_string().c_str(), sizeof( g_szPrelocalisedMenuString ) );
GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
m_nSelectedItem = -1;
// we have the whole string, so we can localise it now
char szMenuString[MAX_MENU_STRING];
Q_strncpy( szMenuString, ConvertCRtoNL( hudtextmessage->BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ), sizeof( szMenuString ) );
g_pVGuiLocalize->ConvertANSIToUnicode( szMenuString, g_szMenuString, sizeof( g_szMenuString ) );
// [...]
}
else
{
HideMenu();
}
return true;
}
Line by line:
- The function handles a message that asks the client to show a menu.
- If
m_bitsValidSlotsis set, the client copies the menu string from the message into the globalg_szPrelocalisedMenuString, usingQ_strncpywith the size of that global as the limit. - It then starts the "MenuOpen" animation and resets the selected item.
- A local buffer
szMenuStringis filled with a localised version of the menu text, again with a size limit. - The text is converted from ANSI to Unicode into
g_szMenuString. - If no valid slots are set, the menu is hidden instead.
The global g_szPrelocalisedMenuString is a char[512] string defined in game/client/menu.cpp. Although the code treats it as a null-terminated string, writing it multiple times lets the server craft arbitrary data in a section of engine.dll. A null-terminated string ends at the first zero byte, so the server can send several messages to fill the buffer with chosen bytes, including zeros, and build up a payload at a predictable address.
Root cause
The bug is a missing bound check on studiohdr2index, a value read straight from the attacker-supplied MDL file. SetVirtualModel() computes pStudioHdr2() as this + studiohdr2index and writes the handle-derived pointer to virtualModel at that address, so any offset in the file becomes a write offset relative to the heap object. The written value is limited: the MDLHandle_t is an unsigned short zero-extended to a pointer, so the top two bytes are null and the low two bytes depend on cache state the attacker does not control.
Existing mitigations did not stop the write itself. ASLR and DEP are enabled on the shipped binaries, but the primitive is a write, not a control-flow hijack, and there is no stack smashing protection.
Impact
A malicious server can crash a connecting client before the loading screen ends, and the authors believe a motivated attacker could achieve remote code execution, which would hand full control of the client computer to the server. Exploitation depends on the client having sv_allowupload 1 enabled, which the report describes as widespread among CS:GO players who play on community servers. The bug affects the Windows client; the impacted code is no longer present with the release of Counter-Strike 2, and no patch was released in the meantime despite multiple follow-ups.
The bug was reported to Valve through its HackerOne managed program. HackerOne is a platform where security researchers report bugs to companies and coordinate disclosure. The ticket was closed with the release of Counter-Strike 2, and the timeline records a $750 reward on 2023.04.25.
Fix
No fix was shipped for CS:GO: the report states that no patch was released despite multiple follow-ups, and the code was removed with Counter-Strike 2.
Variants to test
- Other MDL fields used as offsets. Look for fields read from the file and added to a base pointer before a write. A positive result is a crash whose faulting address tracks a value you control in the file.
- Other server-driven file loads. Check paths where the server names a resource the client must load, such as consistency checks and the
downloadablestable. A positive result is a client-side parse of an attacker-supplied file without user interaction. - Other
S2Cconnectionless handlers. Compare length fields read from the datagram with the destination buffer size, as in theS2C_CHALLENGEexample. A positive result is a stack overflow reachable before authentication. - Other
bytesfields in protobuf messages. Test whether the client copies them into persistent allocations with attacker-chosen size, as withCNETMsg_PlayerAvatarData. A positive result is repeated, size-controlled allocations that survive between messages. - Other writes into fixed globals. Look for handlers that copy message strings into global buffers, as with
g_szPrelocalisedMenuString. A positive result is attacker data landing at a predictable address in a loaded module.
Glossary
- ACK: a short acknowledgement message confirming that data was received.
- AFL++: a popular fuzzer, a program that feeds many mutated inputs to a target to find crashes.
- ASLR (Address Space Layout Randomisation): a defence that places a program's parts at random addresses each time it starts.
- Attack surface: all the places where an attacker could send input that a program will process.
- Authoritative server: a server that decides the true state of the game, which clients follow.
- Bitstream: a sequence of individual bits, rather than whole bytes, used to encode data compactly.
- Boolean: a true/false value.
- BSP: the proprietary file format that defines a Source Engine map.
- Breakpoint: a marker that pauses a program in a debugger at a chosen point.
- Buffer overflow: writing more data into a fixed-size memory area than it can hold, so the extra data spills into neighbouring memory.
- Client: the player's computer and the game program running on it.
- Compiled: turned from human-readable source code into machine code that the processor runs.
- Connectionless packet: a network datagram sent without an established connection, used for queries and connection setup.
- Consistency check: a server-requested verification that a client's files match what the server expects.
- CRC: a checksum, a short number computed from a file's contents so changes can be detected.
- Debugger: a tool for pausing and inspecting a running program.
- DEP (Data Execution Prevention): a defence that stops memory holding data from being executed as code.
- Deserialisation: turning a stream of bytes back into structured data.
- Deterministic: producing the same result every time from the same setup.
- DLL: a shared library that Windows programs load at runtime.
- Entity: any object in the game world, such as a player or an item.
- Frida: a tool that injects code into a running program to observe or change its behaviour.
- Fuzzing: automatically feeding many mutated inputs to a program to find crashes.
- Harness: the small wrapper program that hands inputs to the code under test during fuzzing.
- Heap: the memory area a program uses for data created while it runs.
- Heap massaging / heap spraying: arranging allocations so a chosen object ends up at a predictable place relative to a bug.
- Hex dump: a display of raw bytes in hexadecimal, with offsets and printable characters.
- Hook: intercepting a function call to observe or replace its behaviour.
- ICE: a block cipher, a recipe for encrypting data with a key.
- MDL: the proprietary file format that defines a Source Engine 3D model.
- Memory leak (primitive): getting a program to reveal a memory address, which defeats ASLR.
- NetChannel: Source Engine's proprietary layer for in-game network traffic, with encryption, fragmentation and compression.
- Null-terminated string: a string that ends at the first zero byte.
- Out-of-bounds read/write: reading or writing past the end of the intended memory area.
- Parser: software that reads a file or message and turns its raw bytes into meaningful data.
- PE (Portable Executable): the standard file format for Windows programs.
- Pre-authentication: reachable before the client has logged in or proven its identity.
- Primitive: a small, reliable capability an attacker builds on, such as writing a chosen value to a chosen address.
- Protobuf: a format for encoding structured messages as bytes.
- RCE (remote code execution): an attacker getting their own code to run on a victim's machine.
- Register: a small storage slot inside a processor, such as
ECXorEAX. - Relative out-of-bounds write: an out-of-bounds write whose destination is a base address plus an attacker-controlled offset.
- Reverse-engineering: working backwards from a compiled program to understand what it does.
- Server: the computer that runs the match and sends data to clients.
- Signed integer: a number type that can hold negative values.
- Source Engine: Valve's 3D game engine, first released in 2004.
- Stack: the small, fast memory area a program uses for the variables of the function it is currently running.
- Stack smashing protection: a compiler feature that detects some stack overflows at runtime.
- String table: a list of names sent over the network, here the resources a client needs.
- Subchannel: a channel inside a NetChannel used for reliable, fragmented and compressed packets.
- UDP: a basic network protocol that sends datagrams without guaranteeing order or delivery.
- Unmapped memory: an address the program has no right to touch, which causes a crash when accessed.
- Unsigned short: a number type holding values from 0 to 65535, stored in two bytes.
- Write-what-where: the ability to write a chosen value to a chosen address.
- XSS (cross-site scripting): a bug class where an attacker gets their own code to run inside a page or interface.
- ZigZag: an encoding that maps signed numbers to unsigned ones so small negative numbers stay compact.