A red team needs a blast radius
How do you let an adversarial reviewer probe a system without the probe doing the damage it is looking for? Make every probe declare its worst-case side effect and a numeric bound before it runs, rehearse it on a copy, and refuse the probe if either is missing. A reviewer who can hurt production is not a red team, it is an incident with a nice title.
I learned this the ordinary way. A test run once executed a real rollback script where a stand-in was meant to be. Nobody was careless in the usual sense: the script was the thing under test, and the reviewer's brief said to exercise it. What was missing was a sentence in the brief about what it was allowed to touch.
Declare the damage first
A probe is a small experiment. Before it runs, it should answer four questions in writing: what is it called, what is the worst thing it can do, how many things can it touch at most, and where is it allowed to touch them. If any answer is missing, the runner refuses. That rule is cheap to build and it changes behavior, because writing "removes every file matching a pattern in this directory" next to the probe makes the author think about the pattern.
A runner that enforces it
I built the smallest runner I could defend and ran it against a scratch directory. It checks the declaration, confirms the target sits inside a sandbox after resolving links, refuses a target that contains a symbolic link, a hard-linked file or a special file such as a pipe, records the real target's contents, then rehearses the real action on a copy of the target and measures the change itself by comparing content hashes, folder by folder, before and after. Only if the rehearsal stays inside the bound, and the real target did not change during it, does the probe act on the real target, and the runner measures again afterwards.
The measuring matters. My first version asked the probe how many files it would touch, and a reviewer showed that a probe can simply report the wrong number, or ignore the dry-run flag and delete during the "dry run". Any count the probe reports about itself is only as honest as the probe. So the runner never takes the probe's word.
declared, in bound ran, runner measured 5 changed
no bound declared REFUSED: undeclared: max_files_touched; files left in sandbox: 5
bound too small REFUSED: bound exceeded in rehearsal on a copy: 5 > 2; files left in sandbox: 5
target is outside REFUSED: target outside sandbox; files left in sandbox: 5
probe lies about count REFUSED: bound exceeded in rehearsal on a copy: 5 > 1; files left in sandbox: 5
probe ignores the dry flag REFUSED: bound exceeded in rehearsal on a copy: 5 > 2; files left in sandbox: 5
honest, bound exact ran, runner measured 5 changed
files left outside sandbox: 5
The last line is the point. The probe that aimed at a directory outside the sandbox was refused, and the five files there are still there. The probes that lied or ignored the flag were stopped by the rehearsal, and the real files survived.
The cases that matter
Eleven tests cover what I was afraid of. A probe with no bound touches nothing. A probe aimed outside the sandbox touches nothing. A bound that is too small stops the run in the rehearsal, with every real file still present. A link inside the sandbox that points outside it is refused, because the check resolves the real path first. A probe that under-reports its own count is caught, and a probe that ignores the dry flag cannot hurt the real target. A probe that ignores the path it is given and hits the real directory is caught, because the runner recorded the real target before the rehearsal. A target containing a link, a hard link or a pipe is refused, and a change in a subfolder counts. And the happy path still works, which matters, because a runner that refuses everything proves nothing.
What this does not cover
A bound on files says nothing about a probe that sends a network request, spends money or changes a remote record. Those need their own declared bound: a count of calls, a spend cap, a stand-in endpoint. The runner here handles one kind of side effect. The lesson generalizes, the code does not.
A declaration is also only as honest as its author. A probe can claim a bound of one and be built to do more; the runner's own measurement catches that, but only for the thing it knows how to measure, here file contents. A copy only contains a probe that stays on the path it is given. A probe that wanders onto the real target is caught only after it has done the damage, and one that wanders anywhere else is not caught at all; real containment needs a separate process or sandbox. A probe that behaves differently on a copy than on the real thing defeats the rehearsal too. For anything the runner cannot measure, a person has to read the probe. This pairs with guards that say which way they lean: a guard that cannot tell should refuse, and that includes the guard around the red team.
Finally, do not turn this into a reason to run weak probes. A bound is not a cap on how hard a legitimate large job may run. It is a statement of how much a given probe may change, and a big test can have a big bound if somebody wrote it down.
Brief template
- Name of the probe.
- Worst-case side effect, in one sentence.
- Maximum number of things touched.
- Target, inside a sandbox the runner can verify.
- A rehearsal the runner can measure itself, such as a copy of the target.
How this was verified
I ran the runner and its eleven unit tests in scratch directories. The table above is real output. The tests cover the missing-bound refusal, the outside-target refusal, the small-bound refusal in the rehearsal, the link-escape refusal, the lying probe, the probe that ignores the flag, the probe that ignores its path, a target containing a link, a hard link or a pipe, the subfolder change and the in-bound success. I did not test network or money side effects, and I did not run this against any real system.