Skip to content

Security: EliFebres/anvil

Security

SECURITY.md

Security

Anvil is a coding agent harness for open-weight models in regulated, restricted-network environments.

This page is for the IT security and platform teams deciding whether Anvil may run on their machines. It describes what the code in this repository does, with a file reference for every claim, so each one can be checked. The test behind each claim is in docs/SECURITY_TESTS.md, cited here by its identifier (NET-1, FS-3, ...); a test fails the build when a test named there no longer exists. Anvil holds no certification and has had no independent security assessment.

Reporting a vulnerability

Report a vulnerability privately through GitHub: on the repository's Security tab, choose Report a vulnerability (GitHub private vulnerability reporting), which opens a private security advisory visible only to the maintainers. Do not open a public issue for a vulnerability. Include the version (anvil --version), the operating system, whether a managed policy was installed, and the steps that show the problem. The advisory is the channel for follow-up and for the fix. If the Report a vulnerability button is not shown, private reporting is not switched on for the repository; open a public issue that asks the maintainers for a private channel and contains no details of the problem.

Scope

Anvil is one binary on the machine where it runs, usually a developer workstation. It never runs a model: it sends prompts, and the files and command output its tools read, to model endpoints someone else operates.

party responsible for
Anvil What the agent may read, run, send and store on the machine where Anvil runs; enforcing the limits an administrator sets; the record it leaves. Everything in "Boundaries" below is enforced in-process by the same code on Windows, macOS and Linux; CI runs the tests on Windows and Linux only, so the macOS build is released but not tested in CI.
The model host (an internal model server, a private cloud GPU, or an API vendor) That machine and the model on it: patching, network exposure, authentication, logging and retention of prompts, and who can read what it receives. Anvil sends it the task, the instruction files, the files and command output the tools read, and the conversation so far. Treat everything a session reads as sent to the host.
The organization's IT Who may run Anvil, on which machines and repositories, with which policy; the network around it (firewall, proxy, internal CA); the operating system account it runs under and any sandbox or endpoint monitoring around it; collecting the audit mirror; review of every change through pull requests.

docs/DEPLOYMENT.md has reference layouts and the full shared responsibility table; docs/THREAT_MODEL.md has the actors and the OWASP Top 10 for Agentic Applications mapping.

The one thing to know first. In the default ask mode on the host, a shell command the user approves runs with the user's own rights. Anvil does not sandbox it at the operating system level, and its command-text checks are a guard rail, not a boundary. The boundaries for commands are [shell] mode = "off", "allowlist" (no shell, listed programs only) and executor = "container" (no network, workspace only). See "What is not enforced".

Who sets the limits

Limits come in layers. A higher layer can only be tightened by a lower one, never loosened, and a conflict is an error that names the key, never a silent override.

  1. The managed policy, installed by an administrator at a fixed system path (/etc/anvil/policy.toml on Linux and macOS, C:\ProgramData\anvil\policy.toml on Windows). Nothing below it can loosen it. Without the file Anvil runs unmanaged and says policy: unmanaged at every session start.
  2. The user's own files: ~/.anvil/config.toml, an optional --profile, the rules an always answer saved under ~/.anvil/permissions/, and command-line flags.
  3. The repository Anvil runs in. Untrusted, it may only add deny, ask and shell_programs rules. What it ships that would give it power (hooks, MCP servers, skills, commands, agents, instruction files, allow rules) takes effect only after the user trusts that exact content, and under a policy only when [projects] allow_trust = true.

The policy is described in "Managed policy" below; every key and its default is in docs/ADMIN_GUIDE.md.

Boundaries

Network: where requests may go

Every HTTP request Anvil makes goes to a model endpoint or an HTTP MCP server, through one client built in one function, http_client in crates/anvil-core/src/net.rs. HttpRequest::send checks each request before a connection is made, so no caller can skip the check.

  • Where. Unmanaged, a request may go only to a host:port the user's configuration names: a provider base_url, or the url of an HTTP MCP server in ~/.anvil/mcp.toml or, once the repository is trusted, in its .mcp.json or .claude/settings*.json. Under a policy, only to a pair in [network] allowed_hosts (Egress in net.rs; NET-1, NET-9). A provider or HTTP MCP server in the user's configuration whose host the policy does not allow stops Anvil at startup with an error naming [network] allowed_hosts (Wiring::check_endpoints, crate::policy::check_config; NET-8).
  • No redirects. The client never follows a redirect, so a server cannot pass a request or its key to another host (NET-2).
  • Plain http. http:// is accepted only for loopback (localhost, 127.0.0.0/8, ::1), unless the host is in the user's [network] allow_http_hosts (unmanaged) or the policy sets require_tls = false (managed). Every provider base_url is checked when the configuration loads, for every command (check_plain_http in crates/anvil-cli/src/main.rs); every configured endpoint again when a session starts; and every request when it is sent (NET-3). Under a policy, the user's allow_http_hosts is an error naming [network] require_tls.
  • Keys go only to their own host. An API key, and each header an HTTP MCP definition sets, is added after the URL is checked and only when the request's host:port is that of the URL it was configured with (HttpRequest::api_key; NET-4).
  • Proxy and TLS. No proxy is used unless the policy's [network] proxy says so: HTTPS_PROXY, HTTP_PROXY, ALL_PROXY and NO_PROXY are ignored in the default mode none; system uses them or the system settings; a URL sends every request through that proxy (NET-5). The policy's ca_bundle replaces the system trust store; client_cert and client_key are presented for mutual TLS (NET-6). Anvil reads these files when it builds the client and stores nothing.
  • One client. Only net.rs may build or hold an HTTP client, only anvil-core depends on reqwest, no crate depends on another HTTP client, and no non-test code outside net.rs names a socket type. clippy.toml (disallowed-types), deny.toml ([bans]) and crates/anvil-core/tests/one_http_client.rs enforce it (NET-7).
  • Inspection. anvil doctor --egress lists every destination the HTTP client can reach under the current configuration, what uses it, the endpoints the rules refuse, and the proxy and TLS settings, without sending anything (crates/anvil-cli/src/doctor/egress.rs; NET-10). Local MCP servers, hooks and shell commands are programs that make their own connections; it does not list those.

Anvil sends no usage data anywhere. It has no self-update, no update check, no web search or web fetch tool and no background process. The removed features (self-update, webhooks, tickets and the ticket queue, herdr reporting, learning from the owner's edits, downloading skills) are gone from the code; a configuration that still sets [update], [notify], [tickets], [telemetry], [integrations] or the old table of ticket signal thresholds fails to load and says why (crates/anvil-types/src/config.rs).

destination what triggers it on by default
Model providers: each [providers.<name>] base_url. anvil setup writes one example, https://models.internal.example/v1, to be replaced; anvil setup --endpoint <url> writes one provider for the given server; hosted APIs are only ever added by hand; there is no built-in default (crates/anvil-types/src/config.rs). Requests go to {base_url}/messages or {base_url}/chat/completions (crates/anvil-core/src/provider/). Every model turn of anvil run, chat, resume and build. Also, inside a session: context compaction and the end-of-session memory summarizer (off under a policy unless [features] memory = true). anvil doctor sends a one-token request to every configured provider. Yes, whenever those commands run.
The model list of an endpoint being set up: GET {url}/models (and {url}/v1/models when the URL has no /v1), with the key as a bearer token when it is set (crates/anvil-core/src/provider/models.rs). Same egress rules as providers. anvil setup --endpoint <url> only. No.
HTTP MCP servers: each definition with a url (streamable HTTP, one POST per message), with the headers the definition sets. Sources: ~/.anvil/mcp.toml and, for a trusted repository, its .mcp.json and .claude/settings*.json (crates/anvil-compat/src/mcp/). The older SSE transport is refused. When a session starts (to list its tools), and when one of its tools is called. Under a policy only when [features] mcp allows the server by name and URL and its host:port is allowed. Only when such a file defines one.
Local MCP servers: programs Anvil starts (a command), from the same files. They make their own connections, which the rules above do not cover. When a session starts. Under a policy only listed commands start. Only when such a file defines one.
The proxy named by the policy's [network] proxy, or by the proxy variables or system settings when it is system. Every request, when set. No.
Hooks: shell commands from ~/.claude/settings.json, ~/.anvil/settings.json and, for a trusted repository, its .claude/settings*.json and .anvil/settings.json (crates/anvil-compat/src/hooks.rs). They can do anything a shell command can. At session start and around tool calls once defined. Off under a policy unless [features] hooks = true. Only when such a file defines hooks.
The shell tool: whatever command the model runs, once approved, in ask mode on the host. The built-in deny categories refuse network clients by their command text; with executor = "container" the command has no network at all and the engine runs with --pull=never, so it contacts no image registry either. A model turn; asks first by default. Under a policy the tool is absent unless [shell] mode turns it on. Asks.

Files: what the file tools may open

Every file tool (read_file, write_file, edit_file, glob, grep, list_dir, outline) passes its path through ToolContext::checked_path (crates/anvil-core/src/tools/mod.rs) and crates/anvil-core/src/tools/workspace.rs before opening anything. It refuses; it never asks.

  • The workspace. A path is resolved the way the file system will resolve it (symlinks, .., junctions, drive and UNC prefixes and letter case, permissions::resolve_path) and must lie inside the project root, the session folder or a folder in [tools] extra_dirs (unmanaged) or the policy's [files] extra_roots (read-only); installed skill folders may be read (FS-1). A spelling Windows would fold onto another name (a trailing dot or space, or : after the drive prefix) is refused for reads, searches and writes on every system, so the path checked is the path opened (workspace::win32_fold; FS-2).
  • Secret files, inside the workspace too, are refused, and glob, grep and list_dir leave them out: .env and .env.* (not .env.example, .sample or .template), *.pem, *.key, *.pfx, *.p12, *.ppk (PuTTY keys), *.jks and *.keystore (Java key stores), *.kdbx (KeePass), id_rsa*, id_ed25519*, id_ecdsa*, id_dsa*, credentials*, .netrc, .npmrc, .pypirc, .pgpass, .git-credentials, a repository's .git/config, .ssh, .aws, .azure, .config/gcloud, .kube, .docker/config.json, .gnupg, ~/.anvil/.env, Chrome, Edge and Firefox profiles, and the macOS, Linux and Windows keychains and credential stores. The policy's [files] deny globs are added (holds_secrets; FS-3).
  • Git directories are never written: .git at any depth, worktree and submodule git directories, and bare or separate git directories, so a tool cannot plant a hook or change .git/config (inside_git_dir; FS-4). Reading the rest of .git is allowed.
  • Files that grant power are never written, under any rule, profile, pre-approval, --yes or answer: .anvil/config.toml, .anvil/permissions.toml, settings*.json in a .claude or .anvil folder, .mcp.json, anywhere and in any letter case, and anything under ~/.anvil (grants_power, Workspace::protected_dirs; FS-5). A file inside the workspace that a loaded hook or MCP server names on its command line (sh scripts/fmt.sh) is never written either, nor anything in that file's folder, recursively, because a script loads its neighbours; those files are part of the trust digest too (command_files, Workspace::protected_files; FS-6). A script in the project root therefore closes the whole project to the file tools. FS-6 cannot know the files a build tool runs: a hook that runs npm run lint, make or cargo executes package.json scripts, a Makefile or build.rs, which the model can write, so a trusted repository's hooks can run model-written code. Under a policy, repository hooks run only with both [features] hooks and [projects] allow_trust set.
  • Anvil's own records are never written by the file tools: the sessions root with every transcript and audit log, .anvil/builds, .anvil/logs, .anvil/usage and the audit mirror, in any letter case. The only file there a model may write is the current session's plan.md, which Build corrects when the plan is wrong (Workspace::records_dirs, Wiring::records_dirs; FS-7). A shell command on the host is not bound by this; the mirror is the copy it cannot reach when IT collects it elsewhere.
  • What a write changes. edit_file replaces only the text it matched and leaves every other byte of the file as it was. It matches whether the old text and the file use LF or CRLF line endings, gives the replacement the ending of the lines it replaces, and keeps a byte order mark; spaces, tabs and indentation must match exactly. write_file writes CRLF when it replaces a file that uses CRLF throughout with content that uses LF only, and otherwise writes the content as given. When edit_file finds no match, its error shows file lines only from the one region it names (where the old text's first line occurs, or the line whose white space differs), at most 20 lines of at most 160 characters and 4096 bytes in all (crates/anvil-core/src/tools/edit_file.rs, edit_hint.rs, line_endings.rs; FS-8).

Programs: what Anvil starts and what they inherit

  • A cleared environment. Every program Anvil starts (shell commands, checks, acceptance commands, hooks, MCP servers, rule checks, git, and the probes of anvil doctor and anvil setup) starts from env_clear() plus a short list from crates/anvil-types/src/child_env.rs: PATH, the home, user and temp variables, the locale, TERM, NO_COLOR, the variables Windows needs to start programs, CARGO_HOME and RUSTUP_HOME, and the names in [tools] pass_env. Provider keys, and any variable whose name contains KEY, TOKEN, SECRET, PASSWORD, PASSWD or CREDENTIAL, pass only when [tools] pass_env lists that exact name. crates/anvil-core/tests/children_start_clean.rs fails the build when non-test code builds a Command, under any use ... as or type alias, whose own builder chain or variable does not call env_clear() before the program starts or the builder is passed on, and when any code passes the parent's environment back with .envs(std::env::vars()) or vars_os(); comments and string literals are blanked first (KEY-4). An MCP definition's ${VAR} may name only a variable from that list (McpServer::launch in crates/anvil-compat/src/mcp/mod.rs; KEY-5).
  • Shell modes. [shell] mode in the user's configuration, or in the policy, which beats it, decides how the shell tool runs commands (crates/anvil-types/src/shell.rs, crates/anvil-core/src/tools/shell.rs, crates/anvil-cli/src/wiring/shell.rs):
    • off (the default under a policy): the tool is not registered for the session or its subagents; detected and planned checks do not run; anvil build refuses to start (SH-1).
    • allowlist: a conservative parser (anvil_types::shell::split_command) splits the command into words and refuses ;, &, |, <, >, backticks, $(, parentheses, braces, line breaks and NUL. The words must match an argument-prefix pattern such as cargo test * in every layer (the policy's [shell] allow, the user's, each shell_programs list), and the program starts directly with no shell (Permissions::shell_refusal, Runner::direct; SH-2). Arguments a pattern's * leaves to the model may not name a path outside the project, and git takes no option before its subcommand except seven harmless ones, runs only status, diff, log, show, rev-parse, ls-files, blame, branch, add, commit, restore, switch, checkout, stash, merge-base, describe, shortlog, cat-file, grep and tag (list only) whatever the pattern (so rebase --exec, bisect run, submodule foreach, difftool, fetch and config are refused even under git *), and takes none of the options that write a file, read outside or start a program (shell::argument_refusal, git::allowlisted; SH-3). An allowed program's own behaviour is not limited: cargo test runs build scripts and tests the model can write.
    • ask (the unmanaged default): the command runs in the configured shell after the permission rules and, unless a rule allows it, a person.
  • Deny categories. In every mode, under --yes too, the built-in categories refuse network clients (curl, wget, Invoke-WebRequest, iwr, Invoke-RestMethod, irm, nc, ncat, netcat, ssh, scp, sftp, ftp, Start-BitsTransfer, bitsadmin), git push, git clone, git fetch, git pull, git ls-remote, git submodule, git remote add and set-url, a git alias defined with -c or --config-env, package installs (pip install, npm install, cargo install, gem install), privilege tools (sudo, runas, doas) and rm -rf, Remove-Item -Recurse, git push --force and git reset --hard. Only a rule or allowlist pattern whose text names the command lifts one (deny_category, Permissions::allows_by_name; SH-4). The command is matched as written and again with quotes, backticks and carets removed and runs of white space collapsed, so c''url and rm -rf are found. They match command text, so in every host mode, --yes included, a shell can get around them (& ('cu'+'rl'), a .NET web client, a script file): they are a guard rail, not a boundary.
  • The container executor. With executor = "container" each command runs through docker or podman as run --rm --pull=never --network none --read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges --user <user> --pids-limit <n> --memory <m>, with the workspace bind-mounted at /workspace as the only host folder and its .git mounted again read-only. The user may not be root in any spelling (container_args, ContainerSettings::validate; SH-5, SH-6). Defaults: 65534:65534, 256 processes, 2 GB. The rest of the workspace is writable by design.
  • Anvil's own git calls (snapshots, diffs, build commits, file lists) go through anvil_core::git::command (crates/anvil-core/src/git.rs), which passes core.hooksPath=/dev/null, core.fsmonitor=false, --no-pager, core.editor=:, sequence.editor=: and protocol.allow=never as -c settings, adds --no-ext-diff --no-textconv to diffs, and refuses a repository whose own config names a filter or signing program. crates/anvil-core/tests/one_git_entry.rs keeps every project git call on that path (SH-7). This needs git 2.26 or later.
  • Checks. A check command anvil detects from the repository's files (just check, cargo test, npm test, python -m pytest) runs the repository's own code, so it is asked about like any shell call; anvil build runs each acceptance command only after the same rules allow it (AgentLoop::project_check, Wiring::permit_shell; SH-8).

Permissions: who decides each call

  • Every tool call is decided by ToolRegistry::check_permission (crates/anvil-core/src/tools/mod.rs) against Permissions (crates/anvil-core/src/tools/permissions.rs), assembled in Wiring::registry_without_delegate: the user's rules, then the repository's deny, ask and shell_programs, then the policy's deny and ask, then each shell allowlist. Tightening rules are kept apart from the user's, so they can only make a call stricter.
  • The order is fixed: the allowlist refusal, then the deny categories, then a deny from any layer, then a repository or policy ask, then the user's allow and ask, then the user's default, then a trusted repository's allow, then the tool's own default. A repository's allow never lifts a deny category or an allowlist (PERM-1, PERM-2).
  • Without rules, reading tools (read_file, glob, grep, list_dir, outline, delegate, skill, read-only MCP tools) run; write_file, edit_file, shell and every other MCP tool ask. In the Plan state a tool that may write is refused.
  • A prompt offers yes, no, session (this tool for the rest of the session; for path tools only inside the project root) and, for shell only, always (saves shell:<first word> * to the user's own file for the repository, never into the repository). Under a policy, always saves nothing unless allow_always = true (PERM-3).
  • --yes answers every prompt and approves plans; deny rules, the shell mode and allowlist, the deny categories and the refusal to write files that grant power still apply. Under a policy, --yes is refused unless allow_yes = true, and --allow-tool unless allow_allow_tool = true; require_plan_approval makes a person approve every plan.
  • Subagents (the delegate tool) get the same registry rules, file boundary, shell mode, allowlist, runner and policy through the same two functions, Wiring::registry_without_delegate and Wiring::tool_context (PERM-4).

The repository: what a cloned repository can change

A repository you clone cannot change how Anvil treats you (crates/anvil-types/src/project.rs, crates/anvil-cli/src/trust.rs, crates/anvil-types/src/trust.rs):

  • Its .anvil/config.toml may only add deny, ask and shell_programs. A [providers] table (and so any base_url), [roles], [tools], [network] or [shell], or an allow, default or allow_tools key, stops Anvil with an error naming the key and the file (TRUST-1). Its .anvil/permissions.toml may add the same three keys and allow rules, which wait for trust. Its .anvil/.env is never loaded (crates/anvil-types/src/dotenv.rs; KEY-1).
  • Its hooks, MCP servers, skills, slash commands, agents, instruction files (ANVIL.md, CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, nested CLAUDE.md files) and allow rules take effect only after the user trusts the repository (TRUST-2). The first interactive session lists every item, with the command line of each hook and MCP server exactly as written, and asks once.
  • The answer is kept in ~/.anvil/trust.toml with a SHA-256 digest (fingerprint) over everything listed above, every script a hook or MCP server names, and every file under the skills, commands and agents folders. Any change asks again (TRUST-3). A repository with a symbolic link or junction in those folders is never trusted (linked_item; TRUST-4). With --plain, --yes, no terminal, or a command that never prompts, an undecided repository is untrusted and nothing is recorded. Under a policy without [projects] allow_trust = true, no repository is trusted (TRUST-5).
  • Even trusted, an instruction file's @path import may only name a file inside the repository (crates/anvil-compat/src/instructions.rs; TRUST-6).
  • Every session start lists each MCP server live. The listing (each tool's name, title, description, input schema and all annotations, readOnlyHint included) is approved by SHA-256 together with a digest of the definition; a listing or definition that later differs stops the server until anvil mcp approve <name>. Under a policy only a listing_sha256 pin accepts a listing, and anvil mcp approve is refused (crates/anvil-compat/src/mcp/approval.rs; TRUST-7).

Data: what reaches the model and what stays on disk

  • Redaction. Every tool result, file read, MCP result and hook output, the task, user messages, check output and the reviewer's brief pass through one redactor before they enter the conversation, so the provider and the transcript receive the same text (crates/anvil-types/src/redact.rs, DataGuard in crates/anvil-core/src/guard.rs, ToolRegistry::execute, AgentLoop::push_message; RED-1). It replaces the built-in key shapes (sk-, AIza, ghp_, github_pat_, hf_, AWS access key ids, PEM private key blocks and bodies, JWTs), the values of secret-looking environment variables and of every api_key_env, and the policy's [data] patterns with [REDACTED:<kind>] (RED-2). read_file and grep redact a whole file before they choose lines, and edit_file does the same before its not-found error shows any (RED-3). Every log line is redacted at the sink (Redacting in crates/anvil-cli/src/logging.rs; RED-4). Only the policy can turn redaction off, and Anvil then prints a note (RED-5).
  • Untrusted-data delimiters. Tool results, file contents, MCP results and hook output reach the model inside <untrusted-data id="NONCE"> delimiters with a random nonce per session. Marker-like text inside the content is escaped: any case, up to three separators of any kind, zero-width characters, fullwidth and mathematical letters, the angle-bracket lookalikes U+2039, U+2329, U+27E8, U+27EA, U+276C, U+276E, U+2770, U+29FC, U+3008, U+300A, U+FE64, U+02C2, U+1438 and U+226A, slash and dash lookalikes, the Cyrillic, Greek and Armenian letters that look like those of untrusted and data, and &lt, &#60 and &#x3c with or without their ;. Other lookalikes are not mapped, and the closing marker needs the nonce, which the content cannot know. The base prompt (crates/anvil-core/prompts/base.md) says delimited text is data (DataGuard::wrap, escape_markers; RED-6).
  • Environment. The system prompt tells the model the operating system family (Windows, macOS or Linux), the path separator and how the shell tool starts commands: the shell and its flags, direct start without a shell under an allowlist, or sh in a Linux container. The shell tool description says the same. The shell is named by its file name only, so a configured path, a user name or a home folder never reaches the model, and with [shell] mode = "off" no shell is mentioned (environment_section in crates/anvil-core/src/agent/prompts.rs, shell_fact in crates/anvil-core/src/tools/shell.rs; RED-7).
  • Transcripts. The policy's [data] transcript decides what a session folder keeps: full, metadata (sizes, digests, tool names, token counts, timings; no text) or off (the default under a policy: no session.jsonl). Below full no untruncated tool output or compaction file is written and anvil resume refuses (SessionRecord::kept_as in crates/anvil-core/src/context/session.rs; DATA-1). Below full the memory summarizer does not run, and with [features] memory off nothing under ~/.anvil/memory is read or written (memory::policy_skip_reason in crates/anvil-cli/src/memory.rs; DATA-5).
  • Owner-only files. On Unix every file below is created 0600 and every folder 0700, and an existing one is narrowed when Anvil writes to it again (crates/anvil-types/src/private_fs.rs; DATA-2). On Windows files inherit their folder's access list; anvil doctor fails a row when others can open ~/.anvil, .anvil, transcript_dir or mirror_dir and prints the icacls command that fixes it (DATA-3).
  • Retention. anvil purge --older-than <days>, and the policy's retention_days at session start, delete session and build folders by age; a folder whose status lock a running process holds is skipped (policy::prune_sessions, policy::prune_all in crates/anvil-cli/src/policy.rs; DATA-4).

Nothing Anvil records leaves the machine; there is no upload code.

what where content
Session transcripts <project>/.anvil/sessions/<id>/, or under the policy's transcript_dir (one subfolder per repository, <slug>-<12 hex digits of the SHA-256 of its path>) session.jsonl (the conversation as the provider received it, after redaction, in the mode [data] transcript sets), tool-output/ (untruncated, redacted outputs, full only), compaction-<n>.md (full only), git-index (git's index for the session's baseline: every path in the project, no contents), status.json, plan.md and summary.md. A chat keeps no conversation: its session.jsonl, written only when something was redacted and the mode is not off, holds redaction counts.
Audit log <session folder>/audit.jsonl; <project>/.anvil/builds/<id>/audit.jsonl for a build's acceptance decisions; <mirror_dir>/<id>.audit.jsonl when the policy sets [audit] mirror_dir One hash-chained record per event (see "Audit log"). Written whatever the transcript mode. Deleted with its folder by retention_days and anvil purge, never while the session runs, and never the mirror.
Usage records <project>/.anvil/usage/<date>.jsonl and a copy in ~/.anvil/usage/ Content-free: provider, model, tokens, latency, retries, stop reasons, tool names with argument and result sizes and digests, permission decisions, check results by program name and command digest. The project path is stored as a digest.
Logs <project>/.anvil/logs/ Structured logs; ANVIL_LOG sets the level. Requests are logged by URL and attempt, never with headers. Every line is redacted before it is written.
Build state <project>/.anvil/builds/<id>/ state.json (work items: titles, acceptance commands, status, spend) and status.json.
Memory and rules ~/.anvil/memory/, ~/.anvil/rules.toml Facts and rules the user chose to keep.
Project templates ~/.anvil/templates/<name>/ A copy of the files anvil template save was given (minus ignored files and .git).
Installed skills ~/.anvil/skills/<name>/ (or the project's skills folder with --project) A copy of the skill folder anvil skill add was given.
Trust decisions ~/.anvil/trust.toml Each repository id the user answered the trust prompt for, the answer, and the SHA-256 digest of what it shipped.
Saved permission rules ~/.anvil/permissions/<repository id>.toml The rules an always answer saved.
MCP listing approvals ~/.anvil/mcp-approvals.toml Per repository (or user) and server name, the SHA-256 of the definition and of the approved tool listing.
Configuration and key ~/.anvil/config.toml, ~/.anvil/.env Written by anvil setup and anvil config init, then by the user.

The .gitignore of this repository keeps .anvil/usage/, .anvil/sessions/, .anvil/logs/ and .anvil/builds/ out of commits; other projects need the same lines.

API keys

  • Each provider names the environment variable that holds its key (api_key_env); the key is read from the process environment when the provider is built (crates/anvil-core/src/provider/mod.rs). Keys never appear in configuration files, and provider definitions come only from the user's own configuration or profile.
  • At startup Anvil fills the environment from ~/.anvil/.env without overriding anything already set (crates/anvil-types/src/dotenv.rs; KEY-1).
  • The key goes only to its provider's host:port (NET-4), is never logged, and an error body that repeats it is redacted (send_attempt in crates/anvil-core/src/provider/http.rs; KEY-2). An HTTP MCP server's header values are scrubbed from its error bodies the same way (scrub in crates/anvil-compat/src/mcp/http.rs; KEY-3).
  • Under a policy that sets [network] client_cert and client_key, Anvil reads that private key from the policy's absolute path each time it builds its HTTP client and uses it only for the TLS handshake. The file tools refuse key files, so the model cannot read it.
  • anvil setup writes ~/.anvil/.env and makes it private: mode 600 on Unix; on Windows it reads the access list and prints the command that removes a grant to other users (crates/anvil-cli/src/setup.rs).
  • anvil scan-keys (part of just check and CI) fails when a tracked file holds a key shape or a value of 12 or more characters from the user's .env files, reporting the file and line, never the value (crates/anvil-cli/src/secrets.rs; KEY-6). Private key blocks are redacted but not scanned for, because repositories commit test keys on purpose (this one does, for its TLS tests).

Audit log

Every session (run, chat, resume, and each work item of anvil build) opens audit.jsonl in its session folder before its first model request, and a build opens one in its build folder for the decisions on its acceptance commands (SessionAudit::open in crates/anvil-cli/src/audit.rs, AuditLog in crates/anvil-audit/src/audit/log.rs). Records are written the moment an event happens, on the thread that emits it.

  • What is recorded. Session start (providers by host and model, roles, switches), prompts, model requests (provider, host, model, tokens, redaction count), tool calls, permission decisions with their source (policy, user, project or built-in rule, allowlist layer, session approval, a person, --yes, or nobody to ask), tool results (size, SHA-256, error, exit code), file changes from write_file and edit_file (SHA-256 before and after), plan answers, policy refusals naming the key, and the session end; subagents included under their name (AUD-7, AUD-8, AUD-9). Prompts and tool arguments are kept as size and SHA-256 ([audit] record = "digest", the default) or as redacted text ("full").
  • Each record has seq, ts (UTC), session, agent, user, host, version, commit, binary_sha256, policy (sha256:<hex> of the policy file or unmanaged), the event, prev (the previous record's hash; 64 zeros for the first) and hash.
  • Canonical form. The hash is the SHA-256 of the record's compact JSON with its fields in that order and without hash; the stored line is that JSON with ,"hash":"<hex>" before the closing brace. verify re-serializes each record and requires the same bytes, so each record has exactly one valid line (seal and verify in crates/anvil-audit/src/audit/chain.rs; AUD-1). anvil audit verify and anvil audit show also require at least one record and a first record of type session_start (verify_log), so an emptied log or one whose head was removed is a break. crates/anvil-audit/src/audit/verify_audit.py checks a file by the same rules without Anvil, and a test requires the same verdict (AUD-3).
  • Commands. anvil audit verify <session id or file> [--mirror <file>] exits 1 at the first break, naming the line, and when the file and the mirror differ; anvil audit show prints one line per record and the verdict (AUD-2).
  • Mirror. With [audit] mirror_dir the same lines go to <mirror_dir>/<id>.audit.jsonl. A missing or empty mirror first gets a copy of the session file; a mirror with other bytes stops a required log (AUD-4).
  • Fail closed. Under a policy [audit] required defaults to true: a log or mirror that cannot be opened stops the session before it starts, and after a failed write no model request, tool call, hook or check command runs and the command exits non-zero. A log file that something else removed, replaced, cut or appended to is a failed write (CallGate, HookRunner::with_gate, Output::write; AUD-5, AUD-6, AUD-10). Unmanaged, the log is written but not required.

Managed policy

An administrator installs one policy file that nothing below it can loosen (crates/anvil-types/src/policy/mod.rs, crates/anvil-types/src/policy/ownership.rs, crates/anvil-cli/src/policy.rs). policies/restricted.toml and policies/standard.toml are commented examples; docs/ADMIN_GUIDE.md lists every key with its default, and a test keeps that list equal to the schema (POL-8).

  • Location. A literal in the binary: /etc/anvil/policy.toml on Linux and macOS, C:\ProgramData\anvil\policy.toml on Windows (system_path). No environment variable, flag, profile or configuration key moves it, and the Windows path is not read from %ProgramData% (POL-1).
  • Ownership. Before the file is read, ownership::check makes sure only an administrator can change it: on Unix the file and its folder must be owned by root and not writable by group or others; on Windows the owner of each must be Administrators, SYSTEM or TrustedInstaller and no access-control entry may give anyone else a right that writes, deletes or takes over either. The Windows access list is read as SDDL from Get-Acl, with PowerShell started by its full path, a cleared environment and no profile (POL-2).
  • Failure. A policy file that exists but is unsafely owned, unreadable, does not parse, has an unknown key, names another version than 1 or breaks one of its own rules stops Anvil before it does anything else, with the reason (POL-3). Only a missing file is unmanaged.
  • Precedence. The policy outranks the user's configuration, a --profile, environment variables (a home chosen through ANVIL_HOME included), command-line flags and the repository. A conflicting lower layer is an error naming the policy key (check_flags, check_config, check_build in crates/anvil-cli/src/policy.rs, Wiring::with_policy; POL-4). Hooks, MCP servers and skills the policy forbids are errors in the user's own files under ~/.anvil or ~/.claude; the same items shipped by a trusted repository are left out with a note naming the key (POL-5).
  • Defaults. Every key except version and [network] allowed_hosts defaults to the restrictive choice: no shell, no MCP, hooks, skills, memory, anvil build or delegation, no trust in repositories, no --yes, --allow-tool or saved always rules, no transcript, a required audit log.
  • Where it is applied. At startup in crates/anvil-cli/src/main.rs (loading, flags, configuration, anvil build, trust), and inside a session in one function, Wiring::with_policy in crates/anvil-cli/src/wiring.rs, plus Wiring::registry_without_delegate and Wiring::tool_context, which subagents share.
  • Commands. anvil policy show prints every key with the layer that set it, then every user setting the policy constrains; anvil policy check <file> [--ownership] validates a file before rollout; anvil doctor has policy, policy:ownership and policy:sha256 rows (POL-7).

What is not enforced

  • Approved shell commands on the host are not sandboxed. In ask and allowlist mode on the host they run with the user's rights, can read any file the user can read and reach any host the user can reach. The file boundary applies to Anvil's file tools, not to programs a command starts. The deny categories match command text, so in every host mode, --yes included, a shell can hide a command from them (a variable, an alias, string concatenation, a script file): they are a guard rail. allowlist mode limits which programs start and with which arguments, not what an allowed program then does (cargo build runs build scripts, just runs recipes, npm test runs scripts, all of which the model can write; programs set in the user's own git config run). The container executor is the boundary for that. An operating system sandbox for the host is on the roadmap (docs/ROADMAP.md).
  • The container executor relies on the container runtime. Anvil builds the arguments; the isolation is docker's or podman's. The image is whatever the configuration names, so pin it by digest and pre-load it. Hooks and MCP servers are not run in the container. The workspace mount is writable, so a container command can change scripts and build files that later run on the host.
  • Everything a session reads goes to the model host, and redaction catches only known shapes. A password in a configuration file, a connection string, customer data, a key in another format, or a known key that is encoded or split across lines is sent and stored like ordinary text. The model's own messages and tool arguments are not redacted; they can only repeat what it was sent.
  • The untrusted-data delimiters are a mitigation for prompt injection, not a guarantee. A model can still follow instructions it was told to treat as data. The permission rules, the file boundary and the shell modes are what limit the result.
  • MCP listing approvals detect a change the server makes, not one the user makes. ~/.anvil/mcp-approvals.toml is the user's file; deleting it makes the next listing count as the first. A policy's listing_sha256 pin does not depend on it.
  • Below full, the plan and summary stay. In metadata and off modes plan.md and summary.md are still written; retention_days and anvil purge remove them with the folder.
  • On Windows, files inherit their folder's access list. Anvil does not change access lists; anvil doctor reports a folder others can open, with the fix. It checks the folder, not each file in it.
  • A shell command can still write the files that grant power. The refusal covers the file tools only. An approved shell command (on the host, or in the container, whose workspace mount is writable) can write .anvil/permissions.toml, .mcp.json, a script a hook runs, or, on the host, ~/.anvil/config.toml. A change to a repository's files changes the trust digest, so the new content does not take effect until the user trusts it again, but nothing stops the write itself.
  • Hard links are not detected. The secret list and the protected-file checks look at names; a hard link from an ordinary name to a protected or secret file lets a file tool read or write that file. Creating the link takes an approved shell command; git does not create hard links on checkout.
  • Binaries are not code-signed with a publisher certificate. Releases carry checksums, an SBOM and build provenance attestations instead.
  • The API key sits in the user's environment or ~/.anvil/.env, protected by file permissions, not by an operating system credential store.
  • The audit chain cannot show its own end being cut, or a whole rewrite. Someone who can write the file can cut records from the end, or rewrite it and recompute every hash, and the result verifies. The mirror exists for that: point mirror_dir at a folder the developer can append to but not rewrite, collect it, and compare.
  • Changes a shell command makes are not in the audit log as file changes. They are recorded as a tool call and its result (with exit code), not by the files they touched.
  • The user and host in audit records come from the environment (USERNAME or USER, COMPUTERNAME or HOSTNAME), which the person running Anvil can set. There is no single sign-on identity.
  • Some activity is outside a session's audit log. anvil build asks the planner for its work items before any log exists; the acceptance commands' output is not recorded; a permission decision made inside a subagent's registry is recorded under main.

Release builds

  • Trigger. .github/workflows/release.yml runs only when a version tag (v*) is pushed, and every build uses --locked (SUP-3).
  • Builds. anvil-cli in release mode, from a clean state without a build cache, on GitHub-hosted runners for x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, x86_64-pc-windows-msvc and aarch64-apple-darwin, with the toolchain pinned in rust-toolchain.toml.
  • Assets. Besides the binaries, SHA256SUMS, anvil.cdx.json (a CycloneDX 1.5 SBOM of the binary's dependencies for every platform) and anvil-<version>-vendored-src.tar.gz (the tagged source with every dependency vendored, for an offline build). Every file in SHA256SUMS gets a GitHub artifact attestation (SLSA build provenance, signed through Sigstore) by actions/attest (SUP-4). gh attestation verify <file> --repo EliFebres/anvil checks that a file was built by this repository's release workflow from the tagged commit; it is not a publisher code signature. docs/ADMIN_GUIDE.md has the verification steps.
  • Workflow permissions. release.yml is the only workflow that may write, and only to contents, id-token and attestations; its build jobs narrow themselves to contents: read; ci.yml is read-only (SUP-1). Every action is pinned to a full commit SHA (SUP-2). Dependabot proposes updates as pull requests.
  • Dependency gate. cargo deny check runs in CI against deny.toml: every RustSec advisory fails the build unless listed with a reason (one is: chrono is unmaintained, with no known vulnerability), only the listed permissive licenses are accepted, openssl-sys, openssl and native-tls are banned so TLS stays on rustls, other HTTP clients are banned, and crates.io is the only source.
  • Ownership. .github/CODEOWNERS requires the owner's review for every path, and main is changed only through pull requests.
  • Anvil has no self-update. A newer binary comes from whoever distributes Anvil to the user.

There aren't any published security advisories