Skip to content
Guide

Prompt injection in coding agents

In short

Prompt injection in a coding agent is text it reads while working, in a README, fetched page or tool reply, that it follows as an instruction. The agent holds a developer’s shell and credentials, so a hidden line can become a real action.

Text becomes instructions

An agent reads your request and the files, pages and tool replies it pulls in as one stream of text. A model cannot be relied on to treat that text only as data, so a planted instruction can be followed like yours.

Where it hides

  • Hidden in plain text

    A line nobody looks at, in a comment or a collapsed section, tells the agent to do something else, and the agent takes in the whole file.

  • A reply from a trusted tool

    A tool you approved returns instructions along with its answer, so trusting the tool does not mean trusting everything it sends back.

  • A settings file in the repo

    A config file checked into the repo asks the agent to relax its own rules, so a guardrail can be switched off from inside the project.

Test your setup safely

  1. Copy the setup

    Rebuild it with the same MCP servers, hooks and allowed commands, but with stand-in tools and fake secrets, and never on production.

  2. Run the techniques

    Plant the hidden instructions a real attacker would use, one at a time, so each result points to a single cause.

  3. Fix and run again

    Add the guardrail that closes the gap, then run the same test again to show the fix holds.

Coding agent setups, tested in Cimento

Cimento simulations put a sandboxed copy of a coding agent’s setup to the test.

  • Each agent’s setup is rebuilt in a sandbox from its own configuration, with fake secrets and stand-in tools.
  • Tests include a hidden instruction in a README, a poisoned tool response and a repo file that loosens settings.
  • You see what got through, which control stopped the rest, and why.
  • Each gap comes with a suggested fix, and the same test runs again to show it holds.

Questions

Can a model be trained not to follow injected text?

Training can reduce it, but a model cannot be counted on to tell data from a command every time. That is why the setup around the agent matters: what it can reach, what runs without asking, and where secrets sit.

Is it safe to test this on a live laptop?

Not with real secrets in reach. Test a copy with fake secrets and stand-in tools, kept apart from production, so a test that gets through has nothing real to take.

How often should a setup be tested?

Whenever the setup changes, and again after each fix. A result is only true for the setup and the test it came from, so a new tool, a new permission or a changed setting means running it again.

See a simulation run, live.

In 30 minutes we test a sample agent setup in a sandbox, show what got through and apply the fix.

In one demo

  1. Check the box on human risk
  2. See your team outpace its AI usage
  3. Find the gaps while the secrets are fake