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.
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.
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".
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.
- The managed policy, installed by an administrator at a fixed system path (
/etc/anvil/policy.tomlon Linux and macOS,C:\ProgramData\anvil\policy.tomlon Windows). Nothing below it can loosen it. Without the file Anvil runs unmanaged and sayspolicy: unmanagedat every session start. - The user's own files:
~/.anvil/config.toml, an optional--profile, the rules analwaysanswer saved under~/.anvil/permissions/, and command-line flags. - The repository Anvil runs in. Untrusted, it may only add
deny,askandshell_programsrules. What it ships that would give it power (hooks, MCP servers, skills, commands, agents, instruction files,allowrules) 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.
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:portthe user's configuration names: a providerbase_url, or theurlof an HTTP MCP server in~/.anvil/mcp.tomlor, once the repository is trusted, in its.mcp.jsonor.claude/settings*.json. Under a policy, only to a pair in[network] allowed_hosts(Egressinnet.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 setsrequire_tls = false(managed). Every providerbase_urlis checked when the configuration loads, for every command (check_plain_httpincrates/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'sallow_http_hostsis 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:portis 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] proxysays so:HTTPS_PROXY,HTTP_PROXY,ALL_PROXYandNO_PROXYare ignored in the default modenone;systemuses them or the system settings; a URL sends every request through that proxy (NET-5). The policy'sca_bundlereplaces the system trust store;client_certandclient_keyare presented for mutual TLS (NET-6). Anvil reads these files when it builds the client and stores nothing. - One client. Only
net.rsmay build or hold an HTTP client, onlyanvil-coredepends on reqwest, no crate depends on another HTTP client, and no non-test code outsidenet.rsnames a socket type.clippy.toml(disallowed-types),deny.toml([bans]) andcrates/anvil-core/tests/one_http_client.rsenforce it (NET-7). - Inspection.
anvil doctor --egresslists 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. |
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,grepandlist_dirleave them out:.envand.env.*(not.env.example,.sampleor.template),*.pem,*.key,*.pfx,*.p12,*.ppk(PuTTY keys),*.jksand*.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] denyglobs are added (holds_secrets;FS-3). - Git directories are never written:
.gitat 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.gitis allowed. - Files that grant power are never written, under any rule, profile, pre-approval,
--yesor answer:.anvil/config.toml,.anvil/permissions.toml,settings*.jsonin a.claudeor.anvilfolder,.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 runsnpm run lint,makeorcargoexecutespackage.jsonscripts, aMakefileorbuild.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] hooksand[projects] allow_trustset. - 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/usageand the audit mirror, in any letter case. The only file there a model may write is the current session'splan.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_filereplaces 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_filewrites CRLF when it replaces a file that uses CRLF throughout with content that uses LF only, and otherwise writes the content as given. Whenedit_filefinds 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).
- A cleared environment. Every program Anvil starts (shell commands, checks, acceptance commands, hooks, MCP servers, rule checks, git, and the probes of
anvil doctorandanvil setup) starts fromenv_clear()plus a short list fromcrates/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_HOMEandRUSTUP_HOME, and the names in[tools] pass_env. Provider keys, and any variable whose name containsKEY,TOKEN,SECRET,PASSWORD,PASSWDorCREDENTIAL, pass only when[tools] pass_envlists that exact name.crates/anvil-core/tests/children_start_clean.rsfails the build when non-test code builds aCommand, under anyuse ... asortypealias, whose own builder chain or variable does not callenv_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())orvars_os(); comments and string literals are blanked first (KEY-4). An MCP definition's${VAR}may name only a variable from that list (McpServer::launchincrates/anvil-compat/src/mcp/mod.rs;KEY-5). - Shell modes.
[shell] modein the user's configuration, or in the policy, which beats it, decides how theshelltool 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 buildrefuses 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 ascargo test *in every layer (the policy's[shell] allow, the user's, eachshell_programslist), 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 onlystatus,diff,log,show,rev-parse,ls-files,blame,branch,add,commit,restore,switch,checkout,stash,merge-base,describe,shortlog,cat-file,grepandtag(list only) whatever the pattern (sorebase --exec,bisect run,submodule foreach,difftool,fetchandconfigare refused even undergit *), 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 testruns 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
--yestoo, 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 addandset-url, a git alias defined with-cor--config-env, package installs (pip install,npm install,cargo install,gem install), privilege tools (sudo,runas,doas) andrm -rf,Remove-Item -Recurse,git push --forceandgit 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, soc''urlandrm -rfare found. They match command text, so in every host mode,--yesincluded, 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 throughdockerorpodmanasrun --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/workspaceas the only host folder and its.gitmounted 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 passescore.hooksPath=/dev/null,core.fsmonitor=false,--no-pager,core.editor=:,sequence.editor=:andprotocol.allow=neveras-csettings, adds--no-ext-diff --no-textconvto diffs, and refuses a repository whose own config names a filter or signing program.crates/anvil-core/tests/one_git_entry.rskeeps 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 anyshellcall;anvil buildruns each acceptance command only after the same rules allow it (AgentLoop::project_check,Wiring::permit_shell;SH-8).
- Every tool call is decided by
ToolRegistry::check_permission(crates/anvil-core/src/tools/mod.rs) againstPermissions(crates/anvil-core/src/tools/permissions.rs), assembled inWiring::registry_without_delegate: the user's rules, then the repository'sdeny,askandshell_programs, then the policy'sdenyandask, 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
denyfrom any layer, then a repository or policyask, then the user'sallowandask, then the user'sdefault, then a trusted repository'sallow, then the tool's own default. A repository'sallownever 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,shelland 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
shellonly, always (savesshell:<first word> *to the user's own file for the repository, never into the repository). Under a policy,alwayssaves nothing unlessallow_always = true(PERM-3). --yesanswers 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,--yesis refused unlessallow_yes = true, and--allow-toolunlessallow_allow_tool = true;require_plan_approvalmakes a person approve every plan.- Subagents (the
delegatetool) get the same registry rules, file boundary, shell mode, allowlist, runner and policy through the same two functions,Wiring::registry_without_delegateandWiring::tool_context(PERM-4).
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.tomlmay only adddeny,askandshell_programs. A[providers]table (and so anybase_url),[roles],[tools],[network]or[shell], or anallow,defaultorallow_toolskey, stops Anvil with an error naming the key and the file (TRUST-1). Its.anvil/permissions.tomlmay add the same three keys andallowrules, which wait for trust. Its.anvil/.envis 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, nestedCLAUDE.mdfiles) andallowrules 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.tomlwith a SHA-256 digest (fingerprint) over everything listed above, every script a hook or MCP server names, and every file under theskills,commandsandagentsfolders. 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
@pathimport 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,
readOnlyHintincluded) is approved by SHA-256 together with a digest of the definition; a listing or definition that later differs stops the server untilanvil mcp approve <name>. Under a policy only alisting_sha256pin accepts a listing, andanvil mcp approveis refused (crates/anvil-compat/src/mcp/approval.rs;TRUST-7).
- 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,DataGuardincrates/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 everyapi_key_env, and the policy's[data] patternswith[REDACTED:<kind>](RED-2).read_fileandgrepredact a whole file before they choose lines, andedit_filedoes the same before its not-found error shows any (RED-3). Every log line is redacted at the sink (Redactingincrates/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 ofuntrustedanddata, and<,<and<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
shelltool starts commands: the shell and its flags, direct start without a shell under an allowlist, orshin a Linux container. Theshelltool 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_sectionincrates/anvil-core/src/agent/prompts.rs,shell_factincrates/anvil-core/src/tools/shell.rs;RED-7). - Transcripts. The policy's
[data] transcriptdecides what a session folder keeps:full,metadata(sizes, digests, tool names, token counts, timings; no text) oroff(the default under a policy: nosession.jsonl). Belowfullno untruncated tool output or compaction file is written andanvil resumerefuses (SessionRecord::kept_asincrates/anvil-core/src/context/session.rs;DATA-1). Belowfullthe memory summarizer does not run, and with[features] memoryoff nothing under~/.anvil/memoryis read or written (memory::policy_skip_reasonincrates/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 doctorfails a row when others can open~/.anvil,.anvil,transcript_dirormirror_dirand prints theicaclscommand that fixes it (DATA-3). - Retention.
anvil purge --older-than <days>, and the policy'sretention_daysat 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_allincrates/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.
- 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/.envwithout 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_attemptincrates/anvil-core/src/provider/http.rs;KEY-2). An HTTP MCP server's header values are scrubbed from its error bodies the same way (scrubincrates/anvil-compat/src/mcp/http.rs;KEY-3). - Under a policy that sets
[network] client_certandclient_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 setupwrites~/.anvil/.envand 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 ofjust checkand CI) fails when a tracked file holds a key shape or a value of 12 or more characters from the user's.envfiles, 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).
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 fromwrite_fileandedit_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 orunmanaged), theevent,prev(the previous record's hash; 64 zeros for the first) andhash. - 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.verifyre-serializes each record and requires the same bytes, so each record has exactly one valid line (sealandverifyincrates/anvil-audit/src/audit/chain.rs;AUD-1).anvil audit verifyandanvil audit showalso require at least one record and a first record of typesession_start(verify_log), so an emptied log or one whose head was removed is a break.crates/anvil-audit/src/audit/verify_audit.pychecks 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 showprints one line per record and the verdict (AUD-2). - Mirror. With
[audit] mirror_dirthe 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] requireddefaults totrue: 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.
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.tomlon Linux and macOS,C:\ProgramData\anvil\policy.tomlon 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::checkmakes 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 fromGet-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
versionthan 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 throughANVIL_HOMEincluded), command-line flags and the repository. A conflicting lower layer is an error naming the policy key (check_flags,check_config,check_buildincrates/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~/.anvilor~/.claude; the same items shipped by a trusted repository are left out with a note naming the key (POL-5). - Defaults. Every key except
versionand[network] allowed_hostsdefaults to the restrictive choice: no shell, no MCP, hooks, skills, memory,anvil buildor delegation, no trust in repositories, no--yes,--allow-toolor savedalwaysrules, 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_policyincrates/anvil-cli/src/wiring.rs, plusWiring::registry_without_delegateandWiring::tool_context, which subagents share. - Commands.
anvil policy showprints 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 doctorhaspolicy,policy:ownershipandpolicy:sha256rows (POL-7).
- Approved shell commands on the host are not sandboxed. In
askandallowlistmode 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,--yesincluded, a shell can hide a command from them (a variable, an alias, string concatenation, a script file): they are a guard rail.allowlistmode limits which programs start and with which arguments, not what an allowed program then does (cargo buildruns build scripts,justruns recipes,npm testruns 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.tomlis the user's file; deleting it makes the next listing count as the first. A policy'slisting_sha256pin does not depend on it. - Below
full, the plan and summary stay. Inmetadataandoffmodesplan.mdandsummary.mdare still written;retention_daysandanvil purgeremove them with the folder. - On Windows, files inherit their folder's access list. Anvil does not change access lists;
anvil doctorreports 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_dirat 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 (
USERNAMEorUSER,COMPUTERNAMEorHOSTNAME), which the person running Anvil can set. There is no single sign-on identity. - Some activity is outside a session's audit log.
anvil buildasks 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 undermain.
- Trigger.
.github/workflows/release.ymlruns only when a version tag (v*) is pushed, and every build uses--locked(SUP-3). - Builds.
anvil-cliin release mode, from a clean state without a build cache, on GitHub-hosted runners forx86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,x86_64-pc-windows-msvcandaarch64-apple-darwin, with the toolchain pinned inrust-toolchain.toml. - Assets. Besides the binaries,
SHA256SUMS,anvil.cdx.json(a CycloneDX 1.5 SBOM of the binary's dependencies for every platform) andanvil-<version>-vendored-src.tar.gz(the tagged source with every dependency vendored, for an offline build). Every file inSHA256SUMSgets a GitHub artifact attestation (SLSA build provenance, signed through Sigstore) byactions/attest(SUP-4).gh attestation verify <file> --repo EliFebres/anvilchecks 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.ymlis the only workflow that may write, and only tocontents,id-tokenandattestations; its build jobs narrow themselves tocontents: read;ci.ymlis 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 checkruns in CI againstdeny.toml: every RustSec advisory fails the build unless listed with a reason (one is:chronois unmaintained, with no known vulnerability), only the listed permissive licenses are accepted,openssl-sys,opensslandnative-tlsare banned so TLS stays on rustls, other HTTP clients are banned, and crates.io is the only source. - Ownership.
.github/CODEOWNERSrequires the owner's review for every path, andmainis changed only through pull requests. - Anvil has no self-update. A newer binary comes from whoever distributes Anvil to the user.