Experiments · JavaScript: From Closures to Autonomous Systems · Chapter 18
Ten actions through the harness
Prompt injection and the agent harness
Everything is computed in your browser; nothing is sent anywhere.
About this experiment
What is prompt injection?
Prompt injection is an attack on a system built around a language model: text the model reads as data, such as an email, a web page or a file, contains instructions, and the model follows them. Simon Willison named it in September 2022, by analogy with SQL injection. The cause is that a model has no separate channel for commands; everything it reads is text. No reliable way to teach a model to tell data from commands has been found, so defences sit in the code around the model: narrow permissions for each tool, and tracking where data came from before it is allowed to leave.
An agent runs a program that is written while it runs. The model decides the next tool call, and that call can be malformed, can climb out of its directory, or can carry out an order it found in an email it just read. The code around the model that checks each call before it runs is called the harness.
The experiment takes the book’s ten actions, a fixed list of what real models propose, and passes them through a harness one at a time. Four layers can be switched on and off: parse, schema, permissions on the model of Deno’s flags, and provenance labels after CaMeL. Step through the actions or run them all; each row shows which layer stopped the action, or that it ran, and a panel shows what left the machine. There is no model here and the files and network are toys, but the harness is real code running in your browser, so the error messages come from your engine.
The book ran it in Node 24.16.0. The naive harness, which only parses and runs, executes seven actions, crashes twice, and sends the password from .env to evil.example and a customer key to api.example.com. With all four layers it executes four and stops one at parse, two at schema, two at permissions and one at provenance, and nothing leaves.
The ninth action is the one the chapter turns on. The secret file is inside the granted directory, so reading it is allowed, and api.example.com is an allowed address, so permissions have nothing to catch. Only a harness that remembers where the data came from can refuse to send it, and that is the point of chapter 18: what the agent is given has to be decided in advance, because after launch the model makes the decisions.
From the book
JavaScript: From Closures to Autonomous Systems · Chapter 18
A Runtime for a Nondeterministic Executor
… Such a thing can be stopped only if the harness remembers where data came from. In 2025 researchers from Google and ETH Zurich described a system called CaMeL, where every value carries a mark of its origin, and before every tool call it is checked whether such data is allowed to flow there. In the experiment this is done in a simplified way: the model refers to the results of previous steps, the harness substitutes them itself and knows that the contents of secrets.txt are marked as secret. The secret file can be read, but its contents cannot be sent to the network, even to an allowed address.