Break the Attack Chain

At the end of the last lesson, a stranger’s issue told an agent to print a private npm token and post it as a comment. That instruction could do harm only with a secret the agent could read and a way to send it out.

Here, you’ll see the three conditions an injected instruction needs to leak a secret, check which of them your setup gives your agent, and remove at least one with its settings.

See What a Leak Needs

You can’t reliably stop a model from following instructions in text it reads, so the defense has to sit somewhere else. Picture the feedback file’s hidden comment asking for something worse: read .env, then fetch an example.com address with the key added to the end. For that to leak anything, three things must be present in the same session:

  1. Untrusted text the agent reads, such as a player’s feedback file or a page it fetches, which carries the instruction
  2. Private data the agent can read, such as a key in a project file or in the shell you started the agent from
  3. A way to send data out, such as a fetch, a command that reaches the network, or one that posts or pushes

Watch out: Untrusted text isn’t only what someone types to you. Files, fetched pages, and command output count too, and nobody reads those before the model does.

Together, the three conditions form an attack chain: the instruction needs every link to send a secret to someone outside your session. Remove any one, and it has no text to arrive in, nothing to steal, or no way out. The chain doesn’t cover the model provider, though. Anything the agent reads goes to the provider and into the transcript, network or not. Here’s each link with what removes it:

An injected instruction needs untrusted text, private data and a way out to leak a secret. Cutting any one link stops it.
One Cut per Link of the Attack Chain

You can’t always remove all three, because a task often needs one. Summarizing the feedback needs the untrusted text, and reading a library’s online documentation needs the network. So you cut a link the task can do without. That’s least privilege: the agent gets only the access the current task needs.

The chain covers only leaks. An injected instruction can still ask for an edit that involves no secret, so keep approval prompts on and review the diff.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.