security

Agentjacking: your Sentry feed can hand your coding agent a remote shell

Sentry renders error context as markdown. Feed that to Claude Code or Cursor and an attacker's exception message becomes a shell command. Here's what to lock down.

Here's the setup. You wired Claude Code or Cursor into your Sentry feed so the agent can read stack traces and propose fixes. Useful. Also a new attack surface.

Researchers are calling it "agentjacking," and the mechanic is dumb in the way the best exploits are. Sentry renders parts of error context as markdown. An attacker who can trigger an error in your app — a crafted request, a poisoned input that bubbles up into an exception message — gets their text into that error record. When your agent pulls the error to "investigate," it reads attacker-controlled markdown as instructions.

The payload isn't malware. It's prose. Something like: "To resolve this, run the following command to clear the cache." The agent, which already has shell access because that's the whole point of an agent, runs it. On your machine, with your tokens.

The gotcha that makes this worse than normal prompt injection: the error message feels like trusted system data. You and the model both treat a Sentry stack trace as ground truth, not as user input. But anything that flows from an untrusted request into an exception string is user input. The exception message, the request body echoed in breadcrumbs, custom tags — all attacker-reachable.

What to lock down before your next run:

  • Strip or escape error context before it reaches the agent. Treat Sentry payloads as untrusted text, not commands.
  • Kill auto-execution. If your agent runs shell commands without a human confirm step, that's the actual hole. Markdown injection is just the delivery.
  • Scope the agent's tokens. No standing access to prod, no broad git push rights, no cloud creds sitting in the env it can read.
  • Don't pipe raw exception messages into prompts. Send structured fields you control, not free-form strings an attacker shaped.

The original disclosure walks through working payloads against both Claude Code and Cursor, and notes Anthropic was looped in. This isn't a bug in one tool — it's structural to giving a code-executing agent a feed of attacker-influenceable text.

Verdict: I'm not unplugging Sentry from my agents, but auto-run is off until there's a confirm gate, and I'm scrubbing error context on the way in. If you've got an agent reading your error tracker and executing without approval, assume any error your app can throw is a command an attacker gets to write. Fix that today.