01The question
In October 2026 two bugs in PHP, together called PHP2Shell, let attackers run their own code on servers. The strange part was who was exposed. A site could be written without a single flaw and still be taken over, because the bugs weren't in the site. They were in the program that runs it.
That program is a . Node is one, PHP is one, and the browser is one. So what is a runtime, exactly, and how can it be the weak point when your own code is fine?
The answer comes in three steps. An engine can only calculate. A harness round it decides what it can reach and when your code runs. And the harness runs before your code does.
02An engine can only calculate
A processor runs only . Whatever you write has to be translated, and for JavaScript the translator is an : V8 in Chrome and Node, JavaScriptCore in Safari and Bun. (Inside an engine, and Bun again shows what goes on inside one.)
An engine can do everything the language itself describes: arithmetic, loops, functions, objects. What it can't do is anything outside itself. JavaScript has no instruction for "read this file" or "open a connection". V8 on its own can add numbers all day and never touch your disk.
The engine carries out the code. On its own, it can't touch anything outside itself.
03The harness decides what it can reach
That reach comes from the program round the engine. It has no single standard name; people say the runtime's APIs, its bindings or its standard library. This note calls it the , a word borrowed from AI agents, where the same part does the same job (more on that below). It is ordinary code, written by the runtime's makers, that hands the engine a set of tools: functions your code can call that do the touching for it.
Node's harness gives JavaScript the file system, the network and other processes. The browser's gives it the page, fetch and storage, and no general access to your disk, which is why a website can't read your files. Both run the same V8. What your code can do is decided entirely by which harness it landed in.
- 1Page
- 2Network
- 3Files
- 4Timers
- 5Processes
- 6Storage
- Engine
- V8
- Loop
- Event loop, while the program runs
Same engine, different tool belt. A runtime is an engine plus a harness.
If you build with AI, you already know this shape. Agents such as Claude Code are usually described in three parts. A model writes text, a reply or a request to use a tool, but on its own it can't open a file or run a command. A harness round it gives it tools and runs its loop (The harness is a program on your machine). An environment, a laptop or a sandbox, is where it all acts. A runtime has the same three parts:
- The model is the engine. It works out the next step, as text, and can't carry any of it out.
- The agent's harness is the runtime's harness. It decides what the core can reach, and runs the loop.
- The environment is the environment. A laptop, a browser tab, a container.
Holding the two side by side helps in both directions. It is why the same model behaves so differently in different agents, and why the same V8 can read your disk in Node and can't in a browser: in both cases, the part that decides is the harness.
04The harness decides when your code runs
Tools are half of a harness. The other half is the loop that decides when your code runs, and here PHP and Node chose opposite answers to the same problem. Most of a web request is waiting: for the database, a file, another service. The computing in between is tiny.
PHP gives every request its own waiter. PHP-FPM keeps a of processes. A request gets one worker from start to finish, and while the database is busy, that worker stands and waits. When the page is sent, everything in its memory is wiped, and the worker goes back to the pool.
Node has one waiter for the whole room. One thread runs all your JavaScript. When a request needs the database, Node hands the wait to the operating system and moves on to the next request. When the answer arrives, it joins a queue, and the runs the code that was waiting for it. That is what await means: park me here, serve someone else, come back when my answer is ready.
- Last reply
- 240 ms
- Workers held while waiting
- 4 of 4
- Queued for a worker
- 2
The lifecycles follow from the loop. A PHP script starts fresh for each request, so /about.php feels like a file that becomes a page. A Node program is the server: you start it once with app.listen(3000), and what is in memory stays between requests.
PHP buys safety and simplicity by spending resources. Node buys efficiency by asking you never to block the loop. Either way, the harness is in charge, not your code.
05The harness runs before your code
That last point is the one that matters for security. Your code is never the first to see a request. The harness reads it first: it parses the headers, decodes the form, handles any upload and loads the session, and only then calls your code with the result. If the request is malformed, your code may never be reached at all.
So everything the harness does on the way in is code that runs on your server, with your server's permissions, that you didn't write and can't review in your own repository. Making your own code safe doesn't make that code safe.
The upload is tracked before your script starts, and that step has the bug. The attacker's code runs there, with your server's permissions. Your script, written without a flaw, is never reached.
06PHP2Shell
PHP's engine and harness are written in C, a language that makes the programmer hand memory back by hand. One feature on the way in, session upload progress, on by default since PHP 5.4, tracks a file while it is still arriving, before your script starts. The two bugs leave PHP holding pointers to memory it has already handed back, a . One of them happens when PHP runs out of memory at exactly the wrong moment. An attacker who fills that freed memory with crafted data gets PHP to treat it as its own.
PHP's fresh start for every request didn't help, because it was never the thing at risk. PHP keeps one thing between requests on purpose: the session, saved as a file on disk. Upload progress is written into it. The public exploit chain poisons that file, then gets PHP to run it.
The engine had the hole, so it didn't matter how good the code on top was. A model can behave perfectly while its harness lets anyone run commands.
It was fixed in PHP 8.2.35, 8.3.36, 8.4.27 and 8.5.12. Turning off session.upload_progress.enabled narrows the hole but doesn't close it; only updating does. A Next.js site isn't affected, but the lesson carries: Node and V8 updates matter for the same reason, because your code is only as safe as what runs it.
07Three questions for anything new
Every runtime, platform and agent framework can be read with the same three questions. Which engine runs the code? Which harness surrounds it, with which tools and which loop? And in which does it all live: a laptop, a browser tab, a container, a function on someone's servers?
- Deno is V8 with a different harness from Node's. Bun is JavaScriptCore with a harness of its own (The engine underneath).
- Cloudflare Workers are V8 with the network and no file system, on Cloudflare's machines.
- An agent is a model, a harness of tools and a loop, and a sandbox to act in.
And each layer can be where a hole is: a bug in the engine, in the harness's tools, or in the walls of the environment.
Connected
- Note · same thingStremio's player never sees a torrent
stremio-server is a long-running Node program on your Mac, the Node lifecycle exactly: started once, stays up, keeps its 25 GB cache. The window you browse in is a web app with the browser's harness. Same engine family, two harnesses, one app.
- Note · same thingThinking harder costs more, one token at a time
The model here is the engine there. Thinking stops at the reply; this note picks up the harness round it, the tool loop that hole left out.
- Note · same patternThinking harder costs more, one token at a time
Turned round. Thinking and Stremio both have one job and different engines (relay, tube, transistor; tracker, DHT). Here it is one engine and different harnesses: V8 in Node, in Chrome, in a Worker.
- Note · same thingBun is one file that does every job
That note's Node and Bun are two runtimes in this one's sense, and its Docker thread is the earlier chat on containers this one leaned on: the image as a whole folder tree, packed up.
- Note · same thingRunning a program means pointing a core at numbers
The harness and model of an agent, seen from inside one running: what the harness does without the model.
- Note · same thingA script and a branch are both smaller than they look
What goes on inside the engine, tier by tier, and which came first of compiled and interpreted.
- Chat · no note yetRestate infrastructure overview
The earlier chat taking apart Restate and Replit's agent set-up. The Restate thread leans on it.
Side threads
Questions that came up once the main idea began to hold, kept as they were asked. Each opens beside the paragraph it grew from.
Terms
Checked
What the chat had wrong or only half right, against sources. The note above already says the corrected thing.
- PHP2Shell keeps invalid session state reachable across requests, breaking PHP's fresh start.Memory is still wiped. What lasts is the session file on disk, which is what sessions are for; the public exploit chain poisons that file. Sources also disagree on which CVE is which bug, and on attacks in the wild.Akamai, Understanding PHP2Shell
- PHP and JavaScript are interpreted.Both compile to bytecode or opcodes first and run that. PHP caches its opcodes and has had a JIT since PHP 8.0. Still a spectrum of when.PHP manual, OPcache