docs(fermata): do not use; an experiment, with what it is known to fail at

The public README, crate README, docs, SVGs, crate description and --help no
longer present fermata as protection. The README opens with a warning and a
"Known to fail" list from recheck-2, each item reproduced on this code.

The docs also said things the code does not do: the hook never checks a Bash
command against path rules (threat model L1 to L4), [enforcement] mode has no
effect, [policy.read] takes patterns and not deny, a .botignore directory
pattern misses the files below it, and a relative path never matches.
This commit is contained in:
2026-11-06 23:48:18 +01:00
parent fe041051ca
commit 47da98709f
8 changed files with 203 additions and 271 deletions
+2 -2
View File
@@ -3,11 +3,11 @@ name = "dirigent_fermata"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
description = "Harness-agnostic policy gate for AI coding agents (.botignore + .botsecrets)"
description = "An experiment, do not use: hooks around AI agent tool calls that try to mask secrets, and fail to"
license = "MIT OR Apache-2.0"
repository = "https://git.g4b.org/dirigence/fermata"
readme = "README.md"
keywords = ["ai", "agents", "security", "policy", "gitignore"]
keywords = ["ai", "agents", "experiment", "hooks", "gitignore"]
categories = ["command-line-utilities", "development-tools"]
[lib]
+73 -144
View File
@@ -1,51 +1,81 @@
# fermata
**A fast, harness-agnostic security layer for AI coding agents.**
**Do not use this software.**
AI coding agents read files, run commands, and inspect output as part of their normal workflow. When they read `.env`, secret values get tokenized into the LLM's context window -- and from there they can leak into commits, PR descriptions, log messages, or API calls. The solution is not blocking the read -- the agent needs to see config structure and key names to reason about your project. The solution is **redacting secret values from the output before they reach the model**. No AI coding agent ships built-in post-read secret filtering today. fermata fixes that.
> [!CAUTION]
> This is an experiment. It does not protect your secrets. Secrets can and do reach the model while it is installed. Do not rely on it. Do not install it on a real project.
## Why
## Known to fail
Blocking reads is the wrong approach. The agent needs to see file structure. It needs to know which keys exist in `.env`, what your database config looks like, how your secrets are organized. What it does *not* need to see is the actual secret values. An agent can have full read access to `.env` without secret values being revealed -- if the output is redacted before it reaches the model.
These failures were reproduced with fake values, through the fermata binary. The list is not complete.
fermata operates on two independent levels:
- **Files on the default secret list are never read.** fermata only parses `.env`, TOML, JSON, YAML, Python and properties files. A Read of anything else on its default list reaches the model, even under `on_parse_error = "deny"`: `terraform.tfstate`, `*.tfstate`, `terraform.tfvars`, `*.auto.tfvars`, `.aws/credentials`, `.netrc`, `.htpasswd`, `*.pem`, `*.key`, `id_rsa`, `id_ed25519`, `id_ecdsa`. `*.p12` and `*.pfx` take the same path.
- **Many values never enter the list of known secrets.** A commented `.env` line, a symlinked `.env`, a multi-document YAML file, `secrets.py` with a trailing comment or a triple-quoted value, `.env` values with shell quoting inside them, the first value of a duplicate JSON key, a value swallowed by an unclosed quote, a file that cannot be parsed, a secret file outside the working project.
- **Ordinary config values get masked everywhere, and this can corrupt source.** With `AUTH_ENABLED=true` and `TOKEN_TTL=3600` in `.env`, every `true` and `3600` in every output becomes `*****`. An agent that reads the mask from a source file and writes the file back puts the mask into your code.
- **`cat .env; false` is unprotected.** According to Claude Code's documentation and bundled code, a failed tool's output goes down a path no hook can rewrite. A `[policy.bash]` deny pattern stops only the spelling it names.
- **Commands are not checked against path rules.** `.botignore` and `[policy.read]` do not stop `cat .env` in Bash.
- **A directory pattern in `.botignore` does not match the files below it.** `vendor/` lets a write to `vendor/a` through. `vendor/**` stops it. A relative path never matches `.botignore`.
- **Secret filtering** (PostToolUse) -- `.botsecrets` declares where secrets live; fermata parses them, builds an Aho-Corasick automaton, and redacts secret *values* from tool output before they enter the LLM context. This is the primary defense. It catches secrets regardless of how they appear -- direct reads, shell output, log files, error messages.
- **Policy gate** (PreToolUse) -- `.botsecrets [policy]` / `.botignore` blocks dangerous writes and destructive commands before they execute. Supplementary protection for write safety and anti-jailbreak.
The fuller list: [docs/security-model.md](docs/security-model.md#known-limits). The test suite never runs Claude Code.
The key insight: file-level access control operates on file identity (*which file*). Secret redaction operates on data content (*which values*). The reveal problem can only be solved at the data-content level.
## What it tries to do
> **Note:** fermata also accepts `fermata.toml` as an alias for `.botsecrets` (same format, `.botsecrets` takes priority when both exist).
AI coding agents read files and run commands, and what they read enters the model's context. The experiment asks whether a tool's output could be filtered before the model sees it, so that an agent could see which keys `.env` holds without seeing their values.
## Quick Start
fermata runs in hooks around an agent's tool calls:
### Install
```
Agent wants to run a tool
|
PreToolUse ── .botsecrets [policy] / .botignore
| a rule matches? → deny or ask
| otherwise → no answer: Claude Code's permissions decide
|
Tool executes
|
PostToolUse ── .botsecrets [files] + [keys] + [heuristic]
| values it parsed? → masked
| known formats? → a warning, the value stays
|
Output enters LLM context, with whatever was missed
```
| Part | Mechanism | What it does |
|------|-----------|--------------|
| Known-value masking | `.botsecrets` names secret files; fermata parses those it has a parser for and builds an Aho-Corasick automaton | Masks a value from the manifest in a string of a successful tool's output |
| Heuristic scan | Regex patterns from gitleaks (AWS keys, JWTs, GitHub PATs, database URLs) | Warns beside the output and masks nothing |
| Rules | `.botsecrets [policy]` / `.botignore` | Stops the Read, Write and Edit tools on matching paths, and commands whose text matches. No rules, nothing stopped |
Each call parses the secret files again. That takes milliseconds for a small file and about 23 s at 1.7 MB. A hook that times out lets the original output through.
fermata is no sandbox: see [docs/threat-model.md](docs/threat-model.md).
## Trying the experiment
Use a throwaway project and fake secrets.
```bash
cargo install --path . --features cli
```
### Protect a project in 30 seconds
```bash
# Declare where secrets live -- fermata parses them and redacts values from agent output
cat > .botsecrets << 'EOF'
```toml
# .botsecrets
[files]
patterns = [".env", ".env.*", "secrets.*"]
[keys]
include = ["STRIPE_*", "MY_APP_SIGNING_*"]
[policy.write]
patterns = [".claude/**", "vendor/**", "*.lock"]
[policy.bash]
deny = ["rm -rf /", "curl * | sh"]
EOF
```
One file. The agent can read `.env` freely -- fermata redacts the secret values from the output before they reach the model. Write protection and bash safety rules live in the same `.botsecrets` under `[policy]`.
`fermata.toml` is accepted as another name for `.botsecrets`, which wins when both exist. An optional `.botignore` uses gitignore syntax for the Read, Write and Edit tools. See [docs/configuration.md](docs/configuration.md).
### Wire into Claude Code
Add both hooks in `.claude/settings.json`:
Add both hooks to `.claude/settings.json`:
```json
{
@@ -68,158 +98,57 @@ Add both hooks in `.claude/settings.json`:
}
```
PostToolUse redacts declared secret values from the output of every tool, built-in and MCP, in the shape the tool returned it. PreToolUse blocks forbidden writes and dangerous commands. It is no permission approver: when no rule stops a call it answers nothing, and Claude Code's own prompts stay as they are.
PreToolUse is no permission approver: when no rule stops a call it answers nothing, and Claude Code's own prompts stay.
Leave out `matcher`: both hooks must see every tool. `Grep`, `Glob`, `WebFetch`, `Agent` and MCP tools return file contents too, and a matcher that omits them leaves their output unredacted. PreToolUse answers with nothing for tools it has no rules for.
Leave out `matcher`: a matcher that omits a tool leaves that tool's output unfiltered.
`"onFailure": "block"` (Claude Code v2.1.295 or later; older versions ignore it) stops a tool call when the hook cannot run, for example when `fermata` is not on `PATH`. Without it Claude Code carries out the call and every output passes unredacted. It belongs on PreToolUse because the tool has not run yet. On PostToolUse it cannot hold anything back: the tool has already run, and Claude still gets the original output. With it, a teammate without `fermata` on `PATH` is blocked at every tool by a committed `.claude/settings.json`, so per-user installs belong in `.claude/settings.local.json`. To recover, edit the settings by hand or set `"continue"`.
Redaction has limits. The largest: Claude Code sends the output of a failed tool, such as a Bash command with a non-zero exit code, down a path no hook can rewrite. `cat .env; false` reaches the model unredacted. Only a `[policy.bash] deny` pattern stops it, and only for the spelling it names. See [docs/security-model.md#known-limits](docs/security-model.md#known-limits).
## How It Works
fermata interposes on every tool call in the agent's lifecycle:
```
Agent wants to run a tool
|
PreToolUse ── .botsecrets [policy] / .botignore
| write blocked? → deny
| bash denied? → deny
| otherwise → no answer: Claude Code's permissions decide (reads of .env included)
|
Tool executes
|
PostToolUse ── .botsecrets [files] + [keys] + [heuristic]
| secret values found? → redact before LLM sees it
|
Clean output enters LLM context
```
Three layers of defense, each independent:
| Layer | Mechanism | What it catches |
|-------|-----------|-----------------|
| **Known-value redaction** | `.botsecrets` declares secret files; fermata parses them and builds an Aho-Corasick automaton | Every occurrence of a declared secret value in a string of a successful tool's output, regardless of source. [Known limits](docs/security-model.md#known-limits) |
| **Heuristic detection** | Regex patterns from gitleaks detect undeclared secrets (AWS keys, JWTs, GitHub PATs, database URLs) | Warns about secrets not covered by the manifest -- runtime-generated, unexpected locations. It does not mask them |
| **Access control** | `.botsecrets [policy]` / `.botignore` rules block writes and dangerous commands | Destructive writes, anti-jailbreak (agent modifying its own hooks), dangerous shell commands |
Performance: ~1-5ms per tool call. Cold start (loading config + parsing secret files) is ~10-20ms.
## Configuration
### `.botsecrets` -- the primary (and usually only) config
`.botsecrets` is the unified configuration file. It declares both what to redact and what to restrict:
```toml
[files]
patterns = [".env", ".env.*", "secrets.*"]
[keys]
include = ["STRIPE_*", "MY_APP_SIGNING_*"]
[heuristic]
enabled = true
# Access control: write protection and bash safety.
# Reading secret-containing files is allowed -- Layer 1 redacts the values.
[policy.write]
patterns = [".claude/**", "vendor/**", "*.lock"]
[policy.bash]
deny = ["rm -rf /", "curl * | sh"]
```
Built-in key patterns (`*_KEY`, `*_SECRET`, `*_PASSWORD`, `*_TOKEN`, `DATABASE_URL`, etc.) handle most projects without custom configuration.
### `.botignore` -- optional simple layer
Gitignore syntax. For projects that want a minimal, familiar format for write protection. Complements `.botsecrets` but is not required.
```gitignore
vendor/**
*.lock
```
See [docs/configuration.md](docs/configuration.md) for the full reference.
`"onFailure": "block"` (Claude Code v2.1.295 or later; older versions ignore it) stops a tool call when the hook cannot run. Without it Claude Code carries out the call and the output passes unfiltered. On PostToolUse it can hold nothing back, because the tool has already run. With it, a teammate without `fermata` on `PATH` is blocked at every tool by a committed `.claude/settings.json`, so per-user installs belong in `.claude/settings.local.json`. To recover, edit the settings by hand or set `"continue"`.
## Commands
```bash
# Check if a path is allowed
fermata check --op read /path/to/.env # exit 1 = blocked
fermata check --op write src/main.rs # exit 0 = allowed
# Check a path against the rules
fermata check --op read /path/to/.env # exit 1 = a rule denies it
fermata check --op write /path/to/src/main.rs # exit 0 = no rule denies it
# Run as a hook (reads harness JSON from stdin)
fermata hook --harness claude
fermata hook --harness claude --event post-tool-use
```
See [docs/commands.md](docs/commands.md) for the full CLI reference.
See [docs/commands.md](docs/commands.md).
## Library API
fermata is also a Rust library:
```rust
use std::path::Path;
use dirigent_fermata::core::secrets::{Manifest, Redactor, Scanner, SecretsConfig};
// Load .botsecrets and build the redaction manifest
let config = SecretsConfig::load("/path/to/project")?;
let manifest = Manifest::discover(&config)?;
let root = Path::new("/path/to/project");
let config = SecretsConfig::load(root)?;
let manifest = Manifest::build(&config, root)?;
// Known-value redaction (Aho-Corasick, sub-millisecond)
let redactor = Redactor::from_manifest(&manifest);
let redactor = Redactor::new(&manifest, config.redaction.style);
let clean = redactor.redact("DB_PASSWORD=hunter2");
// -> "DB_PASSWORD=*****"
// clean.text holds the masked text, if hunter2 made it into the manifest
// Heuristic scanning (regex patterns)
let scanner = Scanner::new(&config);
let scanner = Scanner::new(&config.heuristic)?;
let findings = scanner.scan("Found key: AKIA1234567890ABCDEF");
// -> [Finding { pattern: "AWS Access Key", confidence: High, .. }]
```
## Security Model
fermata addresses a novel security concern: **reveal** -- whether secret *values* enter the LLM context. Traditional file-level access control operates on file identity (which file). Secret redaction operates on data content (which values). The reveal problem can only be solved at the data-content level.
Read [docs/security-model.md](docs/security-model.md) for the full analysis, including the Reveal Triangle and defense-in-depth architecture.
## Threat Model
fermata is a heuristic guard, not a sandbox. It defends against statistical agent behavior and prompt-driven mistakes -- not a deliberate adversary. This is a strength: the threat model is well-defined, and the boundaries are documented honestly.
Read [docs/threat-model.md](docs/threat-model.md) for what fermata catches, what it doesn't, and what to combine it with.
## Harness Support
## Harness support
| Harness | Status | Mechanism |
|---------|--------|-----------|
| Claude Code | Shipped | PreToolUse + PostToolUse hooks |
| Codex CLI | Planned | Pre-exec hook adapter |
| Gemini CLI | Planned | MCP server mode |
| Any MCP agent | Planned | MCP proxy wrapping existing servers |
| Claude Code | Exists, fails as listed above | PreToolUse and PostToolUse hooks |
| Codex CLI | Not built | Pre-exec hook adapter |
| Gemini CLI | Not built | MCP server mode |
| Any MCP agent | Not built | MCP proxy |
The policy engine and redaction logic are identical across all modes. Only the I/O adapter changes.
## Background
## Status
v0.2 -- secret filtering engine and policy gate are production-ready. All core components are implemented and tested:
- `.botsecrets` config with `[files]`, `[keys]`, `[heuristic]`, and `[policy]` sections
- Aho-Corasick known-value redactor
- Heuristic scanner with gitleaks-derived patterns
- Manifest discovery, multi-format parser (.env, TOML, YAML, JSON)
- Claude Code PreToolUse and PostToolUse adapters
- `.botignore` walker with gitignore semantics
## The `.botsecrets` Vision
`.botsecrets` is designed to be the **`.gitignore` of AI agent security**: a simple, declarative, human-readable file that every project can drop in to protect its secrets from AI agents.
The format is harness-agnostic from day one. It declares *what* to protect, not *how*. One file covers both redaction (`[files]`, `[keys]`, `[heuristic]`) and access control (`[policy]`). The same `.botsecrets` works with Claude Code, Codex, Gemini, and any future harness that supports tool lifecycle hooks.
- [docs/security-model.md](docs/security-model.md): the idea of "reveal", as distinct from read and write, the design, and the known limits
- [docs/threat-model.md](docs/threat-model.md): what fermata tries to catch and where it stops
## License
+14 -9
View File
@@ -1,6 +1,8 @@
# CLI Command Reference
Fermata is a policy gate and secret filtering engine for AI coding agents. It ships two subcommands: `check` for interactive path validation and `hook` for integration with AI harness hook systems.
> **Do not use this software.** fermata is an experiment. It does not protect your secrets, and secrets can and do reach the model while it is installed. This document describes what fermata tries to do. See [Known limits](security-model.md#known-limits) for where it fails.
Fermata is an experiment in stopping tool calls by rule and masking secret values in tool output. It ships two subcommands: `check` for interactive path validation and `hook` for integration with AI harness hook systems.
---
@@ -33,6 +35,8 @@ When multiple paths are provided, fermata evaluates each one independently and r
**Examples**
A relative path never matches `.botignore`, so it exits 0 whatever the file says. Use absolute paths.
```bash
# Check if the agent can read .env
fermata check --op read .env
@@ -113,7 +117,7 @@ Fermata discovers these files by walking up from the target path (or the current
## Common Patterns
### Protect secrets from day one
### Trying both files
Drop two files in your project root:
@@ -134,7 +138,7 @@ patterns = [".env", ".env.*"]
enabled = true
```
The `.botignore` blocks direct reads. The `.botsecrets` catches secrets that leak through indirect paths (shell output, log files, error messages).
The `.botignore` stops the Read, Write and Edit tools on those paths, and does not stop `cat .env` in Bash. The `.botsecrets` tries to mask the values of the files it can parse in the output of tools that succeed.
### Single-file setup with .botsecrets
@@ -149,7 +153,7 @@ patterns = [".env", ".env.*"]
enabled = true
[policy.read]
deny = [".env", ".env.*", "secrets/**", "credentials/**"]
patterns = [".env", ".env.*", "secrets/**", "credentials/**"]
[policy.bash]
deny = ["rm -rf /", "curl * | sh"]
@@ -191,17 +195,18 @@ deny = ["rm -rf /", "curl * | sh", "wget * | bash"]
### Quick smoke test
After installing fermata, verify it works against your project:
After installing fermata, try it in a throwaway project:
```bash
# Should exit 0 (allowed)
fermata check --op read src/main.rs
fermata check --op read "$PWD/src/main.rs"
echo $?
# Should exit 1 (denied) if .botignore blocks .env
fermata check --op read .env
# Should exit 1 (denied) if .botignore blocks .env.
# Use an absolute path: a relative path never matches .botignore and exits 0.
fermata check --op read "$PWD/.env"
echo $?
# JSON output for scripting
fermata check --op read .env --json
fermata check --op read "$PWD/.env" --json
```
+37 -25
View File
@@ -1,5 +1,7 @@
# Configuration Reference
> **Do not use this software.** fermata is an experiment. It does not protect your secrets, and secrets can and do reach the model while it is installed. This document describes what fermata tries to do. See [Known limits](security-model.md#known-limits) for where it fails.
Fermata uses up to two configuration files to control what an AI coding agent
can access and what secret values it can see. `.botsecrets` is the primary
configuration file. Most projects need only this file.
@@ -21,9 +23,9 @@ operations and performs no redaction.
`.botsecrets` declares which files contain secrets, how Fermata should
redact them from tool output, and (optionally) access control policy rules.
This prevents secret values from leaking into the LLM context window even
when the agent reads files indirectly (via shell output, log files, error
messages, etc.).
The aim is to keep secret values out of the LLM context window, also when the
agent reads files indirectly (via shell output or log files). Many values get
through: see [Known limits](security-model.md#known-limits).
### Layered Configuration
@@ -67,6 +69,14 @@ terraform.tfvars, *.auto.tfvars, terraform.tfstate, *.tfstate,
service-account-key.json
```
Fermata only parses `.env`, TOML, JSON, YAML, Python and properties files, and
`[[file]]` overrides with one of those formats. On this list, `*.key`, `*.pem`,
`*.p12`, `*.pfx`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `terraform.tfvars`,
`*.auto.tfvars`, `terraform.tfstate`, `*.tfstate`, `config/master.key`,
`config/credentials/*.key`, `.aws/credentials`, `.netrc` and `.htpasswd` are
never parsed. Their contents reach the model on a Read, also under
`on_parse_error = "deny"`.
Setting `files.patterns` in a layer **replaces** the defaults entirely.
```toml
@@ -128,8 +138,8 @@ style = "named"
In addition to known-value redaction, Fermata can scan tool output for
patterns that look like secrets (AWS keys, JWTs, GitHub PATs, high-entropy
strings, database connection URLs). This catches secrets not covered by the
`.botsecrets` manifest.
strings, database connection URLs). This looks for secrets not covered by the
`.botsecrets` manifest, and only warns.
| Field | Type | Default | Description |
|-------|------|---------|-------------|
@@ -165,9 +175,11 @@ Enforcement modes:
| Mode | Behavior |
|------|----------|
| `strict` | Any error or ambiguity results in denial. |
| `permissive` | Best-effort redaction; non-fatal errors are tolerated. Default. |
| `audit` | Log all decisions but do not block or redact. |
| `strict` | Accepted, and has no effect. |
| `permissive` | Accepted, and has no effect. Default. |
| `audit` | Accepted, and has no effect. |
The hooks do not read `mode`. Only `on_parse_error` changes what they do.
Parse error actions:
@@ -215,11 +227,10 @@ format = "env"
Optional access control rules embedded directly in `.botsecrets`.
#### `[policy.write]` -- Write Protection
#### `[policy.write]` -- Write Rules
Blocks the agent from writing to matching paths. This is the primary use case
for access control -- protecting vendored code, lock files, and policy files
from modification.
Stops the Write and Edit tools on matching paths, for example vendored code,
lock files and policy files. A shell command that writes to them is not checked.
| Field | Type | Description |
|-------|------|-------------|
@@ -249,9 +260,8 @@ ask = ["docker", "kubectl"]
#### `[policy.read]` -- Read Restrictions (Rarely Needed)
Blocks reads of matching paths. Rarely needed -- secret values are redacted by
the PostToolUse layer regardless of whether the read is allowed. Use this only
for files the agent cannot usefully read (e.g., binary blobs, large data files).
Stops the Read tool on matching paths. A shell command that prints them is not
checked.
```toml
[policy.read]
@@ -266,8 +276,8 @@ For most projects, `.botsecrets` with `[policy]` is sufficient. `.botignore`
remains useful for monorepo subtree exclusion or teams that prefer gitignore
syntax for simple path blocking.
A `.botignore` file uses **gitignore syntax** to block agent access to matching
paths. When a path matches, both reads and writes are denied. There is no
A `.botignore` file uses **gitignore syntax** to stop the Read, Write and Edit
tools on matching paths. A shell command is not checked. When a path matches, both reads and writes are denied. There is no
distinction between operations -- if you need per-operation control, use
the `[policy]` section in `.botsecrets` instead.
@@ -292,7 +302,9 @@ an ignore from a shallower `.botignore`.
### Syntax
Standard gitignore rules apply:
These gitignore rules apply, with two differences from git. A directory pattern
such as `vendor/` does not match the files below it, so write `vendor/**`. A
relative path never matches: the rules only meet absolute paths.
- Blank lines and lines starting with `#` are ignored.
- `*` matches anything except `/`.
@@ -305,8 +317,8 @@ Standard gitignore rules apply:
```gitignore
# Block entire subtrees in a monorepo
packages/legacy-app/
vendor/
packages/legacy-app/**
vendor/**
# Block private keys
*.pem
@@ -330,7 +342,7 @@ id_ed25519
patterns = [".env", ".env.*"]
```
### Standard: Redact Secrets + Write Protection
### Standard: Redact Secrets + Write Rules
```toml
# .botsecrets
@@ -353,9 +365,9 @@ For teams that prefer gitignore syntax:
```gitignore
# .botignore (optional)
node_modules/
build/
dist/
node_modules/**
build/**
dist/**
```
```toml
@@ -366,7 +378,7 @@ patterns = [".env", ".env.*"]
### Full-Featured: Complete Configuration
A production setup using `.botsecrets` for both redaction and policy:
Every section of `.botsecrets` at once, for redaction and policy:
```toml
# .botsecrets
+33 -33
View File
@@ -1,89 +1,93 @@
# fermata Security Model
> **Do not use this software.** fermata is an experiment. It does not protect your secrets, and secrets can and do reach the model while it is installed. This document describes what fermata tries to do. See [Known limits](#known-limits) for where it fails.
## The Problem
AI coding agents see secrets. Not because they try to -- because secrets are everywhere in a working codebase, and agents read files, run commands, and inspect output as part of their normal workflow.
When an agent reads `.env`, the secret values get tokenized into the LLM's context window. Once there, they can leak into commits, PR descriptions, log messages, or API calls the agent makes. The secret is irrecoverably revealed.
No AI coding agent ships built-in post-read secret filtering today. The entire industry relies on pre-read access controls -- block the file and hope the agent doesn't find the data through another path. This is insufficient.
Blocking a file before the read leaves other paths to the same data open. This experiment looks at filtering the output instead.
## The Reveal Triangle
Most security models think about secrets in terms of *files*: can the agent read this file? Can it write to it? fermata introduces a third dimension that traditional models miss entirely.
Most security models think about secrets in terms of *files*: can the agent read this file? Can it write to it? This experiment looks at a third dimension.
**Read** -- Can the agent open a file? Handled by policy rules and file access controls. A blunt instrument: blocking `.env` also blocks legitimate tooling that needs configuration values. In fermata's model, read access to secret-containing files is *allowed by default* -- the agent needs to see file structure and key names to reason about configuration.
**Write** -- Can the agent modify a file? Less concerning than it appears, because version control provides full recovery. Write restrictions matter primarily for anti-jailbreak (preventing the agent from modifying its own hooks or policy files).
**Reveal** -- Do secret *values* enter the LLM context? This is the novel concern. No traditional security model addresses it because the concept did not exist before AI agents. A file read that configures a database is not a security event. The same file read that feeds credentials to an LLM *is*.
**Reveal** -- Do secret *values* enter the LLM context? A file read that configures a database is not a security event. The same file read that feeds credentials to an LLM *is*.
These three dimensions are independent. An agent can have read access to `.env` without the secret values being revealed -- the output is redacted before it reaches the model. This is the default state, not a special configuration: the agent sees file structure, knows which keys exist, can reason about configuration, but never sees actual secret values.
These three dimensions are independent. In theory an agent could have read access to `.env` without the secret values being revealed, if the output were masked before it reached the model. The agent would see file structure and key names and not the values. fermata tries this and does not achieve it reliably: see [Known limits](#known-limits).
The key insight is that Read and Write operate on file identity (*which file*). Reveal operates on data content (*which values*). The reveal problem can only be solved at the data-content level. File identity is necessary but not sufficient.
The key insight is that Read and Write operate on file identity (*which file*). Reveal operates on data content (*which values*). File identity alone does not answer the reveal question.
## Defense in Depth
## Layers
fermata implements a layered security stack. Layers 1 and 2 are the primary defense -- they operate on data content (the actual secret values). Layers 3 and 4 are supplementary -- they operate on file and system identity.
The design has four layers. Layers 1 and 2 operate on data content (the actual secret values). Layers 3 and 4 operate on file and system identity.
### Layer 1: Known-Value Redaction (.botsecrets + Aho-Corasick)
Parse secret-containing files at startup, extract actual secret values, build an Aho-Corasick automaton. Scan all tool output for those exact byte strings and replace them with redaction markers.
This is the primary defense layer. It catches secrets regardless of how they reached the output -- direct file reads, shell command output, log files. If the value `hunter2` is a declared secret, every occurrence in a string of a successful tool's output is redacted before it reaches the model.
**Guarantees**: Every occurrence of a declared value within a string is found, sub-millisecond per scan: the Aho-Corasick automaton finds all of them in a single linear pass. What reaches the scan has [known limits](#known-limits).
This layer looks at values, not at how they reached the output: file reads, shell command output, log files. If the value `hunter2` made it into the manifest, every occurrence in a string of a successful tool's output is masked: the Aho-Corasick automaton finds all of them in a single linear pass. Many values never reach the manifest, and much output never reaches the scan: see [known limits](#known-limits).
### Layer 2: Heuristic Detection (Scanner + gitleaks patterns)
Regex patterns for known secret formats: AWS access keys (`AKIA...`), GitHub PATs (`ghp_...`), JWTs (`eyJ...`), database URLs with embedded passwords, and dozens more derived from industry-standard pattern sets.
This is the safety net for secrets not covered by the manifest -- secrets in files that `.botsecrets` does not know about, secrets generated at runtime, secrets that appear in unexpected places. It warns beside the output and does not mask.
This looks for secrets not covered by the manifest. It warns beside the output and does not mask, so the value still reaches the model.
Its false-positive rate is higher than Layer 1's, which is why it warns: masking every high-entropy string would corrupt the output.
### Layer 3: Access Control (.botignore / .botsecrets [policy])
Block dangerous write operations and destructive commands. `Write .claude/settings.json` -- denied. `Bash: rm -rf /` -- denied. Uses gitignore-style patterns for write protection and command deny-lists for bash safety.
Stop the tool calls your rules name. With `[policy.write]` on `.claude/**`, `Write .claude/settings.json` is denied. With `[policy.bash] deny = ["rm -rf /"]`, `Bash: rm -rf /` is denied. Without rules nothing is stopped. Path patterns apply to the Read, Write and Edit tools, and command patterns match the text of a command.
This layer is supplementary -- it protects against destructive writes and dangerous commands, not secret reads. Reading `.env` is allowed; the secret values do not reach the model because Layer 1 redacts them. Write restrictions remain important for anti-jailbreak (preventing the agent from modifying its own hooks or policy files) and for protecting vendored or generated files.
Reading `.env` is allowed by default, and only Layer 1 stands between its values and the model.
**Limitation**: Cannot catch indirect access to secret values. An agent running `source .env && echo $DB_PASSWORD` bypasses file-level controls entirely. This is exactly why access control is supplementary and redaction (Layer 1) is primary.
**Limitation**: Commands are not checked against path rules. `cat .env` and `source .env && echo $DB_PASSWORD` pass this layer, whatever `.botignore` and `[policy.read]` say. A `.botignore` directory pattern such as `vendor/` does not match the files below it; `vendor/**` does. A relative path never matches `.botignore`.
### Layer 4: Structural Containment (External)
Container-level isolation, filesystem restrictions, dropped capabilities, no-new-privileges. Prevents system modification, privilege escalation, and escape from the execution environment. This layer has no concept of secret values -- it operates on structural boundaries.
fermata does not own this layer. It is provided by your container runtime, VM, or sandboxing tool. fermata's design assumes that structural containment exists as the outermost boundary, and focuses on the data-content layers (1 and 2) that containment cannot address.
fermata does not own this layer. It would come from a container runtime, VM, or sandboxing tool.
## Design Principles
**Fail-open for availability.** A parse error in `.botsecrets`, an unrecognized file format, or a scanner timeout does not block the agent from working. Redaction failures are logged, not fatal. The agent's productivity is not sacrificed for edge-case security failures. Two exceptions: under `on_parse_error = "deny"` the hooks refuse instead, and under `"onFailure": "block"` on PreToolUse a `fermata` that cannot run stops every tool.
**Fail-open by default.** A parse error in `.botsecrets` or in a secret file does not block the agent from working, and the values of that file then reach the model. An unrecognized file format is passed over without a word, also under `deny`. Two exceptions: under `on_parse_error = "deny"` the hooks refuse instead, and under `"onFailure": "block"` on PreToolUse a `fermata` that cannot run stops every tool.
**Not a permission approver.** PreToolUse can stop a call or ask, and otherwise says nothing. It never answers `allow`, because Claude Code would then skip its own permission prompt, and installing a guard must not remove one. `allow_prefixes` only skips fermata's own `ask` rules.
**No missed occurrence of a declared secret within a string.** If a value appears in the secret manifest (loaded from files matched by `.botsecrets`), it is redacted from every string of a successful tool's output, every time, or the output is refused. The Aho-Corasick automaton finds all occurrences in a single pass at memory-bandwidth speed. The [known limits](#known-limits) say what never reaches it.
**Every occurrence of a value in the manifest.** If a value made it into the secret manifest (loaded from files matched by `.botsecrets`), it is masked in every string of a successful tool's output, or the output is refused. The [known limits](#known-limits) say what never reaches the manifest or the scan.
**Sub-millisecond performance.** Hooks fire on every tool call. fermata must not introduce perceptible latency. Policy evaluation is a hashmap lookup. The Aho-Corasick scan runs at memory-bandwidth speed. Cold start (loading secrets + parsing files) takes roughly 10--20ms; subsequent calls are 1--3ms.
**Speed.** Hooks fire on every tool call, and each call loads the config and parses the secret files again. For a small secret file that takes milliseconds. It grows quadratically with the file: 0.6 s for an 81 KB JSON file, 23 s at 1.7 MB, over 300 s at 6.9 MB. A hook that times out lets the original output through.
**Harness-agnostic.** fermata does not assume any specific AI coding agent. The policy engine is pure logic. Harness adapters are thin translation layers. The `.botsecrets` format works identically whether fermata runs as a hook script, an MCP proxy, or an in-process library.
**Harness adapters.** The policy engine knows no specific AI coding agent, and an adapter translates for one harness. Only the Claude Code adapter exists. There is a hook script and an in-process library, and no MCP proxy.
**Single policy file.** `.botsecrets` is the unified configuration interface. One file declares both what to redact (`[files]`, `[keys]`, `[heuristic]`) and what to restrict (`[policy]`). How protection is delivered is a deployment concern, not a configuration concern.
**Single policy file.** `.botsecrets` is the unified configuration interface. One file declares both what to redact (`[files]`, `[keys]`, `[heuristic]`) and what to restrict (`[policy]`).
## Known limits
The PostToolUse hook redacts what Claude Code hands it and accepts back. These are the edges. They were read from Claude Code's documentation and the output schemas bundled in v2.1.314, and have not yet been checked in a live session.
**Covered:** a declared value that appears whole in any string of a successful tool's output, for every built-in tool and MCP tool, nested at any depth. The output comes back in the same shape, with only the values masked.
**Covered:** a value in the manifest that appears whole in any string of a successful tool's output, for every built-in tool and MCP tool, nested at any depth. The output comes back in the same shape, with only the values masked. This is a narrow promise: the list below is long and not complete.
**Not covered:**
- **A tool that fails. This is the largest limit.** Claude Code sends a failed tool's text through `PostToolUseFailure`, whose hooks can only add a note. That includes a Bash command with a non-zero exit code, whose error text holds the command's output, and an MCP error result. `cat .env; false` reaches the model unredacted, and so does a failing `npm test` that prints its environment, `curl -v -f` with a token header on a 500, or any failing `set -x` script. Fermata does not hook this event and cannot rewrite it. Only a `[policy.bash] deny` pattern stops such a command, and only for the spelling it names: a deny on `cat .env` stops `cat .env; false` but not `cat ./.env; false`, `env; false` or `grep -r TOKEN .; false`. `[policy.read]` and `.botignore` guard the Read tool, not what a command prints.
- **Files on the default list that are never parsed.** `terraform.tfstate`, `*.tfstate`, `terraform.tfvars`, `*.auto.tfvars`, `.aws/credentials`, `.netrc`, `.htpasswd`, `*.pem`, `*.key`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `*.p12` and `*.pfx` have no parser. A Read of one reaches the model under every setting, and `deny` refuses nothing, since this is no parse failure. Some of them get a heuristic warning beside the value.
- **Values that never enter the manifest.** A commented `.env` line (`#API_TOKEN=old-prod-value`). A `.env` that is a symlink. A multi-document YAML file: by default the whole file is skipped with a line on stderr, and under `deny` every output is refused for a valid file. `secrets.py` with `SECRET_KEY = "x" # prod` or a triple-quoted value over lines. `.env` values with quoting inside them (`'a'\''b-x'`, `abc"def"-x`), when a program prints the decoded value. The first value of a duplicate JSON key. A `.env` value swallowed by an unclosed quote above it. A secret file outside the working project, such as a Read of `../other/.env`.
- **Files that cannot be parsed.** By default a BOM or a comment in JSON, or a Latin-1 or UTF-16 `.env`, skips the file with only a line on stderr. Neither the model nor the user sees more.
- **A tool that fails. This is the largest limit for values in the manifest.** Claude Code sends a failed tool's text through `PostToolUseFailure`, whose hooks can only add a note. That includes a Bash command with a non-zero exit code, whose error text holds the command's output, and an MCP error result. `cat .env; false` reaches the model unredacted, and so does a failing `npm test` that prints its environment, `curl -v -f` with a token header on a 500, or any failing `set -x` script. Fermata does not hook this event and cannot rewrite it. Only a `[policy.bash] deny` pattern stops such a command, and only for the spelling it names: a deny on `cat .env` stops `cat .env; false` but not `cat ./.env; false`, `env; false` or `grep -r TOKEN .; false`. `[policy.read]` and `.botignore` apply to the Read tool, not to what a command prints.
- **Monitor's output.** Each line of a Monitor's command goes to the model as an event, and PostToolUse only sees `{taskId, timeoutMs}`. `tail -f server.log` passes logged tokens straight through. `[policy.bash]` applies to Monitor's and PowerShell's commands, with the same spelling limit.
- **A changed file's attachment.** After a Read, a file that changes on disk comes back to the model as an attachment with a snippet, which no tool call and no hook handles. Read `.env`, rotate the token, and the next turn carries the new value. `@`-mentions likely take the same route; that has not been traced.
- **A value split across strings.** Each string is scanned on its own. A value divided between `stdout` and `stderr`, between two MCP content blocks, or across the lines of a diff (a multi-line value in `structuredPatch`) does not match.
- **An encoded or altered value.** Base64, URL encoding, a reversed string or a value cut short does not match. Spellings the value has in its own file are known: see [Spellings](#spellings). See the [threat model](threat-model.md).
- **Numbers and booleans in the output.** Only strings are masked. A secret number that a tool returns as a JSON number passes, as text it is masked. Booleans in a secret file are not secrets. A number in a secret file under 6 characters is not one either: see [Spellings](#spellings).
- **Numbers and booleans in the output.** Only strings are masked. A secret number that a tool returns as a JSON number passes, as text it is masked. In a JSON, TOML or YAML secret file booleans are not treated as secrets, and neither is a number under 6 characters: see [Spellings](#spellings). In a `.env` they are: see the next item.
- **Ordinary words get masked.** A `.env` value keeps the general minimum of 4 characters, whatever it holds. With `AUTH_ENABLED=true` and `TOKEN_TTL=3600` every `true` and `3600` in every output becomes a mask, and `*AUTH*` also matches `AUTHOR`. An agent that reads `enabled: *****` from a source file and writes the file back puts the mask into the source.
- **Binary data.** `base64` in a built-in's output, `data` of 64 or more base64 characters beside `type: image`, `audio` or `base64` in a content block at the top of a result, and Bash's image `stdout` stay as they are. A mask there would break the image and the next API request, and a short value can match inside base64 by chance.
- **Undeclared secrets.** The heuristic scanner warns beside the output, and leaves the match in place.
- **A run outside a project.** With no `.botsecrets` or `.botignore` above the working directory, there is nothing to load and the output passes.
@@ -113,18 +117,16 @@ Overlapping matches become one mask, named after the longest. A multi-line value
**Consequences of a mask.** The agent sees `*****`, not the value. If it writes what it read back to a file, it writes the mask over the real value, and an Edit whose `old_string` holds the mask fails. Guard secret files with `[policy.write]`.
## The .botsecrets Vision
## The .botsecrets format
`.botsecrets` is designed to be the `.gitignore` of AI agent security: a simple, declarative, human-readable file that any project can drop in to protect its secrets from AI agents.
The format is harness-agnostic from day one. It declares *what* to protect, not *how*. The "how" is determined by the delivery mode -- hook script, MCP proxy, or library. This means the same `.botsecrets` works with Claude Code, Codex, Gemini CLI, Cursor, and any future tool that supports lifecycle hooks or MCP.
`.botsecrets` is a TOML file. It says which files to parse and which rules to apply, and nothing in it is specific to a harness. fermata reads it for Claude Code only.
A typical `.botsecrets` looks like this:
```toml
# Declare files that contain secrets.
# fermata parses them, extracts the values, and redacts those values
# from all tool output before it reaches the model.
# from tool output, as far as it can.
[files]
patterns = [".env", ".env.*", "config/credentials.toml", "secrets/*.yaml"]
@@ -135,8 +137,8 @@ include = ["STRIPE_*", "MY_APP_SIGNING_*"]
[heuristic]
enabled = true
# Access control: write protection and bash safety.
# Reading secret-containing files is allowed -- Layer 1 redacts the values.
# Rules for writes and commands.
# Reading secret-containing files is allowed.
[policy.write]
patterns = [".claude/**", "vendor/**", "*.lock"]
@@ -145,6 +147,4 @@ patterns = [".claude/**", "vendor/**", "*.lock"]
deny = ["rm -rf /", "curl * | sh"]
```
No secret values appear in `.botsecrets` itself. It points to the files that contain them. The secret extraction, automaton construction, and output scanning happen automatically. Built-in key patterns (`*_KEY`, `*_SECRET`, `*_PASSWORD`, `*_TOKEN`, `DATABASE_URL`, etc.) handle most projects without custom `[keys]` configuration.
fermata is the reference implementation. The format is the standard -- fermata is one way to enforce it.
No secret values appear in `.botsecrets` itself. It points to the files that contain them. Built-in key patterns (`*PASSWORD*`, `*SECRET*`, `*API_KEY*`, `*TOKEN*`, `DATABASE_URL`, etc.) decide which values count unless `[keys]` adds more.
+41 -56
View File
@@ -1,12 +1,14 @@
# Fermata Threat Model
What fermata catches, what it doesn't, and why we tell you both.
> **Do not use this software.** fermata is an experiment. It does not protect your secrets, and secrets can and do reach the model while it is installed. This document describes what fermata tries to do. See [Known limits](security-model.md#known-limits) for where it fails.
What fermata tries to catch, and where it stops.
---
## Framing: heuristic guard, not sandbox
## Framing: an experiment, not a sandbox
Fermata is **not** a defence against a deliberate, optimising adversary trying to escape the box. It is a defence against:
Fermata does nothing against a deliberate, optimising adversary trying to escape the box. The experiment looks at:
- **Statistical agent behaviour** -- the playbook of moves an LLM-driven coding agent reaches for when solving a class of tasks, including its mistakes: overly-broad globs, "let me just `cat` everything", picking up a stray `.env` because it pattern-matched the rest of the directory.
- **Non-malicious harnesses** -- Claude Code, Codex, Gemini and similar agents that are not actively trying to circumvent policy.
@@ -14,36 +16,32 @@ Fermata is **not** a defence against a deliberate, optimising adversary trying t
This shifts the design centre from "what can a smart attacker hide?" to "what does an unguided LLM commonly do, and how do we catch the dangerous fraction of that?" Static analysis becomes tractable when grounded in **what is usual**, not what is adversarially possible.
Think of fermata as a guardrail on a mountain road, not an armoured wall. It catches the statistical case -- the distracted driver drifting toward the edge -- not the determined off-roader who drives around it.
Fermata's primary defence is not path blocking but **value redaction**. Even when a path-level check misses a read (L4 shell indirection, L5 derived names), known secret values are scrubbed from tool output before the LLM sees them. The path-level checks (L0--L3) provide supplementary protection -- they prevent unnecessary file access and dangerous commands, but they are not the last line of defence against secret leakage.
Most of what fermata tries rests on **value masking**, not on path checks. When a command reaches a file no rule looks at, a value in the manifest can still be masked in the output of a tool that succeeds. Many values never reach the manifest: see [Known limits](security-model.md#known-limits).
---
## What fermata catches
## What fermata tries to catch
Fermata's detection operates on two independent tracks: **value-level redaction** (primary) and **path-level access control** (supplementary).
Fermata works on two independent tracks: **value-level masking** and **rules for tool calls**.
### Secret redaction (PostToolUse) -- primary defence
### Secret masking (PostToolUse)
Independent of path-level detection, fermata filters tool output before it enters the LLM context:
- **Known-value redaction** -- `.botsecrets` declares which files contain secrets. Fermata parses those files, extracts the secret values, and replaces them in every string of a successful tool's output using an Aho-Corasick automaton. Sub-millisecond performance. See [Known limits](security-model.md#known-limits).
- **Heuristic scanning** -- regex patterns (derived from gitleaks) detect undeclared secrets in tool output: AWS access keys, JWTs, GitHub PATs, database connection strings, and similar high-entropy tokens. This is a safety net for secrets not covered by the manifest. It warns beside the output and does not mask them.
- **Known-value redaction** -- `.botsecrets` declares which files contain secrets. Fermata parses those files that it has a parser for, extracts the secret values, and replaces them in every string of a successful tool's output using an Aho-Corasick automaton. See [Known limits](security-model.md#known-limits).
- **Heuristic scanning** -- regex patterns (derived from gitleaks) detect undeclared secrets in tool output: AWS access keys, JWTs, GitHub PATs, database connection strings, and similar tokens. It warns beside the output and does not mask them, so they reach the model.
This is the layer that makes fermata's security model resilient. Even if every path-level check fails -- the agent reaches `.env` through a route fermata didn't parse -- the secret values themselves are scrubbed from the output before the LLM sees them.
### Rules for tool calls (PreToolUse)
### Path-level access control (PreToolUse) -- supplementary
The levels below are organised by how the agent names the path it is about to access. Lower levels are easier to detect statically; higher levels require progressively more runtime information.
The path-level checks below are organised by how the agent names the path it is about to access. Lower levels are easier to detect statically; higher levels require progressively more runtime information. These checks prevent unnecessary file access and reduce noise, but they are not the last line of defence.
### L0: Direct path arguments -- fully covered
### L0: Direct path arguments
The agent calls a path-typed tool (Read, Write, Edit) with an explicit file path.
> `Read({"file_path": "/home/user/.env"})` -- `.botignore` matches -- deny.
Both `.botignore` (gitignore semantics, deepest directory wins, negation patterns work as in git) and `.botsecrets [policy]` rules are evaluated against the resolved path. This covers the overwhelming majority of accidental secret-file reads, because most agents use direct path tools as their primary file access method.
Both `.botignore` (deepest directory wins, negation patterns work as in git) and `.botsecrets [policy]` rules are evaluated against the path. This is the only level the hook checks. A `.botignore` directory pattern such as `vendor/` does not match the files below it, unlike in git; `vendor/**` does. A relative path never matches `.botignore`.
### L1: Absolute paths inside Bash commands
@@ -51,7 +49,7 @@ The agent runs a shell command that mentions a full path -- one containing a dir
> `cat /home/user/.env`, `type C:\Users\me\secret.toml`
Fermata's path extraction engine recognises these as high-confidence path candidates and checks them against the same policy rules as L0. Windows paths are handled conservatively (backslashes appear in many non-path contexts), but the common cases are covered.
**Not checked.** The library has a path extraction engine (`core::extract`) that recognises these as high-confidence candidates, and the hook does not call it. A Bash command only meets `[policy.bash]`, whose patterns match the text of the command.
### L2: Bare filenames resolvable in the working directory
@@ -59,7 +57,7 @@ The agent names a file without any path separator, relying on the shell's workin
> `cat .env`, `cat README.md`
These are flagged as low-confidence path candidates. When the agent's working directory is known, fermata resolves bare filenames against it and evaluates them through the policy. Low-confidence detections are biased toward asking the user rather than silently denying, because most bare tokens with file extensions are not actually sensitive paths -- false denials break the agent's workflow and are noticed immediately, while false allows may not be.
**Not checked**, for the same reason as L1.
### L3: Static wildcards in commands
@@ -67,23 +65,17 @@ The agent uses shell glob patterns in a command that could expand to match sensi
> `cat .env*`, `grep SECRET *.toml`, `find . -name '*.pem'`
Fermata handles this by checking whether the glob pattern in the command **overlaps** with any configured policy rule. For example, `.env*` in a command is checked against `.botignore` patterns -- if `.env` is protected, `.env*` is flagged. This does not require enumerating the filesystem; it is a pattern-vs-pattern overlap check.
The limitation: fermata can tell whether a glob *could* hit a protected file, but not whether it *actually will* in the current directory state. For the heuristic threat model, "could hit" is the right bar.
**Not checked**, for the same reason as L1.
---
## What fermata does NOT catch
These are honest boundaries, not future promises. Documenting them is part of the value -- it tells you where you still need other defences.
### L4: Shell indirection
Variable expansion (`cat $SECRET_FILE`), command substitution (`cat $(ls .env*)`), tool composition (`xargs cat < file_list`), and pipelines that route content through intermediate steps.
A real `bash` parser would handle the syntax, but cannot resolve runtime values. Fermata sees the command string, not the expanded result. It can detect the presence of substitution or variable-dereference syntax and escalate to an ask, but it cannot statically evaluate what the command will actually do.
**Why this is acceptable for the threat model:** LLM agents overwhelmingly prefer direct, readable commands. Shell indirection is rare in practice -- agents reach for `cat /path/to/file`, not `cat $(echo /path/to/file)`. The statistical frequency of L4 evasion in non-adversarial agent behaviour is low.
A real `bash` parser would handle the syntax, but cannot resolve runtime values. Fermata sees the command string, not the expanded result, and the hook does not look for this syntax.
### L5: Derived or out-of-band names
@@ -91,19 +83,15 @@ The agent computes a path from sources fermata never sees: its own reasoning, an
> The agent reads a config file, learns about `/etc/app/signing.key`, then reads it in a subsequent call.
**Important:** most derived-name scenarios collapse back to L0 at the moment of the dangerous call. The second read is a direct path-typed tool call, and `.botignore` catches it normally. Fermata does not need to predict the derivation; it just needs the rule to match the resolved path when the call happens.
The genuinely difficult sub-case is when a derived name is used inside L4-style shell indirection -- which is no harder than L4 already is.
**Important:** most derived-name scenarios collapse back to L0 at the moment of the dangerous call. If the second read is a direct path-typed tool call, a `.botignore` rule that matches stops it. If it is a shell command, nothing checks it.
### L6: Application-protocol exfiltration -- out of scope by design
The agent uses a legitimate tool (HTTP client, git push, shell with network access) to move forbidden content to a destination fermata cannot inspect. The content travels as the *payload* of an allowed call, not as a path.
> The agent reads a secret (caught and redacted at L0), but then reconstructs it character-by-character and sends it via an HTTP request.
> The agent reads a secret (masked at L0), but then reconstructs it character-by-character and sends it via an HTTP request.
This is the network-firewall analogy: **you cannot block exfiltration over an allowed application protocol from outside the application.** A packet filter cannot inspect encrypted traffic without MITM; a static policy gate cannot inspect the semantic intent of an allowed tool's payload. Fermata marks this as permanently out of scope.
This is not a failure -- it is a design boundary. Trying to solve L6 within a static policy gate would require either breaking the tool's legitimate use (blocking all network access) or implementing deep content inspection that defeats the latency and side-effect-free constraints that make fermata practical.
This is the network-firewall analogy: **you cannot block exfiltration over an allowed application protocol from outside the application.** A packet filter cannot inspect encrypted traffic without MITM; a static rule check cannot inspect the semantic intent of an allowed tool's payload. Fermata does not try this.
---
@@ -111,39 +99,36 @@ This is not a failure -- it is a design boundary. Trying to solve L6 within a st
| Level | Description | Detection | Confidence |
|-------|-------------|-----------|------------|
| Secret redaction | Known-value + heuristic scanning | Aho-Corasick + regex | High for declared secrets whole in a string |
| L0 | Direct path argument | Full policy check | High |
| L1 | Absolute path in Bash | Path extraction + policy | High |
| L2 | Bare filename in CWD | CWD resolution + policy | Medium |
| L3 | Wildcards in commands | Pattern overlap check | Medium |
| L4 | Shell indirection | Syntax detection only | Low |
| L5 | Derived names | Collapses to L0 at call time | Depends on final call |
| Secret masking | Known-value masking + heuristic warning | Aho-Corasick + regex | Only for values in the manifest, whole in a string of a successful tool. See [Known limits](security-model.md#known-limits) |
| L0 | Direct path argument | Policy check on Read, Write, Edit | Only if a rule matches |
| L1 | Absolute path in Bash | None in the hook | None |
| L2 | Bare filename in CWD | None in the hook | None |
| L3 | Wildcards in commands | None in the hook | None |
| L4 | Shell indirection | None in the hook | None |
| L5 | Derived names | L0 if the final call is a path tool | Depends on final call |
| L6 | Protocol exfiltration | Out of scope | N/A |
Secret redaction is the primary defence layer. Path-level detection (L0--L3) provides supplementary access control; even when it misses, redaction catches the secret values in the output.
---
## Practical implications
Fermata is one layer in a defence-in-depth stack. Here is what it is good at and what to pair it with.
Do not use fermata on a real project. If you try it anyway, this is what it attempts.
### Fermata alone gives you
### What fermata attempts
- **Known-secret scrubbing.** Declared secrets (via `.botsecrets`) are redacted from the strings of successful tools' output, regardless of how they reached the file. A failed tool's error text is out of reach: see [Known limits](security-model.md#known-limits).
- **Heuristic secret detection.** Undeclared secrets matching common formats (AWS keys, tokens, connection strings) are flagged in tool output. Built-in patterns handle most projects without any configuration.
- **Command guardrails.** Dangerous shell patterns (`rm -rf /`, `curl | sh`) are caught by configurable deny lists.
- **Write protection and access control.** Path-level checks (`.botignore`, `.botsecrets [policy]`) prevent unnecessary file access and unauthorised modifications at L0--L3.
- **Masking known secrets.** Values in the manifest are masked in the strings of successful tools' output. A failed tool's error text is out of reach, and many values never enter the manifest: see [Known limits](security-model.md#known-limits).
- **Heuristic warnings.** Undeclared secrets matching common formats (AWS keys, tokens, connection strings) get a warning beside the output, and stay in it.
- **Command rules.** Shell patterns you list (`rm -rf /`, `curl * | sh`) stop a command whose text matches.
- **Path rules.** `.botignore` and `.botsecrets [policy]` stop the Read, Write and Edit tools at L0.
### Combine fermata with
### What real secrets would need instead
- **Network-level controls** for L6 scenarios. If your threat model includes data exfiltration by a compromised or misbehaving agent, restrict outbound network access at the OS or container level. Fermata cannot inspect what an HTTP client sends.
- **Sandboxing / containerisation** for hard isolation. Fermata is a policy gate, not a sandbox. If you need filesystem isolation guarantees (not just heuristic blocking), run the agent in a container with a restricted mount.
- **Secret rotation** as a backstop. If a secret does leak into LLM context through an uncovered path, rotating the secret limits the blast radius. Fermata's redaction makes this unlikely for declared secrets, but rotation is good practice regardless.
- **Audit logging** for visibility. Fermata's decisions can be logged for review. Pairing with an audit trail lets you detect patterns that individual checks might miss.
- **Sandboxing / containerisation** for hard isolation. Fermata is not a sandbox. For filesystem isolation, run the agent in a container with a restricted mount, and do not mount secrets into it.
- **Secret rotation.** If a real secret was in a project with an agent, assume it reached the model and rotate it.
### Design constraints worth knowing
- **Latency budget.** Fermata fires on every tool call and targets single-digit milliseconds. Anything requiring filesystem enumeration or network calls at check time is either opt-in or out of scope.
- **Side-effect-free.** Fermata does not open, move, stat, or modify files outside of its policy resolution. It operates purely on the information the harness provides.
- **False deny vs false allow.** A false deny breaks the agent's workflow and is noticed immediately. A false allow may go undetected. Low-confidence detections bias toward asking the user, not silently denying.
- **Latency.** Fermata fires on every tool call and parses the secret files each time, which is slow for large files: see [Speed](security-model.md#design-principles).
- **No writes.** The hook reads its config and the secret files, walks the project for them, and writes no files.
- **False deny vs false allow.** A false deny breaks the agent's workflow and is noticed immediately. A false allow may go undetected.
+1 -1
View File
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
use std::process::ExitCode;
#[derive(Parser)]
#[command(name = "fermata", about = "Harness-agnostic policy gate for AI coding agents")]
#[command(name = "fermata", about = "An experiment, do not use: hooks around AI agent tool calls that try to mask secrets")]
struct Cli {
#[command(subcommand)]
cmd: Cmd,
+2 -1
View File
@@ -1,4 +1,5 @@
//! `dirigent_fermata` — harness-agnostic policy gate.
//! `dirigent_fermata`: an experiment, do not use. Hooks around AI agent tool calls
//! that try to stop calls by rule and mask secret values in their output.
//!
//! See `docs/tools/fermata.md` (Dirigent integration plan) and
//! `docs/workpad/brainstorm/fermata.md` (product spec).