Repository navigation
Harden anvil for regulated, restricted-network environments - #43
Merged
Merged
Conversation
Six agent-loop tests used `test -f <file>` as the check command. On Windows that only works when Git's usr\bin is on PATH, as it is on the GitHub runner but not on a stock developer machine, so `just check` failed there. `cat <file>` exits the same way in PowerShell and sh. The snapshot test now replaces the shell's own wording of the missing-file error, the way it already replaces CRLF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part A of the enterprise hardening: take out everything that downloads code or contacts a server other than the configured model endpoint on its own. - `anvil update` is gone: the command, the release fetch and swap, the build script that recorded the target, ANVIL_RELEASE_REPO, ANVIL_BUILD_SHA, ANVIL_GITHUB_API_URL and the [update] section. A config file that still has [update] fails to load and says that updates come from whoever distributes the binary. - Webhook notifications ([notify]) are gone the same way. herdr reporting stays, off by default. - MCP servers are stdio only. A definition with a `url` is refused, and the HTTP transport with its own reqwest client is deleted, so anvil-compat and anvil-cli no longer depend on reqwest. - `anvil skill add` takes a local directory only. It no longer runs `git clone`; the error for a URL says to clone it yourself. README, SECURITY.md and CLAUDE.md describe the new state. The full SECURITY.md rewrite comes with the documentation part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part B of the enterprise hardening. Until now a repository's own files could redirect a provider's base_url (sending the API key elsewhere), allow shell without asking, set environment variables, and start hooks and MCP servers, all without a prompt. - Configuration comes only from ~/.anvil/config.toml and a profile. A repository's .anvil/config.toml and .anvil/permissions.toml may add `deny` and `ask` rules and nothing else; every other key is ignored with a warning that names it (anvil-types/src/project.rs). Repository rules are applied through Permissions::tighten: a deny from anywhere wins, and a repository ask beats the user's allow. - The `always` answer saves to ~/.anvil/permissions/<repository>.toml, never into the repository. - A repository's .anvil/.env is never loaded; only ~/.anvil/.env is. scan-keys still reads it so its values are caught if committed. - Hooks, MCP servers, skills, commands, agents and instruction files from the repository load only once the user trusts it. The first interactive session lists every item, with hook and server command lines, and asks once; the answer lives in ~/.anvil/trust.toml keyed by the repository path. With --plain, --yes, no terminal, doctor or build, an undecided repository is untrusted and nothing is recorded. `anvil trust` asks again and `anvil trust --revoke` withdraws it. - An @import in a repository's instruction file may only name a file inside the repository, so CLAUDE.md cannot pull ~/.ssh into the prompt. - A check command anvil detects from the repository's files (just check, cargo test, npm test, pytest) now goes through the permission rules like any shell call. A check the user configured runs as configured. Tests: src/wiring/hostile_tests.rs and tests/hostile_repo.rs build a repository that tries each attack and assert it is refused, with trusted controls showing the gate is what stops the hook and server. Tests that relied on the old behavior now assert the new one: the project-overrides-global config test became a profile-overrides test, the env-order test now asserts the repository's .env is never read, and the import test no longer expects a repository file to import ~/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part E of the enterprise hardening. In-process limits on what anvil's tools can reach; not an operating system sandbox. - Workspace jail. Every file tool resolves its path, symlinks and `..` included, and refuses anything outside the project root, the session folder and `[tools] extra_dirs`; skill folders may be read. Reads are confined too. `.env` files, SSH, cloud and GPG folders, browser profiles and keychains are refused on all three systems, and directory walks skip them (tools/workspace.rs, ToolContext::checked_path). The edit preview, which read the target before the permission check, goes through the same check. - Scrubbed environment. Shell commands, check commands, hooks, MCP servers and rule checks get an explicit list of variables plus `[tools] pass_env`; provider keys and tokens are not passed (anvil-types/src/child_env.rs). This repository's own `just check` was run through the shell tool's code path with the scrubbed environment on Windows and passed. - `shell_programs`. When set, a shell call must be one listed program with plain arguments; chaining, redirection and substitution in sh, PowerShell and cmd are refused, and no rule, answer or --yes lifts it. Layers can only narrow the list; a repository may set it. profiles/strict.toml ships it with default = "ask". The substring blocklist stays as a second layer. - SECURITY.md says plainly that an approved shell command runs with the user's rights and is not sandboxed. The bytecode test now expects PYTHONDONTWRITEBYTECODE=1 always, since children no longer inherit the user's own value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part D of the enterprise hardening. After Part A the provider client is anvil's only HTTP caller; this makes that structural. - anvil-core/src/net.rs holds the one function that builds a reqwest client, with redirects off, and Egress, which decides whether an endpoint may be called: https only, except loopback and hosts in the user's `[network] allow_http_hosts`. Egress::managed adds an allowlist of base URLs (matched by scheme, host, port and path segment) for the managed policy in Part C. A provider checks its base_url when it is built, so a refused endpoint gets no request. - clippy.toml forbids building a client anywhere else, and tests/one_http_client.rs fails if a file other than net.rs builds one or switches that lint off. - An error body that repeats the API key has it replaced with [redacted] before it is shown, logged or recorded. A doctor test runs against a server that echoes the key and checks stdout, stderr and the log files. wiremock, already a workspace dev-dependency, is now also one of anvil-core's, for the redirect test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part C of the enterprise hardening. An administrator installs policy.toml at a fixed system path (C:\ProgramData\Anvil, /etc/anvil, /Library/Application Support/Anvil). No environment variable or flag points anvil elsewhere. When present it is a floor under the user's and the repository's settings; when present but unreadable or invalid, anvil refuses to start; when absent, anvil runs in personal mode. Keys, each defaulting to the restrictive choice except project.config: - [endpoints] allowed_base_urls (required), allow_http_hosts - [project] config - [permissions] allow_skip_prompts, profile (a file next to the policy whose rules replace the user's; the user's deny, ask and shell_programs still apply), require_plan_approval - [extensions] hooks, mcp_commands, skill_dirs, herdr - [tickets] queue - [sessions] transcript_dir, retention_days, summarizer_calls anvil-types/src/policy.rs reads and checks the file. The keys that change a session are applied in one function, Wiring::with_policy; flags, project.config, summarizer calls, the queue, plan approval and retention are applied at startup (anvil-cli/src/policy.rs, main.rs). The session API in anvil-core now takes the sessions folder rather than the project root so transcripts can move. `anvil doctor` prints the policy's path and everything it disables. docs/enterprise/policy.example.toml lists every key with its default; a test loads it together with profiles/strict.toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part F1 of the enterprise hardening. `anvil setup --endpoint <url>
[--model <id>] [--key-env NAME]` asks the server for its model list at
{url}/models (then {url}/v1/models when the URL has no /v1), picks the
only model or the one named, and writes one `endpoint` provider with the
context size the server reports. Every role points at it. Other
providers and comments in an existing config are kept but no longer used.
The probe lives in anvil-core (provider/models.rs) and goes through the
same egress rules as provider requests, so plain http to a remote host
and, under a managed policy, any endpoint the policy does not allow are
refused before a request is sent. Under a policy, plain `anvil setup`
refuses to write the hosted providers.
The key variable defaults to ANVIL_ENDPOINT_KEY; a server that needs no
key accepts any value. api_key_env stays required in the config; making
it optional is part of the provider tolerance work in the next pull
request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part G of the enterprise hardening. - SECURITY.md now opens with who is responsible for what (anvil, the model host, the firm), a table of every enforced control with the code and the test behind it, and a plain list of what is not enforced: unsandboxed approved shell commands, no secret redaction, trust per path rather than content, the blocklist as a second layer, unsigned binaries, the key in a file, plain transcripts. - docs/enterprise/data-flow.md: one Mermaid diagram of the terminal, anvil, the one allowed endpoint and the transcript folder, and what is sent. - docs/enterprise/threat-model.md: malicious repository content, data leaving the firm, supply chain and model mistakes, each with what stops it today and what is on the roadmap. - docs/enterprise/pilot-scope.md: a sign-off template for a time-boxed pilot. - docs/ROADMAP.md: deferred work, with provider tolerance and the doctor acceptance test listed first as the next pull request. - docs/CODE_TOUR.md: one request from the command line to the transcript, naming the file and function at each step. README and CLAUDE.md point to them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…repository programs Follow-up on the enterprise hardening review. - File tools refuse any write inside a git directory (`inside_git_dir` in tools/workspace.rs): a `.git` folder or file at any depth, which covers worktrees and submodules, and any folder that holds HEAD, objects and refs (bare and separate git directories). Reads stay allowed. Tests write .git/config, add hooks, and target a real worktree, submodule, bare repository and separate git directory. - New `anvil_core::git::command` is the one way anvil starts git in a project (session diff, build commits, rules check, scan-keys). It passes -c settings that beat every config file: hooks off (core.hooksPath=/dev/null), core.fsmonitor=false, --no-pager, core.editor=: and sequence.editor=:, protocol.allow=never. Diffs add --no-ext-diff --no-textconv. A repository whose own config names a filter or signing program is refused, since those cannot be turned off without also turning off the user's own. Tests plant each program and include controls showing plain git runs them; tests/one_git_entry.rs fails if non-test code starts git another way. The ticket queue keeps its own git calls: they run in ~/.anvil, not the project. - A Windows test points a directory junction outside the project and checks that reads, writes, listings and searches through it are refused. - SECURITY.md documents both controls and states that require_plan_approval covers only the top-level plan of anvil build; the roadmap item for .git is narrowed to repository hook settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A write_file or edit_file to settings.json or settings.local.json in a .claude or .anvil folder can add a hook that runs in a later session without a prompt. Such a write now always asks: an allow rule, a profile, a pre-approved tool or a session approval no longer covers it, a session or always answer covers that one call only and saves nothing, and the unattended prompt behind --yes refuses it. A deny rule still refuses it without asking. The check uses the resolved path, so `..` and letter case do not get around it. PermissionRequest gains `needs_person`, which every prompt wrapper passes through unchanged; StaticPrompt answers No when it is set. SECURITY.md and the threat model describe the rule. The roadmap's hook-settings item is done and is replaced by a policy key for an administrator-owned git hooks path, so firm-required commit hooks can run on anvil build commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deletes `anvil ticket` and all its subcommands, the `/ticket` chat command, the ticket drafting, signal classification, ticket store and queue push code in anvil-telemetry (draft.rs, classify.rs, signal.rs, tickets.rs, git.rs, prompts/draft.md), the Ticket schema, boundary validator and `anvil-types --schema` binary, the `[tickets]` and `[telemetry]` config tables (both now fail to load with the reason), the `[tickets] queue` policy key and the `just schema` recipe. classify.rs and signal.rs only fed ticket drafting, so they went too; anvil-telemetry now records and sums usage and nothing else. Tests changed on purpose: the ticket tests are gone with the feature; the marker test no longer drafts tickets but still checks that no record leaks a tool argument or result; a new CLI test checks `ticket`, `update` and `learn` are not commands. anvil-types drops schemars and ulid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deletes crates/anvil-cli/src/status/herdr.rs, the `[integrations]` config table (an old file that still sets it fails to load and says why) and the `[extensions] herdr` policy key. The status reporter now only writes status.json, so `StatusReporter::shutdown` and the async tail of `end_status` went with it. The herdr tests are removed with the feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deletes corrections.rs, rule_proposals.rs and prompts/rule-learn.md in anvil-memory, crates/anvil-cli/src/learn.rs, `anvil memory learn` (the `memory` command had no other subcommand, so it is gone too), the session-start step that proposed rules, the session-end step that saved the files anvil left, and the ~/.anvil/memory/corrections/ store. Facts and standing rules stay. The managed policy's `summarizer_calls` now covers only the end-of-session memory call. anvil-memory drops `similar` and `sha2`, which only the removed code used. The learning tests and snapshots are removed with the feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deletes crates/anvil-cli/src/legacy.rs, its test and the `legacy` row of `anvil doctor`. The old-name check in `just no-old-name` and in CI now has no exceptions. The legacy tests are removed with the feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`anvil setup` and `anvil config init --global` now write a single example provider, `endpoint`: an OpenAI-compatible server on the organization's own network (`https://models.internal.example/v1`, key in ANVIL_ENDPOINT_KEY), the same name `anvil setup --endpoint` fills in. The Anthropic and OpenAI protocol adapters stay; hosted APIs become a documented option that setup never writes. Tests changed on purpose because the templates changed: the setup, env-merge and config-merge tests assert the single example instead of the three hosted providers, the template tests use the provider name `endpoint` instead of `runpod`, and the endpoint merge test builds its own fixture with another provider. A new assertion checks the setup template names no hosted API host. The project `.env` test now also covers a `.env` file at the repository root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The self-update removal also took out the baked-in commit. A release build now reads `ANVIL_BUILD_SHA` at compile time (`option_env!`, no build script) and `anvil --version` prints `<version> (<commit>)`; a build from source prints the version alone. Nothing else reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anvil-telemetry no longer needs toml, ulid or insta, and anvil-types no longer needs insta. `anvil compat check` no longer suggests the removed `anvil skill add owner/repo/...` form; it says to clone the repository and pass the directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README, SECURITY.md, CLAUDE.md, CODE_TOUR.md and docs/enterprise now describe what is left: no tickets or ticket queue, no herdr, no learning from edits, no old-name migration, setup writes one self-hosted example and hosted APIs are a documented option. README opens with the new one-line description. docs/DECISIONS.md records the choices made so far and the three the repository owner took before the run. The full rewrite of the documents is a later phase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gate - release.yml runs on `v*` tags only, builds with --locked (adds aarch64-apple-darwin), and publishes SHA256SUMS, a CycloneDX SBOM, build provenance attestations and a vendored source archive. It sets ANVIL_BUILD_SHA so `anvil --version` shows the commit. - Every action is pinned to a full commit SHA. - deny.toml and a `cargo deny check` CI job: advisories, a license allowlist, bans on openssl-sys and native-tls, crates.io only. - Dependabot for cargo and actions, CODEOWNERS, CHANGELOG.md, version 0.2.0, crates marked publish = false. - The workflow permission test changed on purpose: release.yml may now write contents, id-token and attestations; it also refuses job-level widening, unpinned actions, non-tag release triggers and unlocked builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`${VAR}` in an MCP server's command, args and env read anvil's whole
environment, and the server's env was applied over the scrubbed child
environment, so a trusted repository's `.mcp.json` could copy a provider
key from `~/.anvil/.env` into its server. The trust prompt also showed
the expanded arguments and never the env entries.
Definitions are now kept as written and expanded only when the server
starts (`McpServer::launch`), from the variables a child receives
(`child_env::may_pass`: the base list plus `[tools] pass_env`). Any other
reference stops that server with an error naming the variable. The trust
prompt lists command, args and env entries unexpanded.
`expands_environment_references` changed on purpose: an unset variable
outside the child list is now an error instead of empty, so the test
injects the pass rule and the lookup.
New tests: a_definition_cannot_copy_a_withheld_variable_into_a_server,
a_launch_expands_only_variables_children_receive,
mcp_servers_are_listed_as_written_with_their_environment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Test-only dependencies move to [dev-dependencies]: futures-util and tempfile in anvil-compat, ulid in anvil-cli (whose duplicate normal tempfile goes). `-W unused-crate-dependencies` now reports nothing. - `anvil config init --global` writes the same example provider as `anvil setup` (context_window 32768, supports_reasoning false); a new test, setup_and_config_init_write_the_same_example_provider, keeps them equal. Two template tests changed on purpose to the new values. - `anvil setup --help` no longer mentions hosted providers. - CHANGELOG.md and DECISIONS.md no longer use the old repository's name. - CODE_TOUR.md lists all five removed config sections; CLAUDE.md states the release workflow's three write scopes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…errors on conflict - The policy lives at /etc/anvil/policy.toml (Linux and macOS) or C:\ProgramData\anvil\policy.toml, a literal in the binary. Before it is read, the file and its folder must be root-owned and not group or other writable on Unix, or owned and writable only by Administrators, SYSTEM or TrustedInstaller on Windows (SDDL from Get-Acl). An unsafe, unreadable or invalid file, or one with an unknown key, stops anvil. - Schema version 1: [network] allowed_hosts (exact host:port) and require_tls, [models], [permissions] deny/ask/allow_yes/allow_allow_tool/ allow_always/require_plan_approval, [files] extra_roots and deny globs, [features] mcp/mcp_servers/hooks/skills/memory/build/delegation, [projects] allow_trust, [data], [limits]. Every key defaults to the restrictive choice. - A lower layer that conflicts with the policy (user configuration, a profile, a home chosen through ANVIL_HOME, flags, anvil's own files under ~/.anvil) is an error naming the policy key. Hooks, MCP servers and skills from Claude Code's files or a trusted repository are left out with a note. - Egress under a policy checks host:port instead of base URL prefixes. - The always answer can be switched off; the delegate tool and memory have switches; subagents share the policy's rules and file limits. - anvil policy show, anvil policy check <file> [--ownership], doctor rows for presence, ownership and hash, and `policy: unmanaged` at startup. - policies/restricted.toml and policies/standard.toml ship; a test parses every file in policies/. Tests changed on purpose: the forced-profile, allow_skip_prompts, mcp_commands, skill_dirs, [project] config and summarizer_calls tests are replaced by tests for the keys that replace them; the egress tests check host:port pairs; six TUI snapshots gain the startup screen's policy row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…isions SECURITY.md's managed-policy section now states exactly what is enforced, each claim with its file and test. docs/ADMIN_GUIDE.md covers installing the file with the right ownership on each system, rollout and every key. docs/DECISIONS.md records the Phase 2 choices; docs/ROADMAP.md lists the policy keys later phases add. The example policy moves to policies/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A repository's .anvil/config.toml that sets [providers], [roles], [tools], [network], or permissions allow/default/allow_tools is now an error naming the key and file (it used to be ignored with a warning). Other unknown keys are still ignored with a warning. - .anvil/permissions.toml may add allow rules. They apply only once the user trusts the repository, and only where no rule of the user's own (and no user default) decides the call; they never lift the blocked command list or shell_programs. default and allow_tools there are errors. - ~/.anvil/trust.toml pins a decision to trust to a SHA-256 digest of the permission file, the hook and MCP settings files, root and nested instruction files (with imports), and every file of the project's skills, commands and agents. Any change asks again; without a terminal or under --yes a changed or undecided repository stays untrusted, with a note on stderr and a warning in the log. A refusal stays regardless. Old entries without a digest no longer grant trust. - trust::decide and trust::run take allow_trust so a managed policy can forbid trusting repositories; the CLI passes true until the policy key is wired. Tests changed on purpose: the hostile repository fixtures no longer ship a loosening .anvil/config.toml (that is now its own rejection test), the "repository allow is ignored" test now checks it is ignored untrusted and applied trusted, and integration tests trust a repository through `anvil trust` instead of writing the store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
File tools now refuse, instead of asking, any write to .anvil/config.toml, .anvil/permissions.toml, settings*.json in a .claude or .anvil folder and .mcp.json, anywhere in the workspace and in any letter case, after resolving `..` and symlinks; and any write under the user's ~/.anvil (Workspace::protected_dirs, filled by Wiring::tool_context). No rule, profile, pre-approval, --yes or prompt answer lifts it, so a model cannot raise its own permissions or plant a hook. ToolContext::checked_path does the check; workspace::is_hook_settings becomes workspace::grants_power. The "a person must approve" path for hook settings writes is gone with it: PermissionRequest::needs_person is removed and StaticPrompt always gives its answer. Tests changed on purpose: hook_settings_writes_are_refused_without_a_person and a_person_is_asked_about_every_hook_settings_write asserted that such a write asks a person, and the former asserted that a write to .anvil/config.toml completes. They are replaced by tool_writes_to_files_that_grant_power_are_refused, a_symlink_to_a_file_that_grants_power_is_refused (Unix) and tool_writes_into_the_users_anvil_folder_are_refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SECURITY.md, README.md, CLAUDE.md, the threat model and the roadmap now describe what the previous two commits enforce, each claim with its file and test: loosening project keys are errors, a trusted repository's allow rules are the weakest rule, trust is pinned to a SHA-256 digest of what the repository ships, and file tools never write the files that grant power or ~/.anvil. The roadmap's "pin trust to content" item is done and is replaced by the remaining gap (shell writes to those files). docs/DECISIONS.md records the Phase 2 project-trust choices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…documents trust::decide and `anvil trust` both receive allows_project_trust(policy), so the policy decides through the same function the user's answer does. SECURITY.md, README.md, the administrator guide, the code tour and DECISIONS.md now give one account: trust is pinned to a content digest, a trusted repository's allow rules apply, and writes to files that grant power are refused rather than asked about. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
load_checked treated every metadata error as an absent policy, so a policy folder the user may not list ran anvil unmanaged. Only a missing file in a missing folder or a real folder is unmanaged now. Test added: a_policy_path_that_cannot_be_inspected_stops_anvil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A user configuration, profile or saved rules file with [permissions] default = "allow" approved every unnamed call without a person, which is --yes in effect. Under allow_yes = false it is now an error naming that key. Test added: a_default_of_allow_conflicts_with_allow_yes_false_in_every_user_layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under a policy, a hook, MCP server or skill the policy forbids in the user's ~/.claude files only got a note. Both ~/.anvil and ~/.claude are the user's own configuration, so either is now an error naming the policy key. Items a trusted repository ships stay a visible note. Tests changed on purpose: the_users_own_hooks_conflict_and_shared_or_project_hooks_do_not_load is renamed the_users_hooks_conflict_and_project_hooks_do_not_load and now expects an error for a ~/.claude hook; skills_follow_the_policy_mode now expects an error for a ~/.claude skill under skills = "off" and "bundled". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The final review sent a request to a listener with `git fetch <url>` under --yes, because the remotes category held only push, clone and remote add/set-url. fetch, pull, ls-remote and submodule now join it (SH-4). SECURITY.md, the threat model and the SH-4 row say the deny categories are a text match a shell can get around in every host mode, --yes included, not only in ask mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c''url, "curl", c`url, c^url and `rm -rf` (two spaces) were not refused, because quotes split words and the destructive patterns needed single spaces. deny_category now matches the command with quotes, backticks and carets removed and white space collapsed, and then as written (SH-4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the reviewer gave no JSON verdict twice, the loop treated the review as approved. It now sends the change back to Build like a changes verdict, so a reviewer that never decides ends the session as incomplete when the review rounds run out. Test changed on purpose: unparsable_review_verdict_is_reasked_then_approved now scripts a second Build turn and an approving review, because a missing verdict sends the change back before it can be approved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An SDDL of D:NO_ACCESS_CONTROL has no entries, so the policy ownership check and the private-folder check found nothing wrong with a descriptor that lets everyone change or open the file. Both now report a null DACL, as they already did a missing D: part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RED-1 loop test read its key with read_file, which redacts on its own, so removing the redaction in ToolRegistry::execute, the only one for shell and MCP output, left every test passing. A new loop test prints a key with shell and returns one from a stand-in MCP tool and checks that neither reaches the provider or the transcript; it fails with that redaction removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Y-1) The KEY-1 tests checked a path helper, so loading a project .env before dotenv::load left them passing. A hostile_repo test runs anvil --yes with the fake provider and a shell call that prints variables pass_env would pass on: the ~/.anvil/.env value arrives, and the values in the repository's .env and .anvil/.env reach neither the child nor the provider's transcript. It fails when main.rs also loads those files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scan passed when the text env_clear() appeared within 12 lines of Command::new(, so .env_clear().envs(std::env::vars()), an aliased Command, a second command nearby, and env_clear in a comment or string all passed. It now blanks comments and strings, knows every alias of Command in a file, requires env_clear() on the builder's own chain or variable before the program starts or the builder is passed on, and refuses .envs() fed from the parent's environment. A self-test holds each evasion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…D-6) U+27E8, U+2329, the U+3008 family, a Cyrillic e in the marker word and < without its ; were not escaped. The guard now maps more angle-bracket and slash lookalikes, mathematical letters and the Cyrillic, Greek and Armenian homoglyphs of the marker's letters, and the marker pattern accepts <, < and < without their ;. SECURITY.md lists what is mapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FS-5 test filled protected_dirs by hand, so removing the wiring that fills it passed. A hostile_tests test builds the session's and a subagent's tool context with Wiring, with the home folder in extra_dirs, and fails without that wiring. The protected-folder check now ignores letter case, as the records check does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SH-2 test used git, which has its own branch, so routing the general direct branch through the shell passed. The new test runs cargo with $HOME and %PATH% under a cargo * pattern and checks that cargo received them literally; it fails when that branch goes through a shell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The AUD-5 tests attached the gate by hand, so removing the production attachments in wiring.rs passed. A new test hands a failing required log to the wiring through observe_permissions and checks that the wiring's own registry, provider and hook runner all refuse; each of the three attachments was removed in turn and the test failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
*.ppk, *.jks, *.keystore and *.kdbx were not on the built-in secret list; only the example policy denied three of them. They are now built-in secret extensions, refused and skipped by searches without a policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kers A name in a comment satisfied the check (the review added `// fn a_repository_env_is_proven_ignored_by_magic` and it passed). The check now blanks comments and string literals, accepts a name only when its function carries #[test] or #[tokio::test], and requires each test gated by #[cfg(unix)], #[cfg(windows)] or a Linux-only cfg to be followed by "(Unix)", "(Windows)" or "(Linux CI)" in its row. The gated rows of FS-1, FS-2, FS-5, SH-6, DATA-2 and DATA-3 gain their markers. The evasion was reproduced against the old check, which passed, and the new one fails on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anvil --help opened with "The anvil binary: a CLI coding agent. Argument parsing and wiring only." and the startup screen with a tagline that predates the one-line description. The crate description, and so the help header, is now the one-line description; the startup tagline is its short form, "A coding agent harness for open-weight models". The roadmap line about the tagline is removed. Snapshots changed on purpose: empty_session, plan_approval_120, startup_120 and startup_80 show the new tagline (startup_80 is one line shorter). Test changed on purpose: the_logo_sits_beside_the_header_and_sections_follow now checks the tagline text itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
*.kdbx is now a built-in secret extension, so the test that shows a policy's [files] deny extending the list got the built-in refusal instead. Test changed on purpose: a_policy_deny_glob_extends_the_secret_list now denies **/*.sqlite and reads customers.sqlite, which only the policy refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After rebasing onto the document corrections: POL-2 now lists a_null_or_missing_access_list_is_a_problem, and the ADMIN_GUIDE [shell] allow row no longer says a "git push origin *" pattern allows git push, since allowlisted git runs only its listed subcommands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/HARDENING_REPORT.md summarizes each phase of the run: what was done, the breaks the independent reviews found and fixed, what was not done and why, test and dependency counts before and after, the decisions a reviewer is most likely to question, and what only the repository owner can do. The README's document index links it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
read_file shows lines without their endings, so a model copies LF text out of a CRLF file and a multi-line edit_file call could never match. - edit_file matches through a copy of the file with CRLF turned into LF and maps each match back to the original bytes: only the matched span changes, the replacement takes the ending of the first line it touches, a byte order mark is kept, uniqueness and replace_all hold. An exact byte match is the fallback. Indentation still must match. - When nothing matches, the error names a white space difference with the white space made visible, or shows the file's lines where the old text's first line occurs, or says nothing similar exists; at most 20 lines, 160 characters each, 4096 bytes, from a copy of the file redacted whole first (RED-3). - write_file keeps a file that uses CRLF throughout CRLF when the new content is LF only. - parse_args explains a failed parse from the tool's schema: each argument at fault, what it was and what it accepts. read_file, glob and grep name the argument in their own errors too. - The edit preview uses the tools' own functions. - SECURITY.md gains "What a write changes" (FS-8) and the RED-3 text. Tests changed on purpose: - edit_file_previews_the_replacement: an ambiguous call the tool refuses now has no preview; the single-edit case uses a unique match. - numbering_and_paging: the offset-past-the-end text now names the argument and its accepted range. - Snapshots specs_list_every_builtin_sorted and without_a_planner_the_coder_requests_do_not_change: the new edit_file and write_file descriptions (the system prompt lists them). New test an_edit_copied_from_read_file_succeeds_first_try_on_a_crlf_file runs the binary with the fake provider through read_file and a multi-line edit_file on a CRLF file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mands The base system prompt gains an Environment section right after the base text: the operating system family, the path separator and, when the shell tool is registered, one sentence from shell_fact saying which program runs commands and what syntax works there (PowerShell, cmd, a POSIX shell, a configured program, direct start without a shell under an allowlist, or sh in a Linux container). The shell tool's description carries the same sentence; the wiring re-registers the tool with it. The shell is named by file name only, never a configured path, and the text depends only on the session's configuration, so it is byte-stable within a session. Snapshots updated on purpose: - build_prompt_snapshot, plan_prompt_snapshot, verify_prompt_snapshot: the new section after the base prompt (a fixed Windows PowerShell setting). - specs_list_every_builtin_sorted: the platform-neutral default shell description of a registry built without wiring. - without_a_planner_the_coder_requests_do_not_change: the shell tool's new default description; the environment section is masked because it names the platform's shell, which differs between CI runners. New snapshots: environment_powershell, environment_sh, environment_custom, environment_allowlist, environment_container, shell_tool_description_powershell. SECURITY.md and SECURITY_TESTS.md (RED-7) state what the section tells the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ancelled rows The TUI's tool hook sends each result straight to the UI, while the ToolStarted and ToolFinished events pass the usage task first, so a result could arrive before its call's start event. The transcript then made a placeholder row named "tool", the start event added a second row, and only the second was finished; when the turn ended, cancel_running marked the placeholder cancelled. Those were the nameless "cancelled tool" rows of 3 to 27 seconds beside real tool rows. The start event now fills in a placeholder with the same call id instead of adding a row, and UiMsg::ToolResult carries the tool name, so a row made from a result alone still shows which tool it is. Tests: a_result_that_overtakes_its_start_event_leaves_no_orphan_row (app.rs, replays the order for one call and two calls of one turn; it failed on the old code with two "cancelled tool" rows) and a_result_before_the_start_event_fills_one_named_row (transcript.rs). Existing tests that build UiMsg::ToolResult or call set_tool_result now pass the tool name; no assertion changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes the check for the ticket "Permission friction on edit_file": one "session" answer, then five edit_file calls with different path spellings through the registry Wiring builds for an unmanaged session, and one more through a subagent registry from the same wiring. The prompt is asked once. The test passed on the existing code, so no code changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nvironment changes The snapshot without_a_planner_the_coder_requests_do_not_change is updated on purpose: it now holds both the new edit_file and write_file descriptions and the masked environment section with the neutral shell description. Only those two differences appear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each new test was seen failing on 0c32efb before the fix: - an_overlapping_second_match_is_ambiguous: `\n\n` over three CRLF breaks, and `aa` in `aaa`, were applied as unique matches. - a_line_ending_in_a_carriage_return_matches_an_old_text_with_an_lf_break: a line ending `\r\r\n`, copied as `x\r` plus LF, was not found. - an_old_text_with_a_byte_order_mark_matches_only_at_the_start: an old text led by a BOM matched mid-file and in files without one. - not_found_shows_a_carriage_return_at_the_end_of_a_line: str::lines hid the trailing `\r`, so the hint showed lines equal to the old text. - no_preview_for_arguments_the_tool_rejects: `replace_all: "yes"` was previewed although the tool refuses it. Verify-only (passed before the fix): line_endings_hold_for_the_listed_awkward_inputs and write_file_and_its_preview_agree_on_line_endings. No existing test changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README now answers, in order, what Anvil is, how it works (a diagram with a text version and the plan, build, verify, review loop as state.rs runs it), why it is safe (one row per control with its claim IDs and a test listed in docs/SECURITY_TESTS.md) and where it stops, then a command-only quick start, a short administrator section with a policy example checked by `anvil policy check`, the document index and a short development note. The sentence naming sectors is gone. No screenshot is shown, since none can be confirmed current. Length, counted with wc -l -w without the "Documentation" section: 111 lines and 1,312 words before, 105 lines and 1,199 words after. The configuration examples, the build-from-source commands, the plain-http rule, the trust prompt and a hosted provider example move to a new "Configuration" section of docs/USAGE.md. Five reader-test rounds and the judgment calls are in docs/DECISIONS.md. No test or snapshot changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README no longer holds the hosted API example; docs/USAGE.md does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Run after merge
The live repository description and topics change only when this merges, so they and the README never disagree in public:
The description is 208 characters. Each of the four controls it names is enforced on this branch and has tests listed in
docs/SECURITY_TESTS.md(POL, NET, FS and AUD rows). All nine suggested topics fit what the code does, so none were dropped.Repositions Anvil as a coding agent harness for open-weight models in regulated, restricted-network environments, and hardens it so an IT security team can approve it for a developer workstation that talks to a self-hosted model endpoint, and can prove afterwards what it did.
Start with
docs/HARDENING_REPORT.md(per-phase summary), thenSECURITY.md,docs/SECURITY_TESTS.md(every claim with the test that proves it) anddocs/DECISIONS.md(every choice with its reason).Method
Phases
Remove. Deleted from the binary:
A project
.envis never loaded. Setup writes one self-hosted endpoint.Managed policy. A fixed-path, ownership-checked, versioned
policy.tomlbeats every other layer. A conflict is an error that names the key. Project files cannot loosen anything. Trust is pinned to a content hash. Tools never write the files that grant power. Includesanvil policy showandanvil policy check, pluspolicies/restricted.tomlandpolicies/standard.toml.Tool confinement.
off,allowlist(no shell, fixed git subcommands) andask(deny categories).Network egress.
host:portcheck.anvil doctor --egress.Data protection.
Audit log.
anvil-telemetryis nowanvil-audit, with usage records in.anvil/usage/. A hash-chainedaudit.jsonlper session is mirrored and fails closed, and subagents are audited. Addsanvil audit verifyandanvil audit show.Supply chain.
--locked,SHA256SUMS, an SBOM, provenance attestations and a vendored source archive.cargo deny, Dependabot, CODEOWNERS.CHANGELOG.md.Documentation. README, SECURITY, threat model (OWASP Top 10 for Agentic Applications 2026), NIST control mapping (it states that Anvil holds no certification and has had no independent assessment), admin guide, deployment guide, security test index, roadmap and code tour.
Second round: Windows edit fixes and a README for an IT reviewer
The owner asked for this work to go into this pull request instead of a separate
fix/windows-edit-ergonomicsbranch and PR. Judgment calls are indocs/DECISIONS.mdunder "Windows edit fixes: file tools", "...: environment, transcript rows and session approvals", "...: line-ending review" and "README for an IT reviewer".Part A: tool faults found in real use on Windows
Both models in the Nov 19 runs failed their first multi-line
edit_file, saw namelesscancelled toolrows, and guessed at the shell.Root causes, each confirmed in the code
read_fileshowed LF-only lines, butedit_filesearched the raw CRLF bytes, so a multi-lineoldcould never match in a CRLF file.cancelled toolrows came from an ordering race. A tool's result reaches the full-screen UI on a direct channel, while its start event goes through the usage task first, andtokio::select!picks either. A result that arrived first created a placeholder row named literally "tool". The start event then added a second row, and the end of every turn (not only a user cancel) marked the stranded placeholder cancelled, so its duration was the rest of the turn. A replay test showed exactly these rows on the old code.read_filefailure was an argument error whose message did not say which argument was wrong or what is accepted.What changed
edit_fileignores line endings and nothing else, so tabs, spaces and indentation must still match. Only the matched span changes. The new text takes the ending of the lines it replaces, and a byte order mark is kept. An ambiguous match is still refused, and overlapping matches now count as ambiguous.oldoccurs, names a whitespace difference with the whitespace made visible, or says plainly that nothing similar exists. It is capped at 20 lines, 160 characters per line and 4096 bytes, and redacted likeread_file.write_filewrites CRLF when it replaces an all-CRLF file with LF-only content. New files and mixed files are written exactly as given. The diff preview uses the same code as the write.# Environmentsection. It states the OS family, the path separator and how the shell tool starts commands, taken from the effectivetools.shelland the[shell]mode. It covers PowerShell,pwsh,cmd, POSIX shells, a custom program, direct start in allowlist mode (no pipes or redirection), the container executor, andoff, where no shell is mentioned. The shell tool's description carries the same sentence. The section names no user, host or home path, and it is fixed for the session so the cached prompt prefix holds.a_session_answer_holds_for_later_edits_in_the_same_sessionpassed on the existing code, so nothing else changed.Tests
edit_file.rs:an_lf_old_text_edits_a_crlf_file_and_every_line_stays_crlfa_crlf_old_text_edits_an_lf_file_and_the_file_stays_lfin_a_mixed_file_only_the_replaced_lines_changea_byte_order_mark_is_keptreplace_all_works_across_crlf_linesa_match_that_is_ambiguous_across_line_endings_is_refusededge_cases_of_line_endingsnot_found_*tests, includingnot_found_stays_within_its_size_limitthe_not_found_message_redacts_a_key_block_whichever_lines_it_showsargument_errors_name_the_argument_and_what_it_acceptswrite_file.rs:lf_content_over_a_crlf_file_is_written_as_crlfandmixed_lf_and_new_files_are_written_as_given.read_file.rs:argument_errors_name_the_argument_what_was_wrong_and_what_it_accepts.prompts.rs: the environment-section tests for PowerShell,sh, a custom shell, each hardening shell mode, and that it names no user, host or home path.app.rs:a_result_that_overtakes_its_start_event_leaves_no_orphan_row, the replay test.tests/edit_line_endings.rs:an_edit_copied_from_read_file_succeeds_first_try_on_a_crlf_file, the end-to-end regression test with the scriptedfakeprovider.Every new test failed on the old code before its fix, except the ones marked verify-only in the commit messages. CI runs all of them on both the Windows and the Ubuntu runner.
Independent break attempt. A reviewer that had not written the code tried odd inputs:
\r, and\r\r\n;oldthat ends mid-line, and an emptynew;oldequal to the whole file.It found five breaks, each fixed after a failing test:
\r\r\n, written the wayread_fileshows it, did not match.oldlet it match anywhere, even in files with no byte order mark.\r.Two cases remain, both recorded as decisions:
oldthat needs the same\r\nread two ways in one string still does not match.oldwith trailing spaces can get the whitespace hint against a longer line.SECURITY.mdchanged in the same commits: there is a new "What a write changes" bullet (FS-8) and an "Environment" bullet under what reaches the model (RED-7).Part B: README
docs/USAGE.md, where nothing was deleted.docs/SECURITY_TESTS.md; what Anvil does not do; the quick start; administrators; the index; development.host:portpairs. A task runs plan (a person approves), build (writes and commands ask unless a rule decides), verify (the project's check command, whose exit code decides), then review (up to three rounds). Every session writes a local audit log.ANVIL_ENDPOINT_KEYor~/.anvil/.env. Runanvil setup --endpoint <url>,anvil doctorandanvil doctor --egress, thenanvil "<task>". Administrators placepolicy.tomlat the fixed path and useanvil policy checkandanvil policy show.docs/USAGE.md.Numbers
main, 851 at the start of the hardening run, 1044 at its end.cargo test --allon Windows: 1019 passed, 0 failed, 2 ignored at the end of the hardening run; 1062 passed, 0 failed after the second round.Cargo.lock: 427 packages before and after; no new third-party crate.Not done
Listed in
docs/ROADMAP.md:Also not done:
Owner actions
mainstill requiresci.v0.2.0after merge and check the first release run.[tickets]) from existing~/.anvil/config.tomlfiles.🤖 Generated with Claude Code