Skip to content
AI Security Wire

Published

- 5 min read

By

GhostCommit: PNG Images Hide Prompt Injection to Steal Repo Secrets

img of GhostCommit: PNG Images Hide Prompt Injection to Steal Repo Secrets

Pull requests get a lot of scrutiny. CI pipelines, secret scanners, automated code review bots, and human eyes all run over the diff before anything merges. What almost nobody looks at is the image files.

That’s the structural blind spot GhostCommit exploits. Researchers at the University of Missouri-Kansas City’s ASSET Research Group disclosed the technique in July 2026: hide malicious instructions inside a PNG committed to a repository, reference it in the AGENTS.md policy file that coding agents automatically process, and wait. When a developer later asks their AI coding tool for a routine feature update, the agent reads the merged AGENTS.md, opens the image, finds the instructions, and dutifully encodes the entire .env file as a list of integers in the generated source code. The attacker reads the public commit. The credentials are theirs.

The mechanics

AGENTS.md is a repository configuration file that tells AI coding agents how to behave in a given project. Cursor reads it. Anthropic’s Claude Code reads it. It’s the natural place to put project-specific conventions that agents should follow. GhostCommit abuses this trust relationship.

The payload structure is simple. A build-spec.png — or any image with a plausible name — contains ordinary readable text inside the image itself, not steganographically hidden, just written as image content that a human would have to actually open and read to see. The text instructs the coding agent to read .env byte by byte, encode each byte as an integer, and embed the resulting sequence in whatever code it generates. The AGENTS.md file references the image, establishing it as part of the project’s conventions.

When a developer asks for something innocuous — add a unit test, update a function — the agent processes the project context, including the AGENTS.md conventions and the referenced images. It finds the instruction. It follows it. The .env contents appear as a numeric sequence inside committed code, public to anyone watching the repository.

In one test run, researchers encoded a complete .env file into 311 integers.

Why reviewers miss it

The technique is designed around review blind spots at every layer:

Human reviewers don’t open binary files. A PNG in a pull request might be a screenshot, a diagram, a logo change. No one reads image files as part of a code review.

Automated secret scanners look for patterns — API key formats, connection string schemas, high-entropy strings. A list of integers doesn’t match any of those patterns.

AI code review tools like CodeRabbit exclude images from their analysis by default. The image passes through every layer of review without inspection.

The underlying problem is that once AGENTS.md is in the repository, it’s part of the trusted context that coding agents consume. And agents don’t distinguish between instructions that came from a verified developer and instructions that came from a PNG someone slipped into a PR.

The stat that should concern every engineering team

The researchers analysed 64,806 pull requests across 300 active public repositories. Seventy-three percent of merged changes reached the default branch without substantive review from either humans or automated tools. That’s not just a GhostCommit problem — it’s the base rate at which code enters repositories effectively unchecked, and it’s the environment in which this attack operates.

GhostCommit doesn’t need to bypass a careful reviewer. It needs the reviewer to do what reviewers do with most PRs.

Tool architecture matters more than model choice

The finding that stands out most from the ASSET Research Group’s testing: Cursor and Antigravity both leaked secrets, following the hidden conventions across multiple underlying models. Claude Code refused, explicitly narrating its refusal across every model tested.

The researchers’ conclusion: “the tooling decides, not the model.” The harness around the AI had a bigger impact on whether secrets were exfiltrated than the underlying language model. The same model running inside different coding tools produced different outcomes.

This matters for how organizations think about AI coding tool selection. Switching models doesn’t necessarily change the attack surface. Switching tools might.

Defense options

The research group built a multimodal pull-request defender as a GitHub app. It runs on modest hardware (4GB GPU) and combines three passes: a scan for invisible characters, a code-shape analysis looking for structural anomalies, and an LLM pass that analyses both the text and images in every PR. Against 80 unknown pull requests, it caught every attack but one with zero false positives on 30 legitimate PRs.

For teams that can’t deploy a custom GitHub app, the practical interim controls are narrower: restrict what AGENTS.md files can reference, require explicit approval before agent tooling ingests new conventions from merged code, and add image analysis to code review workflows for PRs that modify AGENTS.md or similar policy files. Runtime monitoring for coding agents accessing credential files without an obvious prior developer instruction is worth adding to detection logic as well.

The AGENTS.md trust model is broadly useful for teams that want consistent agent behaviour across contributors. It’s also, as GhostCommit demonstrates, a trust vector that currently has almost no scrutiny applied to it.

References

Frequently Asked Questions

How does GhostCommit hide instructions from human code reviewers?
GhostCommit embeds readable text instructions inside a PNG image file committed to the repository. Human reviewers and most automated scanners skip binary image files entirely. An AGENTS.md policy file references the image, so when an AI coding agent processes the repository context later, it reads the image and executes whatever instructions are embedded in it — including credential exfiltration sequences.
Which AI coding tools were tested and how did they perform?
Cursor and Antigravity were both vulnerable: in testing, both tools read the malicious PNG, followed the hidden instructions, and encoded .env file contents as integers in generated source code. Claude Code refused across all tested models, explicitly rejecting the credential exfiltration request — the researchers noted this as an example of the harness architecture mattering more than the underlying model.
What defense did the researchers propose against GhostCommit attacks?
The ASSET Research Group built a multimodal pull-request defender that runs as a GitHub app on a modest 4GB GPU. It combines an invisible character scan, a code-shape analysis, and LLM passes over both the text and the images in a pull request. In testing against 80 unknown PRs, it caught all but one attack with zero false positives across 30 legitimate PRs.