Skip to content
Memory corruption Write-up Advanced

When Agentic Glue Melts: Exploiting Cloudflare Code Mode and Workers

Check Point Research found five memory-corruption and deserialisation bugs in workerd, the C++ runtime behind Cloudflare Workers and Code Mode, including an out-of-bounds read in URLPattern and a use-after-free in node:zlib. Chained together, these let a malicious Worker read another tenant's secrets from the shared heap, or let a prompt injection escape the Code Mode sandbox and run native code on the host.

matthewsu Follow

Published on research.checkpoint.com

We set out to break Cloudflare Code Mode, and ended up breaking Cloudflare Workers too. We did both by targeting workerd, the runtime beneath both: an in-process sandbox that relies entirely on V8 to isolate untrusted code.

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the native C++ glue between JavaScript and the runtime (JSG) mishandles object lifetimes and counts, so bugs there sit on the tcmalloc heap outside the V8 cage and memory protection keys.

Impact

A malicious Worker could read another tenant's secrets from the shared process heap, and a prompt injection could escape the Code Mode sandbox to run native code on the host; the authors note they did not test the cross-tenant exploit on production, only self-hosted workerd, and that production had a check the open-source build lacked.

What the attacker needed

Ability to deploy a Worker; shared host with other tenants; self-hosted workerd for full exploit

The fix

Cloudflare's managed Workers environment was fixed in production, and self-hosted workerd or Code Mode deployments should update to v1.20260619.1.

How it was found

  1. Deploy a malicious Worker into Cloudflare's shared pool.
  2. Trigger the URLPattern out-of-bounds read by supplying a pattern with a group nested inside another group.
  3. Use the resulting arbitrary read to reach another tenant's memory in the shared process.
  4. Leak the other tenant's secrets out of the process.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Cloudflare Workers runs lots of customers' code inside one shared program, relying on a JavaScript engine to keep them apart. The researchers looked at the C++ layer that connects JavaScript to the underlying system and found mistakes that let one piece of code read or write memory it should not touch. That means one customer could potentially see another's data, or break out of the sandbox entirely.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by matthewsu

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.