Ghostcommit Hides Prompt Injection in PR Images

Malwarebytes · Medium sophistication
Last updated July 30, 2026

Researchers demonstrated “Ghostcommit,” a method to trick AI code-review assistants using hidden instructions embedded inside an image added in a pull request. The AI agent may later follow those hidden instructions to read sensitive files and leak secrets back into source code, even when the pull request looks normal to human reviewers. The risk depends heavily on the coding tool (“harness”) and its permissions, not just the AI model.

How the attack worked

Ghostcommit is a proof-of-concept technique where an attacker submits a pull request containing a harmless-looking image alongside a repository guidance file, such as an AGENTS.md, that tells an AI coding agent to trust the image. The instructions themselves are hidden inside the image file rather than in visible text. A human reviewer scanning the code changes has little reason to open the image, so the pull request appears ordinary. Later, when the AI agent works on an unrelated task and processes that image, it follows the hidden instructions, reads sensitive files, and writes the extracted secrets back into the code in an obfuscated form.

Why it succeeded

The technique works because prompt injection is no longer limited to text. Images and other multimodal inputs can carry instructions that AI agents interpret and act on, even when nothing in the visible diff looks suspicious. The pull request review process is built around human judgment of code changes, not around inspecting embedded content in attached files. This gap between what a human reviewer checks and what an AI agent later reads creates the opening the attack relies on.

What determines success or failure

According to the research, whether the attack actually results in secret theft depends heavily on the specific AI coding tool, or harness, and its guardrails and permissions, more than on the underlying language model. The harness decides which files to load, which conventions to trust, and what guardrails to apply, so the same model can behave very differently depending on the tool that runs it. Some harnesses refused to exfiltrate secrets during testing, while others did not.

What to watch for

  • Pull requests that include non-text attachments, like PNG images, without a clear functional need
  • Repository policy or guidance files that instruct tools or agents to trust or load content from images
  • AI agents attempting to access credential or configuration files unrelated to the task at hand
  • Guidance files added or modified alongside seemingly unrelated visual assets

Building resistance

Organizations using AI coding agents for code review or development tasks should treat pull requests, including any attached images or policy files, as a potential path for attacker-controlled instructions aimed at the AI agent rather than the human reviewer. Practical steps include restricting the secrets and files an agent can access, inspecting non-text attachments before merging, and monitoring agent behavior for unusual attempts to read credentials or config files. Teams should also evaluate coding tools based on their guardrails and permission models, since tool configuration can matter as much as the model itself in determining whether an injection attempt succeeds.

Key findings

  • Hidden instructions can be embedded inside an image file (PNG) and referenced by a repository guidance file (AGENTS.md) so an AI coding agent follows them later.
  • A pull request can look ordinary to humans while still delivering attacker-controlled instructions to an AI agent.
  • The demonstrated outcome is secret theft: the agent is induced to read sensitive files and write the secrets back into code in an obfuscated way.
  • Whether the attack succeeds depends more on the AI tool/harness and its guardrails/permissions than the underlying model (e.g., Claude Sonnet behaved differently across tools).
  • Some harnesses (e.g., Claude Code) refused to exfiltrate secrets in the researchers’ testing.

Who’s being targeted

  • Commonly targeted roles: Developers, Engineering leadership, DevOps, Application Security, Code reviewers.
  • Affected industries: Software development, Technology, Any organization using AI coding agents for code review.
  • Attack channels: github.
  • Impersonated: Open-source contributor / internal developer.

Red flags to watch for

  • Non-text attachments (e.g., PNG) included in PR without a clear need
  • Repository policy/guidance files instruct tools/agents to trust or load content from images
  • AI agent shows unusual attempts to access credential/config files unrelated to the task
Try Mirage

Mirage safely runs attacks like this one against your own team, so you find out what happens before a real adversary does.

Get a demo

Frequently asked questions

What is the Ghostcommit attack?

Ghostcommit is a technique where an attacker embeds hidden instructions inside an image file added in a pull request, referenced by a repository guidance file, so an AI coding agent follows those instructions during a later task.

How does Ghostcommit steal secrets?

Once the AI agent processes the referenced image during a later task, it can be induced to read sensitive files and write the secrets back into the code in an obfuscated form, even though the pull request itself looks ordinary to human reviewers.

Does Ghostcommit work against every AI coding tool?

No, success depends more on the AI tool or harness and its guardrails and permissions than on the underlying model. Some harnesses refused to exfiltrate secrets in testing while others behaved differently with the same model.

How can teams defend against image-based prompt injection?

Key defenses include restricting access to secrets, inspecting non-text attachments like images in pull requests, and monitoring AI agents for unusual attempts to read credentials or configuration files.

Read the video transcript

A pull request introduces a harmless-looking PNG and an AGENTS.md file, and your AI code reviewer says, "Looks good, ready to merge." Here’s the trick: Ghostcommit hides prompt injection inside that PNG. AGENTS.md tells the AI agent to trust the image, and later the agent quietly follows those hidden instructions. In the demo, when the agent later works on a normal task, it reads secret config files and writes those secrets back into the code in obfuscated form. To you, the original PR still looks totally routine. Your move: before you merge, question any PR that adds AGENTS.md or similar guidance files plus unexplained images, and get them reviewed with security, not just code review.

Similar attacks

TikTok Resin Art “DM to Order” Scam

TikTok Resin Art “DM to Order” Scam

Scammers on TikTok are impersonating resin artists by reposting stolen videos and telling viewers to “DM to order.” After moving the conversation into direct…

July 24, 2026