Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Tool:Bytenode

From ReverseEngineering.wiki
Tool
License MIT
Website https://github.com/bytenode/bytenode
On this wiki Facts · Code · Notes · Topics

bytenode (MIT) compiles JavaScript to a V8 code cache (.jsc) that Node.js or Electron loads through vm.Script with a dummy source, so the shipped app has bytecode instead of readable source.

bytenode ships JavaScript as Format:V8 code cache blobs. The loader needs the same V8 version and flags as the compiler, so a .jsc only runs inside the Node.js or Electron build it was made for.

Recognising it

  • Files ending in .jsc; a small .js stub that calls require('bytenode') and loads a .jsc; the strings bytenode and .jsc in the app bundle or its package.json.
  • The file begins with a V8 code cache header: bytes 2-3 are DE C0 (magic 0xC0DE0000 xor table size); bytenode checks exactly that in isBufferV8Bytecode and, if it is absent, tries Brotli decompression (compress option). See Fact:V8 code cache/magic/Magic 0xC0DE0000 xor table size.

How it works (lib/index.js at 5562c8f)

  1. Compile: new vm.Script(code, {produceCachedData: true}) then createCachedData(); V8 flags --no-lazy (so every function is compiled eagerly) and --no-flush-bytecode are set first.
  2. Load: read the source length from the header (offset 8, the legacy length-based source hash), build a dummy source of that length (" + zero-width spaces + "), and run new vm.Script(dummy, {cachedData, filename}). V8 only compares the length-derived source hash, so the dummy is accepted, and then executes the cached bytecode; script.cachedDataRejected signals a mismatch.
  3. Fix-up: because the compile may have run in another process, fixBytecode copies the flag hash (bytes 12-16) from a freshly compiled dummy into the .jsc. Older Node 9-11 also patched bytes 16-20; Electron needs bytecode compiled inside Electron itself.

The layout comment in bytenode (source hash == source length, 4 bytes) is the older header; V8 main has a 32-byte source hash and can be set to SHA-256 mode, see Format:V8 code cache. Unverified: which V8 versions switched on SHA-256 by default (and so make the dummy-source trick fail).

Reversing

The function source text is not in the file, but string literals, identifiers and constants of every function are in the serialized payload, so strings shows much of the program. Decompiling needs a disassembler for the exact V8 bytecode version (Ignition); the V8 version hash in the header (offset 4) identifies the build. See Technique:Reversing bundled JavaScript.

Code & repositories

See the linked repository below.

  • https://github.com/bytenode/bytenode @ 5562c8f31ce64cfbb4664ada71281feffe8172b9 · license: MIT (declared by the contributor for the files used; GitHub reports MIT (read from LICENSE; GitHub's API was busy) for the repository)
    bytenode: compileCode, fixBytecode, readSourceHash, generateScript in lib/index.js (magic DE C0, dummy source of the original length, flag hash patch).
    Tested on: source read, not run · checked 2026-10-19