Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 12 min read Deep dive hardMaster

Using Hermes’s Quicksort to run Doom: A tale of JavaScript exploitation

A fuzzer-found bug in Hermes's stable Quicksort let a comparator callback grow the array during Array.prototype.sort, so the fixed-size index vector was read out of bounds. Meta's security team escalated it to arbitrary read/write. They underflowed the unsigned j index to swap values outside the vector, groomed adjacent mmap'd ArrayBuffer allocations, and corrupted a malloc chunk size to get overlapping buffers. They then reclaimed one buffer as a GenGC heap segment so ArrayBuffer data pointers could be overwritten. The escalation raised the bounty from a typical $500–$3,000 to $12,000, and the exploit was demonstrated by running Doom inside Hermes.

Related posts

  • Bun v1.0.20

    Bun mediumAdept

    Bun v1.0.20 cuts memory usage in node:fs async operations by avoiding redundant cross-thread string clones. Benchmarks show fs.readlink and fs.stat dropping from 107 MB to about 45–71 MB RSS, and a fs.writeFile leak with large non-ASCII strings falling from 1,696 MB to 91 MB. HTMLRewriter.transform now accepts strings and ArrayBuffers and has a destructor-timing leak fixed, and fs.readFile/writeFile gain hex and base64 encodings. A Linux setTimeout high-CPU regression is fixed, Bun.spawn gains a resourceUsage report, and debug builds use macOS malloc zones to track native allocations.

  • Turbocharging V8 with mutable heap numbers

    V8 hardMaster

    V8 eliminated a performance cliff in JetStream2's async-fs benchmark caused by a custom Math.random whose `seed` lives in a ScriptContext slot. Every update to the seed allocated a new immutable HeapNumber, and the integer bitwise math was compiled as floating-point. V8 now tracks slot types (constant, SMI, HeapNumber, Int32, other) and lets a context slot own a mutable HeapNumber that is updated in place, storing raw Int32 values when they stay in range. Optimized code depends on the slot type staying stable and deoptimizes if it changes, and the change gives about a 2.5x speedup on async-fs and about 1.6% on the overall JetStream2 score.

  • Bun v1.0.21

    Bun mediumAdept

    Bun v1.0.21 fixes 33 bugs and focuses on memory: blob.arrayBuffer() now uses copy-on-write virtual memory mappings for blobs of 8 MB or more (1 MB with --smol), so 100 copies of a 128 MB blob use 192 MB instead of 12.9 GB. bun:sqlite now reports SQLite's memory to the garbage collector, cutting usage 4x for 100,000 prepared statements, and throws SQLiteError with extended error codes and messages. The release also adds console.table(), Blob support in Bun.CryptoHasher and a toBeObject matcher. It fixes path-string memory leaks in Bun.file, Bun.write and node:fs errors, plus several TLS and WebSocket crashes.

  • Bun v1.1.7

    Bun mediumAdept

    Bun v1.1.7 fixes 28 bugs and adds glob patterns in package.json workspaces (via Bun.Glob), asymmetric matcher support in expect.extend's this.equals, and a working bunx --version. Several fixes come with root causes: a SIMD invalid memory access in Zig's std.mem.indexOfScalarPos crashing Windows startup, a misassumed 8-byte alignment of FILE_DIRECTORY_INFORMATION, threadlocal destructors running during std::quick_exit with live Workers, an uninitialized C++ integer corrupting stacktrace line numbers, and a memory leak from unread Bun.serve() request bodies since v1.0.30. Smaller changes include WebSocket close code 1015 on TLS failures, a ServerWebSocket shrink from 32 to 24 bytes, and adding clang-analyzer to CI.

  • Bun v0.6.9

    Bun mediumAdept

    Bun v0.6.9 focuses on memory reductions: zero-copy string Response bodies in Bun.serve() and Response (60 MB vs Deno's 425 MB and Node's 1414 MB after 1000 responses of a 12 MB string), 50% less memory for cold bun install, and fixed leaks when importing modules. It also fixes non-ASCII filename imports, mockResolvedValue and missing function properties on mocks in bun test, a GC-related crash in the CommonJS require() loader, and a ~192-byte-per-call leak in node:crypto hashing.

The quest for software engineering knowledge.

Look:
Layout: