The Interpreter

Inside Datadome's Interstitial Module 872 VM - v1.33.1

Today we'll be delving into DataDome's interstitial module 872 VM, disassembling it, lifting it into pseudo-code, and tracing the cipher behind the plv3 token.

Disclaimer: A signal list will not be given in this post. We'll be delving into the architecture of the VM, and the cipher behind the plv3 token. Take everything you see here with a grain of salt, these are my own findings and I encourage you to verify yourself before taking my findings as truth.

Going into the reversal I already knew a few things about this VM. Back in April I attempted to reverse this VM, and I ended up giving up. I wanted to see what cipher was being used for the plv3 VM, but at the time I had minimal knowledge about VMs, and dived straight off the deep end into this behemoth of a VM which proved to be a much bigger challenge than I initially thought. Being honest, I had absolutely no clue what I was looking at back then. I knew the VM was a self-constructing loading VM, it was a stack machine, and I had the dispatch loop and tape already located. I've come back to this VM after taking apart Kasada's VM, and decided to give it another crack.

As stated in the Kasada post, I've been learning about reverse engineering custom bytecode virtual machines buried in JavaScript over the past few months. Anti-bots are moving this direction because it raises costs for attackers significantly, and it's much more time consuming than your typical obfuscated JS file. The same rules apply as last time, I've reversed everything myself, and used AI to help me write tools for speeding up the process.

One thing I will say. I've seen many people calling Kasada the hardest VM they've taken apart, and DataDome is almost always labeled as the easiest. I want to chime in on this given I've taken apart both now. DataDome's VM, because of its architecture type (stack machine), was much harder to read compared to Kasada's register machine. I actually found it easier to take apart Kasada's VM as well, even though it was my first time taking apart a commercial anti-bot VM, and my first time working with a register machine. I think DataDome gets a lot of hate because of their tags challenge, but honestly they're going in the right direction now. There were plenty of times here where I wanted to give up, and I left most of those times out in this post, but persistence is key.

Deobfuscating their JS

When a request gets blocked by DataDome, there are two types of step-up challenges. The first (which is medium risk) is the interstitial challenge. This is a silent device check that runs in the background of your browser, a non-interactive challenge. The second is the slider challenge. This is their high risk step up, and it prompts the user to slide an arrow all the way to the right of a box.

DataDome Slider

We'll be delving into the former, their invisible device check. Specifically, we're going to map the module 872 VM, which is their "proof-of-browser" check. This exists in both the silent device check, and the slider challenge.

Opening their JS reveals a huge blob of obfuscated JS. The first thing I want to do is deobfuscate the JS to see what exactly we're dealing with. I ran webcrack on the file which separated the different module numbers into each corresponding file. The one we're focusing on is 872. Webcrack wasn't able to deobfuscate the file, so I'm going to write some simple AST transformations using Babel to make this more readable.

What we're left with is about 218 lines of code. At the start of the file we can see multiple constants being declared:

const g = 3525;
const B = 3934;
const w = 223532;
const C = 227466;
const Y = 3368;
const E = 3390;
const D = 3419;
const T = 3388;
const J = 3416;

Below this, there's three large functions. At the bottom of the file we can see a module.exports, which contains a massive ~220k character long string.

module.exports = function () {
  return function (A) { // dispatch loop
    const C = performance.now(); // start time
    let E = 0;
    const D = {};
    try {
      const C = function (A) {
        const g = M();
        return Array.from({
          length: 233538
        }, (C, Y) => Y >= B && Y < B + w ? A.charCodeAt(Y - B) : g());
      }(atob(A)); // VM memory/tape
      s(C, D); // setup/loader
      const N = C[B + C[Y]++];
      const Q = g + N;
      C[J] = C[Q]; // Look up handler for opcode N and install it as current instruction
      C[3349] = N;
      while (!C[T] && E++ < 100000000) { // C[T] = HALT flag
        C[J](); // run the current handler
      }
      D.u = C[-1];
    } catch (A) {
      D.e = A;
    } finally {
      D.i = E; // output
      D.t = performance.now() - C | 0; // time to run
      return D;
    }
  }("J0kAAGJjb25zdCBuPWFyZ3VtZW50c1swXSxzPW..."); // encoded tape
};

The string is the encoded tape, and what we're looking at here is the dispatch loop for the VM. The tape looks atob encoded, so I tried taking the string and base64 decoding it. This showed me the ops, along with the tape. There's 101 ops (93 executing ops, 101 total ops) buried at the start of the tape, but I can't op name yet without learning the primitives of this VM.

The VM is one big array, carved into regions. Registers up front, then the tape, then the stack. The variables we saw declared at the top of the list are boundaries, regs below 3934, tape from there, stack up top.

Learning the primitives

To save the bore of going through every primitive and learning each one, I'll show a snippet of each primitive and the name I gave it initially to get the ball moving on op naming.

n[k] holds the name I gave it
n[17] A tape / memory array
n[31] E (3390) stack pointer
n[15] Y (3368) program counter
n[43] C (227466) frame / memory base
n[10] D (3419) unknown currently.
n[2] T (3388) unknown currently.
n[0] / n[3] / n[7] / n[13] 3397 / 3330 / w / 3378 bare slots

The operand readers, the few I named first to get going (pull bytes off the tape, advance PC):

// s() - the 8-bit reader (also n[37])
return A[B + A[Y]++];              // read byte at base+PC, THEN advance PC

// n[34] - READ 16 BIT OPERAND
const g = A[Y]; const w = A[B+g]; const C = A[B+g+1]; A[Y] = g+2; return w<<8 | C;

// n[8] - READ 24 BIT  (the local M)

// n[36]  — GETTYPETAG
return N(() => A[B + A[Y]++]);

// n[29] - Q / "next instruction"  (fetch-decode the next op; ends every handler)

Stack/frame, POP I had early:

// n[19]  — POP → A[D]
A[D] = A[--A[E]];

Naming the ops

After naming those it was time for me to move to op naming. I started off with the easy ones like arithmetic ops (add, subtract, XOR, etc.), and moved progressively through them. While I was reading the ops, I noticed that most of them have a call to n[20] with the op's own byte as the argument. When I looked at the primitive, it's an empty function:

// n[20]
function (A) {}

So I started to speculate on what this could actually be used for. It does nothing in this build, but in future builds this could be a dormant anti-tamper/CFI canary. A future build swaps it for a check that, if it fails, silently blocks on the score rather than throwing. A silent block is better here because a thrown error tells a solver exactly which op tripped the trap, whereas a silent block just harvests telemetry from everyone running a stale solver. This is all speculation though, and I have no way to verify my claims, I just thought it was odd to leave this empty op in the build so I started to speculate.

Every op is const n = arguments[0] plus a short recipe of n[k] calls, always ending in n[29]() (next instruction). So naming an op = read the recipe, inline the primitives, then ask: what expression does it compute, and where does the result land? Is it pushed on the stack, stored to a frame slot, written into memory, or a side effect (JMP/CALL/HALT). That helped me in naming these ops, as I did have trouble at the start trying to come up with names for them.

I went through and named every op I could with the primitives I had mapped, and now I need to go back to the JS and get the last few primitives to finish the op naming, then move to lifting it into pseudo-code. The last few primitives are n[10], which is the result register (D.r = the plv3 token), n[2] which is the halt flag, n[4] which is LOAD, n[9] which is STORE, n[5] which is GETPROP, and n[49] which is SETPROP. Now that I have those last primitives, I can name the last few remaining ops and move onto the lift.

Here are a few worked examples of the ops. This one is pretty straightforward.

// GETPROP
function op91() {
  const n = arguments[0];
  n[20](225); // possible dormant anti-tamper? useless in this build.
  const s = n[36](), // get type tag
    t = n[17][n[31]],
    c = n[17][t - 1]; // peek
  n[17][t - 1] = c[s]; // assign peek to obj
  n[29](); // next operation
}

Another example:

// POP + ASSIGNMEMTOPOP + ADDPOPTORESULT + ASSIGNSPTOTYPETAG
function op15() {
  const n = arguments[0];
  n[20](22);
  const s = n[34](), // READ 16BIT
    t = n[17][--n[17][n[31]]]; // POP
  n[17][n[43] + s] = t; // ASSIGN MEM TO POP
  n[17][n[10]] = t; // ADD POP TO RESULT
  const c = n[36](); // GET TYPE TAG
  n[17][n[17][n[31]]++] = c; // ASSIGN SP TO TYPETAG
  n[29](); // NEXT INSTRUCTION
}

A lot of the ops in DataDome had multiple operations they'd do inside one op. Kasada didn't do much of this, so it was hard for me to come up with a single name. I ended up just naming what each op was doing, and if it had multiple operations in one I'd just separate each by +.

Building the tooling

With the last few ops named, it's time to move onto tooling. As stated previously, the tooling was written by AI. We started off with creating the disassembler which recovered the executed instruction stream by instrumenting the VM's own operand readers. Once the disassembly was built, we created the lifter. It lifts each opcode to pseudo-code from the named ISA. Keyed on handler source, not opcode byte, because the table self-constructs and reuses bytes which I encountered in the Kasada lift. Then we built structure, which resembled the Kasada lift. It flattens the lift into a readable, register style decompile (Ln: labels, // @addr comments, goto as the only non-JS token).

DataDome Pseudo-Code

We can finally now start to read the VM, but I wanted a few more tools to make it easier for me to trace values. First, we made a memory slot tap. Every read/write to a slot or range, tagged with executing op's name and address (C[Y]-1, the instruction address, not the mid-op PC). Then we made a tool to watch per-op runtime values, and another one that finds the VM's sub array buffers by object identity and logs element writes with the VM address, routing around the reused base-relative Vn names. We also made a backward def-use slicer over the structured output. With those created, it's time to actually start to hunt for the token.

Hunting the token

Op63 (HALT), does n[7].r = A[n[10]], n[10] = 3419, the token is whatever's in slot 3419 when the VM stops. My first instinct is to watch slot 3419's writes, but this was a dead end. The first ~300 writes are scratch, the VM building the API-name strings char by char (Uint8Array, Date + now, Math + Random, ...) and starting a rolling hash. 3419 is a reused scratch register, the token is only its value at halt. I fixed that by adding --tail to the memory slot tap so I could see the last few writes, not the first.

Outer Cipher

This caught the final assembly. The VM spells out join, btoa, replace, and does D.r = btoa(bytes.join('')).replace(...)x4 = base64url. btoa is keyless and reversible, so the outer "encryption" is just packaging. The thing that is fed to btoa is a ~290 byte binary string, the .join('') of a byte array, and that's what we need to hunt for next.

I tried backward slicing the bytes producers, but it kept bottoming out at <input/param>. The values were loop carried (hash accumulators on the back edge) or function arguments. The exact blind spot of a static nearest def slicer. The fix was a method shift, not a tool. I read a loop by replaying it, and not slicing it. The slicer couldn't follow the data, so I decided to hook the VM, find the ~290 byte array, and capture where it's written. This became arrtrace. An object identity tracer that watches the actual Array object instead of the reused byte relative Vn name.

ArrayTrace

In a single run it laid out the whole pipeline. #361, a 285 byte working buffer hammered 757 times across the run at ~30 distinct write sites -> #990 the 293 byte byte buffer -> #991 the char array via fromCharCode -> join -> btoa -> D.r. I immediately verified by fromCharCode that it's #990, not #361 that gets serialized. And those ~30 write sites were the tell that #361 isn't one blob but a field structure (mostly 8-byte chunks), so I dove into one field (@140201) and read its construction with demask: #361[i] = plaintext + Sbox[idx] + V25. That field read is where the table chasing started, and where I kept grabbing the wrong table over and over. I chased multiple dead ends, so I decided to try an experiment that settled it.

A curious find

But before I get to the experiment, I got curious when I was reading L16354 and saw a return statement, which I decided to read the values of. This was the best find of the entire search, and it basically showed every single signal that is put into the plv3 token. As I stated previously, I won't be showing every single signal, but I will show a couple I saw.

Curiosity

I'm mentioning this because this will come back at the end of the search, and I also want to reaffirm to people reading that curiosity when reading these anti-bot VM's has led me to great finds. So when you're reversing, be curious, because more often than not you'll find something that helps you meaningfully (this also happened with Kasada, and I found a few easter eggs the developers left which was a cool find).

The experiment

Now back to the experiment. I created diffmap which runs the VM twice and diffs a buffer byte by byte. The lookup index (@140182) is static across runs, the output (@140186) is dynamic. The table the field actually reads (V426) is per-run, while V25 and the @32186 S-box diff as 100% static (constants to extract once, not secrets). And since a table turned out to be a plain linear sequence read at a static index (no swapped permutation anywhere), the posts I've seen on plv3 labeled the plv3 cipher as an "RC4-variant", which proved to be wrong.

The table was per-run, so something seeds it, and I decided to go hunting for the nonce. Tracing the per-run value backward ran straight into the derivation at @89056: V34[V17[V29[V11]]] ^ 139, nested lookups four plus tables deep, deliberately bottomless.

NestedObf

I wanted to hand reverse it, but the better call was to refuse that fight and go around it. If the keystream is a deterministic function of the entropy, I never have to reimplement the derivation. I can pin the entropy and let the VM compute the keystream for me. So I stopped reversing how the nonce becomes the keystream and started asking what feeds it. determ.js proved the promise first. I pinned every entropy source (Date.now, performance, Math.random, crypto.getRandomValues, error.stack), run twice, and the token comes out identical. The whole thing is a pure function of the nonce.

PinnedEntropy

Now that every source was pinnable, the question becomes which one is the nonce? I held each one fixed and changed one at a time. The clock didn't move the token, Math.random didn't, but flipping a single byte of crypto.getRandomValues did. So the per-run keystream depends on exactly one input, crypto.getRandomValues. The nonce, carried in the token as the IV at offset 64. I never had to touch @89056. This debunked another claim I saw, which was that the server validates the token structurally without decoding it. Though, this was self-contradicting since the checks it lists all require decoding first. The server decrypts with the carried nonce + the static keys; somewhere "can't reproduce" had been muddled into "can't decode".

Unpin getRandomValues

To get the payload without touching that derivation, three shortcuts failed first which I ruled out by just looking at the output. Tapping the per-run table by memory range (98k reads, it shares the stack, nothing isolatable); hooking charCodeAt (caught only error.stack, the VM reads its payload from its own memory, never as JS strings); reading the first write per #361 position (already masked, 33% printable).

Then I pivoted, and went a different direction. I decided to read the signals at the source. I tapped every host read which ended up giving me the entire signal payload. I was able to do this because of the return statement I hooked earlier. I had every signal that was fed into plv3. I never had to even touch the cipher.

The cipher, end to end

So in the end, I didn't exactly "crack" the cipher, but I was able to map it fully, and get the full signal list of what plv3 includes.

signals collected off browsers -> serialized into a plaintext byte buffer -> inner cipher -> outer cipher -> fromCharCode -> join -> btoa -> base64url = D.r.

The outer cipher is base64url packaging over a static XOR. The outer key (V25) is a 256-byte constant, identical per run, and btoa is keyless and reversible. So the outer layer is obfuscation, not encryption. Anyone with the client can undo it.

The inner cipher is a per-run, nonce keyed substitution. Each plaintext byte is masked through a 256 entry table at a static per position index, with XOR. The table is the only per-run piece, and it's seeded by one input, crypto.getRandomValues, the nonce, carried in the token as the IV at offset 64. The "RC4-variant" label was wrong, there was no swap based KSA, and one of the tables is a plain linear (a + b x k) mod 256 sequence. The only thing I didn't reverse, and I deliberately refused, is the obfuscated @89056 derivation that turns the nonce bytes into that table.

So the verdict I came to is it's a nonce keyed substitution + static XOR obfuscation wrapper around a fingerprint payload. A time tax, and anti-replay shell, not cryptographic secrecy. Because the nonce rides along in the token, the whole thing is deterministic and fully decodable given that nonce plus the (static, extractable) keys, which is exactly how the server reads it. Decode, then score the collected signals.

Defensive Side

As I stated at the start, I had more trouble with this than I did Kasada's VM despite the narrative that Kasada is one of the harder VMs compared to DataDome. This was only one part of the DataDome challenge. In the actual interstitial post data, there's another signal payload that must agree with the plv3 which is a more thorough signal list. From a defensive standpoint the VM was actually solid. Reading the VM is where I had trouble, and the obfuscation was pretty good. It took me about 6 days for me to map the entire plv3 cipher, and the signals it collects.

But here's the thing, the crypto was never a secret keeper. The nonce rides in the token in the clear, which means the server has to be able to decode it, so confidentiality was never the goal. If the design wanted secrecy, it wouldn't hand you the IV. Mistaking the obfuscation for the defence is the trap. I just spent a week proving the obfuscation comes apart.

The @89056 derivation is the cost raiser doing exactly what it was put there to do. I refused to hand reverse it and replayed the nonce instead, which cost me nothing. But a solver author who wants to reproduce a token from scratch, not replay, hits that bottomless nest and pays dearly. That is the correct way to judge client side obfuscation, not "can it be beaten" (everything client side can), but "how many attacker hours does beating it cost, and does that price out the attacker." Its success is measured in time, not in being unbreakable.

Just like Kasada, the real gate is server side. The VM's job is to collect a fingerprint that's expensive to forge faithfully, and bind it to a fresh nonce. The verdict, scoring that decoded payload against the UA/IP/TLS it arrived with, happens somewhere we cannot see. The whole elaborate client cipher is just protecting a payload whose actual evaluation isn't in the client at all. The dormant n[20] canary and the environment probes show the design is built for silent integrity enforcement and sandbox detection. And that's exactly what the plv3 token is for, as labelled by DataDome themselves, it's a "proof of browser" check. It's purely there to make sure the JS was run inside of a browser, and not a sandbox.

The actual kicker is that I mapped the whole thing, and I still didn't beat the actual defence, because the actual defence was never in the client.