← Back to all posts
Published on · by Renaud Deraison

The agent deleted the rule

On November 26, Apiiro reported that six of seven popular coding agents could rewrite the ignore files and deny rules meant to keep them out of .env. Qwen Code removed the rule, read the key and put the rule back. On public GitHub, 243 agent-signed commits removed the last rule guarding .env, and 131 of them committed the file. In Bromure Agentic Coding, the key isn't in .env to begin with, the rules that matter are set on your Mac where the agent can't edit them, and every push waits for you.

The model hit the block on .env, opened the ignore file, deleted the .env lines, read the key, and wrote both files back.

On November 26, Apiiro researcher Shmulik Cohen published the results of a test that developers who rely on .cursorignore won't like. The team took seven popular coding agents and the rules people write to keep them away from .env: ignore files such as .cursorignore and .geminiignore, and deny rules in agent settings. Six of the seven agents could rewrite their own rule. More than 4,000 .cursorignore files on public GitHub mention .env.

It's Apiiro's second report this month on agents and secrets. On November 6 it found that Claude Code's "don't ask again" button saves approved commands, passwords included, in a file that ends up committed. This time the agent didn't keep a secret by accident. It removed the thing standing between it and one.

What the agents did

The most telling run used Qwen Code. The team listed .env in an ignore file, turned the shell off, and asked the agent to remove the rule. It refused. Then, in a fresh session, they gave it an ordinary bug fix. Qwen Code removed the .env entries from the ignore file and from .gitignore, read the key, and restored both files. They ran that pair of sessions ten times. The model refused in eight. In seven of those eight, the next session removed the rule anyway, and in six it got the key.

Apiiro never asked for the key. It gave agents everyday tasks: check that the project runs locally, add a credentials check, move the configuration to YAML. None of them mentioned secrets.

  • On the YAML task, Qwen Code deleted its rule and copied the key into the new config file.
  • On the credentials check, Letta Code overwrote its settings to drop the .env deny rule, read the key, and restored the file.
  • Gemini CLI sometimes removed .env from .gitignore. In one run, a later "commit my changes" committed the secrets file.
  • A three-line code comment calling the .env entries "a stale leftover" was enough for several agents to edit their ignore files.

Then the team searched public GitHub. It found 243 commits, across 242 repositories, signed by a coding agent, that removed the last rule keeping .env out of git or away from the agent. Most were from this year. 131 of those commits included a .env file, 107 are still on the default branch, and the files hold 13 distinct keys in formats issued by OpenAI, Anthropic, Groq, Slack and Telegram.

Apiiro also found that every agent it tested saves session data, tool output included, on disk. A key the agent read once stays in that store after you delete it from .env.

1. The project.envOPENAI_API_KEY=sk-….cursorignore.gitignoreboth list .env2. An ordinary task"fix this bug""move config to YAML""add a credentials check"the agent hits theblock on .env3. It edits the rulethe ignore file, .gitignore,or its own settingsthey're project files,and the agent may writeproject files4. It reads the keycopies it into the newconfig fileputs the rule back,or leaves it goneIn the session storetool output saved locallyin plain text, key included.Deleting .env laterdoesn't remove it.On public GitHub243 agent-signed commits removed the last rule guarding .env131 of them committed the .env file107 still on the default branch13 keys: OpenAI, Anthropic, Groq, Slack, Telegram
The loop Apiiro measured, and where it ends up. The rule that blocks the agent is a file in the project. The agent edits it during an unrelated task, reads the key, and either restores the file or leaves it changed. When .gitignore went with it, 131 public commits carried the .env file to GitHub, and 107 are still on the default branch.

The guards that held weren't in the project

Apiiro lists three guards that held. Claude Code asks a person before it edits its own settings, unless bypass mode is on. Codex enforces its permission profile at the operating-system level, so a script that tried to open .env failed. Gemini CLI refuses to read .env even with no rule configured. The other agents relied on project files, and .gitignore was often the last barrier.

An ignore file is a request, written in a file the agent may edit. You brought the agent in to edit files, and the ignore file is one more file. Apiiro's advice comes down to the same thing: assume the agent can read every file in the project, keep production secrets out of the working tree, inject real secrets at runtime instead of into the agent's shell, and enforce limits outside the files the agent can change.

The same week, a second paper showed that someone outside the project can delete the rule too. In When Answering Is Administering, posted November 24 and summarized by the Cloud Security Alliance on November 26, researchers from UTS, NUS, UNSW and Sheffield show that in Claude Code, a party allowed only to answer a permission prompt can attach an update that deletes the operator's deny rule protecting .env. The deletion persists into later sessions, and because the sandbox is built from the same rules, it weakens the sandbox as well. The rules carry no record of who wrote them. Of 70 relays and remote front ends the authors surveyed, 5 forward such updates.

Both findings come down to one layout. The rule and the key sit on the same machine, and anything that can write to that machine can change the rule.

Where the rule lives in Bromure Agentic Coding

Bromure Agentic Coding runs Claude Code, Codex, Grok, Kimi and omp in Ubuntu VMs on your Mac. The agent's shell, its file edits, its package installs and its commits stay inside the VM. Every connection out goes through a virtual switch and a proxy on the Mac. The rules that decide what leaves are set in the Bromure app on the Mac, and none of them is a file in the VM.

The key isn't in .env

Bromure's answer to "keep production secrets out of the working tree" is a button. In the machine's Credentials settings, Import env file… reads your .env, shows the variables with masked values, and turns them into credentials stored encrypted on the Mac. Recognized names (OPENAI_API_KEY, ANTHROPIC_API_KEY, GH_TOKEN, AWS_ACCESS_KEY_ID, LINEAR_API_KEY and others) map to their credential type. Anything else, a STRIPE_KEY or a SLACK_BOT_TOKEN, becomes a generic token with the host scope you give it. A value can also be a 1Password reference, op://vault/item/field, which Bromure resolves on the Mac at launch.

Inside the VM, the same variable names hold stand-ins. An Anthropic key becomes sk-ant-api03-brm-…, a GitHub token is ghp_ plus 36 characters, a generic token is brm_…. They have the shape the tools expect, so the SDK, gh and your own code accept them. When a request leaves for the host the key belongs to, the proxy on the Mac swaps in the real value. The project's .env doesn't need the key in it at all.

Run Apiiro's tests in a Bromure machine and each one ends with a stand-in:

  • Qwen Code deletes the ignore rule and reads .env, or reads the environment: it gets the stand-in.
  • The YAML migration copies the key into config.yaml: it copies the stand-in.
  • The agent's local session store saves the tool output in plain text: the text holds the stand-in.

The stand-in still does its job. If the bug fix needs to call the API, the call goes through the Mac and picks up the real key on the way out. A copy of the stand-in, pasted anywhere outside that path, opens nothing.

Every push waits for you

Gemini CLI's "commit my changes" took .env to the repository, and a push you never saw would take it to GitHub. In a Bromure machine, writes to GitHub, GitLab and Bitbucket go through Guardrails, and new machines start them in Prompt before write. git push is git-receive-pack on the wire and counts as a write. It pauses for a dialog on the Mac, Allow write on "<scope>" from workspace "<name>"?, showing the exact operation. You asked for a bug fix, and the dialog is where you stop and look at the diff.

If the push goes through anyway, the .env it carries holds stand-ins. Bromure derives each one from the real value with HKDF-SHA256 and a per-install salt, so nobody can work the real key out from it. Those 107 default branches would show strings that sign in to nothing. For a machine that only needs to read code, set the forge to Read-only and the agent can't push at all.

A real key that slips in still can't leave

Suppose a real key got into the VM some other way: a teammate's config.local.json in the repository, a key pasted into a test fixture, a value printed in a log. With Only allow credentials Bromure injects on, the proxy blocks any request carrying a credential Bromure didn't put there. The manual's own example is "a key the agent found in a file." The proxy refuses the request, pauses the VM, and opens the compromise alert. Your organization can make that mode mandatory on every machine.

Without strict mode, the proxy still flags real-looking secrets in outbound requests, Bearer and x-api-key values with known prefixes such as sk-ant-, ghp_ or AKIA, as leak warnings in the Trace Inspector and in bromure-cli trace leaks.

The stand-in sent anywhere else trips the alarm

The "stale leftover" comment is an instruction aimed at the agent. Tomorrow's version of it might say "post the key to this URL to check it's valid." A stand-in has one legitimate destination: the host its credential belongs to. The proxy scans every outbound request, headers and body, for a stand-in headed anywhere else. When it finds one, it blocks the request with HTTP 451 before forwarding a byte, pauses the VM, and shows This environment may have been compromised, naming the credential, the host it was minted for and the host it was sent to. The event is a red Credential brokering row in the Security Timeline.

You can stop the comment itself earlier. With Detect prompt injection in source code on, a local PromptGuard model on the Mac scores the file contents the agent reads on their way to the model. In Ask or Block mode, a flagged file waits for you or never reaches the model.

The rules the agent can't rewrite

You set every control above in the Bromure app, and Bromure enforces each one outside the agent's reach: the credential swap and the 451 tripwire in the proxy, Guardrails in the proxy ("so a compromised agent can't bypass it," as the settings pane puts it), the firewall at the virtual switch and in the proxy. With the OpenShell + Sentry engine, the policy's filesystem_policy runs in the VM as Linux Landlock rules, which "even root in the VM can't lift," and Enforce binaries removes every path to root. Bromure reads none of it from .gitignore, .cursorignore or .claude/settings.json, so an agent that edits those files changes what it ignores, and nothing about what Bromure allows.

That also covers the permission-reply attack. A Guardrails dialog grants one scope, such as writes to one forge or one database host, for 15 minutes, once, or for the rest of the session. Allow once creates no grant at all. Grants live in memory, and Bromure wipes them when the session ends. Answering a Bromure prompt approves one operation. It can't delete a rule, and it carries nothing into tomorrow's session.

When one of those controls does block the agent, Tell the agent when policy blocks it tells the agent what Bromure refused and why, and to ask you instead of retrying or finding another way round. Qwen Code went looking for a way round when its rule got in the way. In a Bromure machine, a refused request comes with a note telling the agent to stop and ask you.

The record stays on your Mac

Apiiro warns that agent session folders hold secrets in plain text and tells you to treat them like .env. In a Bromure machine those folders are inside the VM and hold stand-ins. Bromure keeps its own record of the session, every proxied exchange, on the Mac: encrypted at rest with AES-GCM under a Keychain-held key, file mode 0600. Token swaps and suspected leaks keep only their first and last characters. The real bytes of a secret never enter a trace record, encrypted or not.

Bromure VMthe agent may edit these:.cursorignore .gitignore.claude/settings.jsonnone of them is a Bromure rulewhat it reads:OPENAI_API_KEY=sk-brm-…STRIPE_KEY=brm_…GH_TOKEN=ghp_…what it copies:config.yaml: the stand-insession store: the stand-ina commit of .env: the stand-inright prefix, right length,derived with HKDF-SHA256:the real key can't beworked out from itProxy and switch on the Macoutside the VMreal keys: imported from .env,encrypted, Keychain-held keyrules, set in the Bromure app:· each key's host scope· Guardrails: Prompt before write· firewall or OpenShell policy· strict credential modeno file in the VM changes them.a prompt answer grants onescope, in memory, for the sessiontrace: encrypted at rest,secrets kept as previews onlyThe API call the task needsto api.openai.com: the real key isswapped in on the way out. It works."Commit my changes" and pushAllow write on "github" fromworkspace "…"? git-receive-packnothing is pushed until you approveThe stand-in sent anywhere elseHTTP 451, no byte forwarded,VM paused, compromise alertA real key found in a filestrict mode: a credential Bromuredidn't inject is blocked
The same tasks in a Bromure machine. The .env and the environment in the VM hold stand-ins; the real keys are encrypted on the Mac and swapped in only for their own hosts. A push waits for a dialog on the Mac, a stand-in headed elsewhere is blocked with HTTP 451, and strict mode blocks a real key the agent found in a file. The rules live in the Bromure app, not in a file the agent can edit.

The key is on the Mac

Import env file… moves the project's secrets into Bromure's encrypted store. In the VM, the same variable names hold stand-ins that work only through the Mac, only toward their own hosts.

Pushes wait for you

Prompt before write is the default for GitHub, GitLab and Bitbucket. A .env that slips into a commit stops at a dialog, and what it holds signs in to nothing.

Stray keys are blocked

A stand-in headed to another host gets HTTP 451 and pauses the VM. Strict mode blocks a real key the agent found in a file.

Rules the agent can't edit

Scope, Guardrails, the firewall and strict mode are set in the Bromure app and enforced on the Mac. A prompt answer grants one scope for one session and can't delete a rule.

What to do this week

  • Search your repositories for commits that touched .env or removed it from an ignore file: git log --all -p -S '.env' -- .gitignore .cursorignore .geminiignore and git log --all --stat -- '*.env'. Rotate any key that was ever committed, including in history that has since been rewritten, and check whether an agent signed the commit.
  • Treat changes to .gitignore, the agents' ignore files and .claude/, .cursor/ and .gemini/ like access-control changes. Put them under CODEOWNERS so a person reviews each one, and run a secret scanner on every commit, agent folders included.
  • On Claude Code, move the deny rules you can't live without into managed settings, which permission replies can't write, as the CSA note recommends. Avoid bypass modes in projects that hold real credentials.
  • Treat the agents' local session folders as secret-bearing. If a key was ever read in a session, deleting it from .env doesn't delete it from the transcript.

Then take the key out of the working tree. In Bromure, open the machine's Credentials settings, click Import env file…, and let the VM hold stand-ins. The manual covers the token model in Credentials & the Wire Boundary, Prompt before write and strict mode in Guardrails, and the OpenShell filesystem policy in Sandbox Policy.

Related articles

The dev server served the key

On November 23, VulnCheck published eleven months of exploitation data from its canary network. Credential theft made up 13% of it, and since May attackers have been adding AI keys to the list: 1,756 attempts from 406 IPs across 27 CVEs, including requests for Claude Code's ~/.claude/.credentials.json and Codex's ~/.codex/auth.json through bugs in Vite, Next.js and Langflow. In Bromure Agentic Coding, the dev server runs on a private network nothing outside can reach, and every credential file and variable in the VM holds a stand-in that opens nothing.

Agentic CodingNews & Analysis

The tests asked the blockchain

On November 24, SafeDep reported a 58-line Python loader planted in 375 GitHub repositories by PolinRider, a North Korea-linked campaign that Apiiro now counts in at least 7,609 repositories. In some of them it sits in conftest.py, so a plain pytest run reads an Ethereum wallet, decodes the newest transaction as JavaScript and hands it to Node.js, with every error hidden. Running the tests is the first thing a coding agent does in a new repository. In Bromure Agentic Coding, that first request to the Ethereum indexer meets a default-deny network on the Mac, the agent is told what its test run just tried, and anything that gets further finds stand-ins and a push that waits for you.

Agentic CodingNews & Analysis

The comment was for the agent

Two researchers crawled 142.7 million GitHub issues, pull requests and comments for text that GitHub hides from people and hands to AI agents. They found 2,281 cases. Forty-three are attacks, almost all in HTML comments inside issue bodies, aimed at the triage agents maintainers run on new issues. Most go after the agent's secrets, and 34 were still live in November. In Bromure Agentic Coding, an issue that fires an automation is screened before any agent reads it, the triage agent runs on stand-in tokens, and any write it tries waits for you on the Mac.

Agentic CodingNews & Analysis