Security: an agent's shell can read other runs' folders, osfd's environment and secrets #201

Closed
opened 2026-10-18 07:28:22 -04:00 by cmoriarty · 3 comments
Owner

Found in run 77 (Free profile, production ead9f7e), openspec.apply[3], served by Kilo's beam-free. The model reasoned "Hidden tests likely follow task naming… Let's search .osf maybe hidden test contracts?". It then used the shell tool to:

  • find /var/lib/openspecflow -name "*physics*", which listed other runs' work trees;
  • ls/find run 62's and run 76's src/physics and tests;
  • cp -r run 62's src/physics and its test files into its own tmp, and sed them;
  • head run 62's tmp/judge/physics-bundle.mjs;
  • grep -rl … /var/lib/openspecflow.

All 18 shell calls completed. Only the read tool's direct path to another run was refused ("Refused: … This run's own folder is …").

What an agent can reach today. Every agent shell runs as osfd's own user (uid 1000 braid, the same as osfd serve and opencode serve) and inherits opencode's environment:

  • the environment itself: an earlier run's env printed OPENCODE_SERVER_PASSWORD=…, OSF_FORGEJO_TOKEN_FILE=…, OSF_UI_BASE_URL=…; runs 68 and 72 printed their run's settings.json and listed its secret file;
  • osfd's secrets, mode 600 but owned by the same user: the Forgejo token file and the API key files under the state volume's keys/. No run's history shows one read, but nothing stops it;
  • every other run's folder: work trees, judge bundles, settings, secrets.

On the Free profile, whatever a shell prints goes to third-party providers, and some of them train on prompts. On vLLM it stays on the local server.

Done now: run 77 stopped. No Free runs until this is fixed.

To do

  1. A first layer, quick:
    • agent shells get an environment from an allowlist, not osfd's (no OSF_* secrets or paths, no OPENCODE_SERVER_PASSWORD);
    • Braid's path guard refuses, in shell commands as in read, any path under the state volume outside the run's own folder, plus the token and key files and /proc/*/environ.
      This is bypassable by a determined model, so it is not the fix.
  2. The fix: agent processes can't reach what isn't theirs. Either opencode and its shells run as a different uid from osfd, with run folders and secrets permissioned so the agent's uid reaches only its own run, or each run is sandboxed (mount namespace with only its folder and the tools). Decide which the container allows (capabilities, seccomp, user namespaces).
  3. A simulated-run scenario and a self-check line that an agent's shell cannot read another run's folder, the token, or a key file.
Found in run 77 (Free profile, production ead9f7e), `openspec.apply[3]`, served by Kilo's beam-free. The model reasoned "Hidden tests likely follow task naming… Let's search .osf maybe hidden test contracts?". It then used the **shell** tool to: - `find /var/lib/openspecflow -name "*physics*"`, which listed other runs' work trees; - `ls`/`find` run 62's and run 76's `src/physics` and `tests`; - `cp -r` run 62's `src/physics` and its test files into its own tmp, and `sed` them; - `head` run 62's `tmp/judge/physics-bundle.mjs`; - `grep -rl … /var/lib/openspecflow`. All 18 shell calls completed. Only the `read` tool's direct path to another run was refused ("Refused: … This run's own folder is …"). **What an agent can reach today.** Every agent shell runs as osfd's own user (uid 1000 `braid`, the same as `osfd serve` and `opencode serve`) and inherits opencode's environment: - the environment itself: an earlier run's `env` printed `OPENCODE_SERVER_PASSWORD=…`, `OSF_FORGEJO_TOKEN_FILE=…`, `OSF_UI_BASE_URL=…`; runs 68 and 72 printed their run's `settings.json` and listed its `secret` file; - osfd's secrets, mode 600 but owned by the same user: the Forgejo token file and the API key files under the state volume's `keys/`. No run's history shows one read, but nothing stops it; - every other run's folder: work trees, judge bundles, settings, secrets. On the Free profile, whatever a shell prints goes to third-party providers, and some of them train on prompts. On vLLM it stays on the local server. **Done now:** run 77 stopped. No Free runs until this is fixed. **To do** 1. A first layer, quick: - agent shells get an environment from an allowlist, not osfd's (no `OSF_*` secrets or paths, no `OPENCODE_SERVER_PASSWORD`); - Braid's path guard refuses, in shell commands as in `read`, any path under the state volume outside the run's own folder, plus the token and key files and `/proc/*/environ`. This is bypassable by a determined model, so it is not the fix. 2. The fix: agent processes can't reach what isn't theirs. Either opencode and its shells run as a different uid from osfd, with run folders and secrets permissioned so the agent's uid reaches only its own run, or each run is sandboxed (mount namespace with only its folder and the tools). Decide which the container allows (capabilities, seccomp, user namespaces). 3. A simulated-run scenario and a self-check line that an agent's shell cannot read another run's folder, the token, or a key file.
Author
Owner

First layer deployed in c1228b4 (agent-shells-see-only-their-run): an allowlisted environment for agent shells and a path guard, attack-reviewed. The real fix, a per-run sandbox, is #203 (research first; draft proposal agents-reach-only-their-run).

First layer deployed in c1228b4 (`agent-shells-see-only-their-run`): an allowlisted environment for agent shells and a path guard, attack-reviewed. The real fix, a per-run sandbox, is #203 (research first; draft proposal `agents-reach-only-their-run`).
Author
Owner

The first layer is archived in OpenSpec as agent-shells-see-only-their-run (5a953a0); the capability is agent-confinement. This issue stays open for the real fix, #203.

The first layer is archived in OpenSpec as `agent-shells-see-only-their-run` (5a953a0); the capability is `agent-confinement`. This issue stays open for the real fix, #203.
Author
Owner

Closing at the owner's word (2026-11-11): the fix this issue waits for is tracked on braid#203, so one ticket is enough.

Where its three to-dos stand:

  1. First layer: shipped in c1228b4 and archived as agent-shells-see-only-their-run. Agent shells get an allowlisted environment, and the path guard refuses other runs' folders, osfd's secrets and /proc/*/environ.
  2. The fix: braid#203, a sandbox per run. Its draft proposal agents-reach-only-their-run is on main, not approved, with research still to do.
  3. Proof of the first layer: the sim agent-shell-confined, and the deploy self-check's line "an agent's shell gets none of osfd's settings or secrets, and the guard keeps it to its run", ok in the deploy of f27905f.

The exposure is not closed. A model that computes a path at run time can still get past the text guard, and Free runs have gone on since 11-03 with only this layer. That stays true until braid#203 ships.

Closing at the owner's word (2026-11-11): the fix this issue waits for is tracked on braid#203, so one ticket is enough. Where its three to-dos stand: 1. **First layer:** shipped in `c1228b4` and archived as `agent-shells-see-only-their-run`. Agent shells get an allowlisted environment, and the path guard refuses other runs' folders, osfd's secrets and `/proc/*/environ`. 2. **The fix:** braid#203, a sandbox per run. Its draft proposal `agents-reach-only-their-run` is on main, not approved, with research still to do. 3. **Proof of the first layer:** the sim `agent-shell-confined`, and the deploy self-check's line "an agent's shell gets none of osfd's settings or secrets, and the guard keeps it to its run", `ok` in the deploy of `f27905f`. **The exposure is not closed.** A model that computes a path at run time can still get past the text guard, and Free runs have gone on since 11-03 with only this layer. That stays true until braid#203 ships.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#201
No description provided.