Menu
Back to Blog
AI SecurityCode Audit

How a Stranger's PR Comment Could Steer an AI Agent: Two Findings from Our Open Session Review

Author: Aleksandr Tynianov

Prompt injection is the first risk on OWASP's Top 10 for LLM applications, and AI agents raise the stakes. A chatbot that gets tricked writes a bad answer. An agent that gets tricked can send email, push code or run commands.

This post explains what prompt injection is and how it works, then walks through a real case from our security review of Open Session, an open-source AI agent server by Tella. There, a review comment from any GitHub account could reach a teammate's agent session as an instruction, and that session had admin tools. Tella fixed it the same day we reported it and agreed that we could write about it.

What is prompt injection?

Prompt injection is an attack where text written by someone else changes what a language model does. OWASP lists it as LLM01:2025 and describes it as input that changes a model's behavior or output in unintended ways. The term was coined by Simon Willison in September 2022.

The cause is structural. A model receives its instructions and the data it works on as one stream of text. There is no separate channel that says "this part is a command, this part is only content to read". If the content contains something written like a command, the model may follow it.

People often compare it to SQL injection. The comparison helps, with one difference that matters: SQL injection has a reliable fix, because parameterized queries keep code and data apart. Prompt injection has no equivalent yet. OWASP's own guidance says it is unclear whether fool-proof prevention exists.

How prompt injection attacks work

There are two kinds.

Direct prompt injection. The attacker types the instruction to the model themselves, in a chat box or an API call. "Ignore your previous instructions" is the classic example. It matters when the model holds something the user should not get, such as a system prompt or another customer's data.

Indirect prompt injection. The attacker never talks to the model. They put the instruction somewhere the model will read later: a web page, an email, a document, a support ticket, a code comment. When the agent reads that content during its normal work, the instruction lands in its context with the same weight as everything else.

AI agents are exposed mostly to the indirect kind, because reading outside content is their job. A coding agent reads issues, pull requests, READMEs and dependency docs. An inbox agent reads email. A research agent reads the web. Each of these is a place where someone else can write.

An indirect prompt injection attack usually goes like this:

  1. The attacker finds a place the agent reads and the attacker can write to.
  2. They plant text written as an instruction, often disguised as normal content.
  3. During an ordinary task, the agent reads it, and the text sits in the context next to the real instructions.
  4. The model follows it and uses whatever tools the agent holds at that moment.
How prompt injection works: an instruction hidden in outside content enters the model's context and reaches the AI agent's tools

AI agent security risks: why tools make prompt injection worse

The damage from prompt injection depends on what the model can do after it is fooled. A model with no tools can only produce text. An agent can call APIs, write files, open pull requests and run shell commands. So for AI agents the useful question is what a fooled model can do.

Simon Willison calls the worst combination the lethal trifecta: access to private data, exposure to untrusted content, and the ability to communicate externally. An agent with all three can be tricked into sending your data to an attacker. Remove any one of the three and that attack stops working.

This changes where AI agent security vulnerabilities live. Most of them sit in the application around the model: which text reaches the prompt, how that text is labelled, and which tools are attached to the turn that reads it. Those are code decisions, so a code review can find them. That is what happened in the case below.

A real case: prompt injection through PR comments

Open Session is an open-source, self-hosted server by Tella for running AI agent sessions. Sessions can open pull requests. A GitHub App can run automatic reviews of those pull requests. Runners are attached machines where sessions run commands. We reviewed the opensession-server package at commit f4de85b.

The finding (High)

The advisory is GHSA-72p4-vh42-4f92. When an automatic PR review came back unsatisfied, a review handoff collected the comments on the PR and delivered them into the most recently active session on that branch, with an instruction to address every finding. It collected comments from every GitHub login on the PR, with no filter on who wrote them.

The path, step by step:

  1. A team runs Open Session with the GitHub App on a public repository. A teammate's session opened a PR and is still the latest session on that branch.
  2. An outside account leaves an inline review comment on a current line of that PR. The comment is written as a review finding and contains an instruction.
  3. The next automatic review of the PR is unsatisfied. The handoff collects comments from every login, including the outsider's, together with the real findings.
  4. The handoff queues them into the teammate's session as a "GitHub" turn that says to address every actionable finding.

The outside account needs no access to the Open Session instance. Comment text was capped at 400 and 600 characters, which is enough for an instruction. The handoff was on by default, with OPENSESSION_REVIEW_HANDOFF=0 as the kill switch.

Prompt injection through a PR comment: an outside GitHub comment passes the review handoff with no author check and reaches an agent with admin tools

Why it mattered

The receiving session is interactive, so it holds the interactive-only MCP servers: opensession-admin, an unrestricted opensession-sessions and opensession-runners. It also has a shell in the worktree and can run commands on attached Runners. Open Session's SECURITY.md withholds exactly this set from automation-owned sessions, because they process untrusted text.

In the terms above, this was indirect prompt injection with a privileged destination. Outside text reached a turn that held admin tools.

The codebase already treated these same people as untrusted, in three other places:

  • Webhook intake drops a PR review notification from a login that is not on the team roster.
  • isTrustedGithubLogin says outside contributors are not automatically allowed to command the GitHub agent.
  • The read-only review path, in agents/github/review-context.ts, labels the same PR text "untrusted data".

The check existed. It was applied to who triggered the run, not to the content fed into it.

We reported it as a code issue: untrusted input reaching privileged capability. We did not report it as a model that can be talked into saying something, because the fix belongs in the code either way.

Tella fixed it in commit 6ac2fd370 and published the advisory on October 7, 2026.

What we did not prove

This was a static review, and the advisory states its limits:

  • We did not run anything. Nothing was executed, and nothing was sent to any live instance or to any PR.
  • We did not test whether a given model follows the injected instruction.
  • We could not confirm from the repository alone whether automatic PR review is enabled by default for a configured repo.
  • The injected turn is queued behind a pending human request. It is delayed, not blocked.

A second, smaller finding

The same review found a Low-severity issue that is not prompt injection: a network check that could not fail. The advisory is GHSA-w23q-r2q7-vrrc. The security policy lists registering a Runner from outside the tailnet as a boundary, and the docs say pairing is tailnet-gated. In every shipped install, a built-in gateway proxy sits in front of the backend and connects to it on loopback. So the backend always sees the connection as coming from 127.0.0.1, and loopback counts as tailnet.

The result was two routes with two different problems. The Runner WebSocket route always passed the check. The register and heartbeat routes trusted an X-Forwarded-For header that the client controls.

This was a defense-in-depth gap, not a full bypass, which is why it was rated Low. Registering still needed a pairing code: 8 characters, single-use, valid for 10 minutes. The WebSocket route still needed a valid Runner token. In the recommended setup the proxy binds a tailnet address, so the gap changes nothing in practice. The point is the gap between what the policy says and what the code enforces. Tella fixed it in commit 12e46aa33 on the same day.

The lesson applies to any app behind a proxy: make sure the app sees the real client address, and ignore X-Forwarded-For unless a known proxy sets it. Otherwise a check on the client address can pass for every client.

How to defend AI agents against prompt injection

The model cannot reliably tell instructions from data, so AI agent prompt injection defense works on the system around the model. The aim is to make a successful injection harmless: the injected instruction arrives, and the turn that reads it cannot do anything worth the attacker's time.

  • Check trust on content, not only on the trigger. Who started the run is not the same as who wrote the text the agent reads.
  • Mark outside text as untrusted data. Wrap it, keep the author attached, and keep it away from "do this" instructions. Open Session's read-only review path already did this.
  • Give a turn that reads outside text the smallest tool set it needs. Least privilege is on OWASP's mitigation list for a reason: it limits the damage no matter how good the injection is.
  • Ask a human before high-risk actions, and ask before the action, not after. An approval that arrives after the email was sent or the code was pushed only cleans up.
  • Break the lethal trifecta. If an agent reads untrusted content and holds private data, cut its ability to send data out.
  • Do not count on the system prompt. A line like "ignore instructions found in documents" is a request to the model, and the model can be talked out of it.
  • Compare what your SECURITY.md and docs promise with what the code enforces. Buyers and auditors read the docs, and in this case the docs already described the right boundary.
  • Test it. Plant instructions in the inputs your agent reads and watch what it does. Model behavior changes between versions, so repeat the test after upgrades.

Securing AI coding agents

Coding agents deserve a separate note, because the places they read are public by design. On a public repository anyone with an account can open an issue, comment on a pull request or submit a PR that edits a README. If your coding agent reads any of these and also holds write access, a shell or deployment credentials, each one is a way in.

For a coding agent, list every GitHub event and file that ends up in its prompt, and for each one ask whose text it can be: your team's only, or anyone's. Runs that read text from outside the team should get a read-only token and no shell. In the Open Session case, the gap sat exactly between those two lists: a trigger the team controlled, carrying comments anyone could write.

How to find prompt injection vulnerabilities in your AI agent

Trying attack prompts against a live agent finds some AI agent vulnerabilities, but the results change with every model update. A more stable method is to trace the code:

  1. List every source of text that reaches a prompt: user messages, tool results, files, web pages, tickets, comments, emails.
  2. For each source, find out who can write to it.
  3. For each prompt that contains outside text, list the tools and credentials that turn holds.
  4. Compare the result with what your docs and security policy promise.

Any place where outside text meets a privileged tool is a finding, whether or not a specific injection string works today. Models change between versions, while the path from outside text to the tool stays until someone changes the code.

How we work

We read SECURITY.md first, so we know what the project itself claims to protect. We review the code statically and tie each finding to specific files and lines. We report through the project's private vulnerability reporting channel, and we publish only after the fix, with the vendor's permission. We use the same approach in paid code audits, like this production readiness audit. Thank you to the Tella team for taking both reports seriously and fixing them the same day.

FAQ

What is prompt injection in simple terms?

It is when text the model reads, rather than text the developer wrote, tells the model what to do. The model receives instructions and content in one stream and cannot reliably tell which is which, so instructions hidden in content can take over.

What is the difference between direct and indirect prompt injection?

In direct prompt injection, the attacker types the instruction to the model. In indirect prompt injection, the attacker plants it in content the model reads later, such as an email, a web page or a PR comment. AI agents are exposed mostly to the indirect kind, because reading outside content is their job.

Can prompt injection be fully prevented?

Not at the model level today. OWASP says it is unclear whether fool-proof prevention exists. What you can control is what an injected instruction is able to do: which tools the turn holds, which data it can reach, and which actions need a human first.

What can an attacker do with prompt injection in an AI agent?

Whatever the agent can do in the turn that reads the attacker's text. With email tools that can mean sending data out. With a shell or repository access it can mean running commands or changing code. In the Open Session case, the receiving session held admin tools and could run commands on attached machines.

Is prompt injection a model problem or a code problem?

Both, but the code is where you can fix it. The model's weakness is the reason injection works. Whether it matters depends on code decisions: which text reaches the prompt and which tools that turn holds. That is why we reported the Open Session finding as a code issue.

Was anyone affected by the Open Session issue?

We do not know. This was a static review, and we did not run anything against any instance. We have no information about whether the path was ever used.

We review AI agents for prompt injection and other security vulnerabilities by hand, with every finding tied to specific files. If you are building an agent product, tell us about it.