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.
135 lines
8.3 KiB
Markdown
135 lines
8.3 KiB
Markdown
# Fermata Threat 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](security-model.md#known-limits) for where it fails.
|
|
|
|
What fermata tries to catch, and where it stops.
|
|
|
|
---
|
|
|
|
## Framing: an experiment, not a sandbox
|
|
|
|
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.
|
|
- **Prompt-driven mistakes** -- the user's prompt or a tool's output nudges the model into touching something it shouldn't, without anyone meaning to.
|
|
|
|
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.
|
|
|
|
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 tries to catch
|
|
|
|
Fermata works on two independent tracks: **value-level masking** and **rules for tool calls**.
|
|
|
|
### 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 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.
|
|
|
|
### Rules for tool calls (PreToolUse)
|
|
|
|
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.
|
|
|
|
### 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` (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
|
|
|
|
The agent runs a shell command that mentions a full path -- one containing a directory separator or drive letter.
|
|
|
|
> `cat /home/user/.env`, `type C:\Users\me\secret.toml`
|
|
|
|
**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
|
|
|
|
The agent names a file without any path separator, relying on the shell's working directory to resolve it.
|
|
|
|
> `cat .env`, `cat README.md`
|
|
|
|
**Not checked**, for the same reason as L1.
|
|
|
|
### L3: Static wildcards in commands
|
|
|
|
The agent uses shell glob patterns in a command that could expand to match sensitive files.
|
|
|
|
> `cat .env*`, `grep SECRET *.toml`, `find . -name '*.pem'`
|
|
|
|
**Not checked**, for the same reason as L1.
|
|
|
|
---
|
|
|
|
## What fermata does NOT catch
|
|
|
|
### 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, and the hook does not look for this syntax.
|
|
|
|
### L5: Derived or out-of-band names
|
|
|
|
The agent computes a path from sources fermata never sees: its own reasoning, an HTTP response, a previous tool's stdout that the harness reused as input.
|
|
|
|
> 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. 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 (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 rule check cannot inspect the semantic intent of an allowed tool's payload. Fermata does not try this.
|
|
|
|
---
|
|
|
|
## Coverage summary
|
|
|
|
| Level | Description | Detection | Confidence |
|
|
|-------|-------------|-----------|------------|
|
|
| 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 |
|
|
|
|
---
|
|
|
|
## Practical implications
|
|
|
|
Do not use fermata on a real project. If you try it anyway, this is what it attempts.
|
|
|
|
### What fermata attempts
|
|
|
|
- **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.
|
|
|
|
### 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 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.** 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.
|