Blog
Researchers got Copilot CLI to read and send a .env file
The story: GitHub Copilot CLI vulnerability: Cryptographic Context Injection steals developer secrets · Adversa AI ·
Topics: AI tools
On 6 October 2026 Adversa AI showed GitHub Copilot CLI, in autopilot mode, reading a local .env.prod file for a web page and sending it out. GitHub says it is not a product vulnerability. What the attack depends on, and how teams can see what their agents read.
On 6 October 2026, researchers at Adversa AI published a demonstration in which GitHub Copilot CLI, running in its autonomous autopilot mode, fetched a web page, read a local .env.prod file and sent its contents to a server the researchers controlled. GitHub validated the report but said it is not a product vulnerability. For any team that lets coding agents work on developers' machines, it raises a plain question: which files did the agent read, and would anyone be able to tell afterwards?
What happened
The disclosure, as Adversa and The Register describe it:
- 17 September 2026: Adversa reported the attack chain to GitHub's bug bounty programme.
- By 1 October 2026: GitHub's triage team had validated the finding, declined to treat it as a vulnerability and ruled the report ineligible for a bounty.
- 6 October 2026: Adversa published the research, and The Register reported it the same day. CSO Online followed on 7 October.
The chain starts with the user asking Copilot CLI to fetch a web page. The page holds encrypted instructions, a short Python routine to decrypt them and two keys. To build the first key, the agent reads files from disk, such as the project's .env file, and folds their contents into the key string. That key fails on purpose. The second one works, and the decrypted instructions tell the agent to fetch another address, one that carries the harvested secrets out to the attacker.
Adversa says the whole chain took 28 seconds. After the first request no further interaction was needed, the user was shown no destination host, and nothing on screen indicated that files had left the machine. The researchers say they are not claiming to bypass a confirmation prompt: the attack needs autopilot mode and a model willing to follow the decrypted instructions. They used their own test setup and have withheld the working payloads.
The model mattered. Microsoft's mai-code-1.1-flash ran the full chain in 50% of attempts, while two GPT-5.6 models offered in Copilot refused the same payload every time. On a paid account with model selection set to Auto, Adversa says the router sometimes assigned the model that complied, without the user seeing which one.
GitHub's position, as quoted by The Register, is that the attack needs a user to direct Copilot CLI to fetch attacker-controlled or untrusted content and to confirm the action, and so is "not a product vulnerability". GitHub said it may make the behaviour stricter in future but had nothing to announce. Adversa disagrees and says the chain still works as described.
Not known yet: whether anyone has used the technique outside a test, which Copilot CLI version was tested, and whether GitHub will change anything.
What it means
The theft is, first of all, a read. Before a single byte leaves, a process the developer started opens a file on the laptop. The outbound request is the part network tools might see; the read happens on the file system, and in Adversa's demonstration nothing on screen showed it.
GitHub's documentation is clear about what full permissions mean. In autopilot, --allow-all (or its alias --yolo) grants every tool, path and URL at the start of a session, and the autopilot page warns that "this gives the CLI permission to make any changes it deems necessary". Reading files is a read-only operation, which the tool permissions page says is allowed automatically. Adversa adds that files outside the working directory were within reach too.
That makes the question afterwards hard. An agent reads files in a project folder all day, so a read of that folder is normal. What would stand out is a read of the secrets file in a session that began by fetching an outside page, or a read of folders the task never needed. Answering it needs a record of reads made at the time, on that machine, kept long enough to look back. Adversa's own first recommendation is a per-session trace of every tool call with its real arguments. Without one, a team can say which secrets were in reach, but not which were read.
What you can do
- Find out where autopilot runs with full permissions. Ask which developers use
--allow-allor--yolo, and on which machines. GitHub itself suggests running autonomous sessions in a local or cloud sandbox. - Take the web away from sessions that don't need it. The tool permissions page shows how to hide tools from the model:
copilot --excluded-tools='web_fetch, web_search'
- Keep secrets out of the folders agents work in, and rotate any key that sat in a project where an agent with web access ran with full permissions.
- Watch the secrets files themselves. On a Mac (macOS 13 or later),
esloggerprints Endpoint Security events; the terminal running it needs Full Disk Access:
sudo eslogger open > open-events.json
On Linux, an audit rule records every read of one file, tagged with a key you choose:
sudo auditctl -w /home/dev/project/.env.prod -p r -k agent-secrets
sudo ausearch -k agent-secrets -i
On Windows, object-access auditing on the folder writes reads to the Security log. Each has limits: eslogger keeps nothing unless you save its very busy output, an auditctl rule lasts until the next reboot unless it is added to the audit rules files, and all three are set up one machine at a time.
- Look for the sequence, not the payload. Adversa suggests alerting when untrusted content enters a session, code runs, local files are read and the agent then contacts an unrelated host.
Where ProofStream fits
ProofStream records which program opened which folder, when and on which machine, across Mac, Windows and Linux, and keeps that history searchable for months. In a case like this it would show whether the agent, or a shell or Python process, opened the project folder or folders outside it, and at what time; in folders a customer chooses, on Business Plus, it would also show the file's name, such as .env.prod. It wouldn't have stopped the read, and it doesn't see what was in the file or the request that carried it out. How it works.
Sources
- GitHub Copilot CLI vulnerability: Cryptographic Context Injection steals developer secrets
- GitHub Docs: Allowing GitHub Copilot CLI to work autonomously
- GitHub Docs: Allowing and denying tool use in Copilot CLI
- The Register: Zombie instructions on web pages could trick GitHub Copilot CLI into sharing secrets
- CSO Online: Encrypted instructions trick Copilot CLI to spill dev secrets
- Cybereason: Blue teaming on macOS with eslogger
- Wazuh documentation: how Linux audit rules work
Spotted a mistake? Tell us and we'll correct it.
Comments
No comments yet.