#Security#Supply Chain#AI Agents#GitHub Actions#Testing
A Guard That Stops Too Much Gets Switched Off
Agent instruction files like AGENTS.md can tell a coding agent which package to install. I added a check to seven repositories, watched the first version fire on ordinary setup steps, and narrowed it to the one thing an attack needs.
Every repository I maintain for VEAI LAB. has a file that a coding agent reads
before it touches anything: AGENTS.md, CLAUDE.md, sometimes a
.cursorrules. These files describe how the project works, which checks to
run, and what not to do. They are useful. They are also files that run with the
agent’s permissions, change what gets installed, and are often copied in from
another project. Nobody reviews them the way they review code.
In October a preprint made that gap concrete. Package Hallucination Attacks on Coding Agents through Prompt Injection in Rule Files (not yet peer reviewed) reports that an instruction planted in a rule file can make a coding agent replace a real dependency with an attacker’s package. The authors also describe a method that rewrites the planted text automatically, and report high success rates across different combinations of models and agents.
So I added a check. This post is about the first version, which was wrong in a useful way.
What the check stops
The rule I wanted was simple: an instruction file must not tell the agent to fetch something by name. Dependencies belong in the manifest and the lockfile, where code review and Dependabot can see them. An instruction file has no reason to name a package.
The check, now published as rule-file-guard, fails a commit or a pull request when one of those files contains:
- an install that names a package:
npm install left-pad,pip install requests,uv add httpx,cargo install … - a change of registry:
--index-url,--extra-index-url,registry=,npm config set registry - a download piped into a shell:
curl … | bash
It runs in two places: as a pre-commit hook, so the mistake never leaves the machine, and as a GitHub Actions job, so a pull request from anywhere gets the same answer.
The first version stopped npm install
My first draft treated any install command in an instruction file as suspicious. That sounds safe. I ran it against the seven repositories (the care apps, CareQuest and CareReady among them, plus the sites and research code) before merging anything.
It failed in three of them. Not because anything was wrong. Their instruction
files said things like “run npm install, then npm test”, or “pip install -r requirements.txt before running the pipeline”. That is the normal way to
tell an agent, or a person, how to set up a project. Those commands install
exactly what the manifest already lists. They are the opposite of the attack.
A check that fires on that will be switched off within a week, and then it stops nothing. Worse, it teaches everyone that its red mark means “ignore this”. So the first version was not too strict. It was useless.
Narrowing to what the attack needs
The attack in the paper needs the agent to fetch a specific package the attacker chose. That means a name has to appear after the install verb. So the check now looks at what follows the verb:
- nothing, or only flags:
npm install,npm ci→ allowed - a file or a directory:
-r requirements.txt,-e .,./packages/core→ allowed - anything that looks like a package name → stopped
Registry changes and curl | bash stay blocked, because there is no ordinary
reason to put either in an instruction file. When a line really is intended, a
reviewer can add rule-file-guard: allow to it. That keeps the exception
visible in the diff instead of hidden in a config file.
Keeping both lists in the tests
The tests carry two lists, and the second matters as much as the first.
- Lines it must stop: 17 examples, from
pnpm add @acme/http-utilstowget -qO- … | sudo sh. - Lines it must let through: 11 examples, including every setup line that tripped the first version, and a sentence like “npm installs only what package.json lists”, which contains the words but is not a command.
Before trusting the tests I broke the check on purpose, removing the rule that
skips -r and -e arguments, and confirmed the “let through” list failed.
A test suite that stays green when the code is broken is not checking anything.
Then I ran the check on all seven repositories again. Every current instruction file passed. Adding one planted line made it fail, and removing the line made it pass, in each repository.
What it does not do
This is a pattern check, and I want to be plain about its edges.
- It reads only the file names it knows about.
- It matches commands. An instruction written in prose (“add the package foo-utils before you start”) or hidden in encoded text gets through.
- It knows nothing about the package itself.
It is one cheap layer. The others are still needed: review changes to instruction files like code, keep dependencies in a lockfile, and be careful about what you copy in. The same week, I read two agent plugins I had installed from elsewhere to confirm neither carried hooks, MCP servers, or scripts that would run on their own.
The part that transfers
The lesson I keep relearning is not about agents. It is about alarms. A check earns trust by being quiet when things are normal. If it cannot tell setup from attack, people stop reading it, and the one time it is right, nobody looks.
The same week I fixed a latency alert in my own monitoring that had fired every week with the identical value. It was computing a 95th percentile from six requests. It now refuses to judge with fewer than twenty. Different code, same rule: say “not enough data” before you say “something is wrong”.
The other VEAI LAB. products are built the same way — CareReady keeps a family’s checklist on the device because families use it in a hospital corridor with poor signal, and CareQuest lets a caregiver skip a day without the app treating it as failure.
If you are hiring for platform or developer-tooling work where the interesting part is making checks people actually trust, I am available: hire-veai.com.
Written with AI assistance (Opus / Claude). The project and the decisions in it are mine.

Thanks for reading — built with care, for caregivers.