GeezerVison is showing github.com — fix(security): stage-1 audit remediation — file modes, listener timeouts, path guards, toolchain pin by HardcoreMonk · Pull Request #91 · HardcoreMonk/anvil
Conversation
HardcoreMonk
commented
Aug 6, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Stage-1 remediation from the 2026-08-06 security audit. Four independent fixes, each with a test that was observed failing before the change.
What changed
Daemon artifacts are now owner-only. Per-VM rootfs images, snapshot memory.bin/state.bin and COW exception stores embed 0600 secrets (LLM provider API keys, the guest agent token, the operator control-plane bearer), but the inherited 0022 umask put them at 0644 inside 0755 directories — recoverable by any unprivileged local account with strings vm-*.ext4. Most of those files are written by child processes (Firecracker, cp, truncate), so per-call modes cannot close it; initUmask() sets 0077 before any bootstrap, the three workspace/snapshot MkdirAll literals move to 0700, and the systemd unit gains UMask=0077. UMask is a file-creation mask, not a sandbox, so the deliberately unhardened /dev/kvm, iptables and loop-mount access is untouched.
All four listeners bound their pre-auth timeouts. The control plane, runtime MCP gateway, scheduler and in-guest agent all left every http.Server timeout at the zero value, which means "no limit". ReadHeaderTimeout and IdleTimeout apply before any handler and therefore before authMiddleware, so no valid token was needed to pin connections, goroutines and fds. ReadTimeout/WriteTimeout stay unset on purpose — SSE Town Wall streams, NDJSON task streams and multi-gigabyte snapshot/workspace bodies outlive any fixed budget — and the tests assert they remain zero so a later "completeness" edit cannot introduce them.
. is rejected as a profile name. The config handlers' inline guard caught "", ".." and separators but not ".", so DELETE /config/profiles/%2e resolved to the profiles directory itself, skipped the in-use 409 guard (no VM has "." as its profile) and os.RemoveAll-ed every profile's goose.yaml, system.md and egress.json. A missing egress.json is a silent no-op, so VMs spawned afterwards would have come up with no egress enforcement. The create path already enforced ^[a-z0-9][a-z0-9_-]*$; its format half is now shared with the read/update/delete handlers.
PUT /hosts refuses config-managed hosts. DELETE already returned 409 for these; PUT did not. The scheduler is deliberately unauthenticated (loopback trust), so any local process could repoint a config-managed host's endpoint, and the control loop would then send ANVIL_SCHEDULER_API_TOKEN — a daemon control-plane bearer — to it on the next poll, with DELETE unable to clean up the record.
Go toolchain pinned to a patch release. CI and release both resolve the toolchain from go.mod, which declared only the go 1.25.0 floor, so builds shipped every stdlib advisory fixed since. govulncheck measured 14 reachable vulnerabilities at 1.25.5 and 0 at 1.25.12. No third-party module contributed any — the dependency tree is clean and the entire exposure was the toolchain version.
Verification
go build ./..., go vet ./..., go test -race -count=1 ./... (16 packages, 0 failures), gofmt -l . (no drift), govulncheck ./... → 0 vulnerabilities (was 14).
Behaviour changes reviewers should weigh
- The profile-name guard now matches the create path exactly, so a profile directory hand-made on disk with a non-conforming name (uppercase, dots) is no longer manageable through the API.
- Two pure extractions,
newSchedulerServer and newAgentServer, exist to make the timeout construction testable; Addr/Handler preservation is asserted.
Operator follow-up (not code)
os.MkdirAll does not narrow an existing directory. Hosts already running keep their 0755 workspace/snapshot directories and 0644 images, so a one-time chmod is required at deploy time for the umask change to take effect on existing state.
Not in this PR
The matching CI govulncheck gate and permissions: contents: read for ci.yml are ready but need a token with workflow scope to push.
🤖 Generated with Claude Code
Summary by CodeRabbit
-
Security
- Restricted snapshots, workspaces, and newly created files to owner-only access.
- Strengthened profile-name validation to block invalid and traversal-style paths.
-
Reliability
- Added safe HTTP header and idle-connection timeouts while preserving streaming and large transfers.
- Prevented direct updates to configuration-managed hosts; changes must use the hosts configuration.
-
Bug Fixes
- Corrected profile deletion and host update behavior with appropriate validation and conflict responses.
-
Build
- Pinned builds to Go 1.25.12.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…timeouts
Two hardening fixes from the 2026-08-06 security audit.
File modes: the daemon's artifacts — per-VM rootfs images, snapshot
memory.bin/state.bin, COW exception stores — embed 0600 secrets (LLM
provider API keys, the guest agent token, the operator control-plane
bearer). Under the inherited 0022 umask they landed at 0644/0755, so any
unprivileged local account could recover those secrets with a single
`strings vm-*.ext4`. Per-call modes cannot close this because most of the
artifacts are created by child processes (Firecracker, cp, truncate), so
initUmask() sets 0077 before any bootstrap and the three workspace/snapshot
MkdirAll literals move to 0700. The systemd unit gets UMask=0077 as defense
in depth; it is a file-creation mask, not a sandbox, so it does not disturb
the deliberately unhardened /dev/kvm, iptables and loop-mount access.
Listener timeouts: all four production http.Server instances (control
plane, runtime MCP gateway, scheduler, in-guest agent) left every timeout
at net/http's zero value, meaning "no limit". Both ReadHeaderTimeout and
IdleTimeout apply before any handler and therefore before authMiddleware,
so no valid token was needed to pin connections, goroutines and fds.
ReadTimeout and WriteTimeout stay unset on purpose: SSE Town Wall streams,
NDJSON task streams and multi-gigabyte snapshot/workspace bodies all
outlive any fixed budget, and the tests assert they remain zero.
Note for operators: os.MkdirAll does not narrow an existing directory, so
hosts already running keep their 0755 workspace/snapshot dirs and 0644
images. A one-time chmod is required at deploy time.
Co-Authored-By: Claude Fable 5 <[email protected]>
The inline guard on the profile config handlers rejected "", "..", "/" and
"\" but not ".". DELETE /config/profiles/%2e therefore reached
filepath.Join(workDir, "configs", "profiles", "."), which Clean collapses to
the profiles directory itself; the in-use (409) guard never fired because no
VM has "." as its profile, and os.RemoveAll then wiped every profile's
goose.yaml, system.md and egress.json. A missing egress.json is a silent
no-op in loadEgressProfile, so VMs spawned afterwards would come up with no
egress enforcement at all. The literal "." is cleaned away by ServeMux, but
the percent-encoded form is not, and handlers read the decoded path.
The create path already had this right: validateProfileName enforces
^[a-z0-9][a-z0-9_-]*$, which rejects ".", ".." and separators alike. Split
its format half out as validProfileNameSyntax and share it with the four
read/update/delete handlers, keeping the "default" reserved-word check on
the create path only so those handlers can still resolve the default
profile.
This tightens the read/update/delete surface to the same names the create
path already allows: a profile directory hand-made on disk with a
non-conforming name (uppercase, dots) is no longer manageable through the
API.
Co-Authored-By: Claude Fable 5 <[email protected]>
DELETE /hosts/{name} already returned 409 for a config-managed host, but PUT
had no such guard. The scheduler is deliberately unauthenticated (loopback
trust), so any local process could PUT an existing config-managed host's
name and repoint its endpoint. The control loop attaches
ANVIL_SCHEDULER_API_TOKEN — a daemon control-plane bearer — to its polls, so
the next cycle would have sent that token to the attacker's endpoint, and
DELETE could not clean the record up because it stayed config-managed.
The guard sits in the HTTP handler rather than in SetHostAndSave: the
hosts-file loading path uses ApplyConfiguredHostsAndSave and never calls
SetHostAndSave, so normal startup is unaffected.
Co-Authored-By: Claude Fable 5 <[email protected]>
CI and the release workflow both resolve their toolchain from go.mod, which
declared only the `go 1.25.0` floor. Builds therefore tracked 1.25.0 and
shipped every standard-library advisory fixed since. Measured with
govulncheck: 14 reachable vulnerabilities at 1.25.5 (crypto/tls, crypto/x509,
net/url, os, net, net/textproto, net/http, archive/tar), 0 at 1.25.12. None
came from third-party modules — the dependency tree is clean and the whole
exposure was the toolchain version.
A toolchain directive moves every build site together. The matching CI
govulncheck gate lands separately (it needs a token with `workflow` scope).
Co-Authored-By: Claude Fable 5 <[email protected]>
coderabbitai
Bot
commented
Aug 6, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Warning
Review limit reached
@HardcoreMonk, you've reached your PR review limit, so we couldn't start this review.
Next review available in: 29 minutes
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
How can I continue?
After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.
To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.
How do review limits work?
CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.
For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.
Please refer docs for additional details.
Review details
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 19eaed0c-9595-4b1c-88eb-a6e72e8541f5
📥 Commits
Reviewing files that changed from the base of the PR and between 8336bdc and 25161e6.
📒 Files selected for processing (1)
📝 Walkthrough
Walkthrough
Changes
HTTP listener timeouts
| Layer / File(s) |
Summary |
Configure stream-safe HTTP servers cmd/anvil-scheduler/main.go, cmd/goose-agent/main.go, cmd/goose-daemon/api.go, cmd/goose-daemon/mcp_gateway.go |
Scheduler, agent, control-plane, and MCP servers now set 10-second header-read and 120-second idle timeouts. Full read and write timeouts remain unset. |
Validate timeout contracts cmd/anvil-scheduler/server_timeouts_test.go, cmd/goose-agent/server_timeouts_test.go, cmd/goose-daemon/server_timeouts_test.go |
Tests verify timeout values and preservation of server addresses and handlers. |
Profile-name validation
| Layer / File(s) |
Summary |
Centralize profile-name validation cmd/goose-daemon/config_api.go, cmd/goose-daemon/builtins.go, cmd/goose-daemon/mcp_binding.go |
Profile-related handlers now use validProfileNameSyntax, which rejects empty, dot, traversal, and path-separator names. |
Test rejected profile paths cmd/goose-daemon/config_api_test.go |
Tests reject dot-profile paths and verify that existing profile directories remain unchanged after a rejected deletion. |
Owner-only filesystem permissions
| Layer / File(s) |
Summary |
Apply restrictive permissions cmd/goose-daemon/main.go, cmd/goose-daemon/api.go, ephemera.service.in, internal/storage/provisioner.go |
The daemon and systemd service use umask 0077. Snapshot and workspace directories use mode 0700. |
Validate permission settings cmd/goose-daemon/umask_test.go, internal/storage/workspace_perm_test.go |
Tests verify the process umask and directory modes. |
Scheduler host updates
| Layer / File(s) |
Summary |
Guard config-managed host updates internal/anvilmcp/scheduler_service.go, internal/anvilmcp/scheduler_service_test.go |
PUT /hosts returns HTTP 409 for config-managed hosts. Non-config-managed hosts continue to register successfully. |
Go toolchain pin
| Layer / File(s) |
Summary |
Pin the Go toolchain go.mod |
The module now declares toolchain go1.25.12. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Suggested reviewers: steve-seungeui
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 70.83% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title accurately summarizes the PR's security remediations, including file modes, listener timeouts, path guards, and the toolchain pin. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
fix/security-audit-stage1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@go.mod`:
- Around line 5-13: Update the release workflow’s setup-go step to use
actions/setup-go@v6 while preserving go-version-file: go.mod, so the release job
resolves the pinned toolchain go1.25.12. Locate the setup-go action in the
release job and change only its action version; do not remove the toolchain
directive from go.mod.
In `@internal/anvilmcp/scheduler_service.go`:
- Around line 103-106: Make the managed-host validation atomic with persistence
by moving the ConfigManagedHosts check from the PUT handler into SetHostAndSave,
where it must re-read the trimmed host name while holding the write lock and
return an error before saving. Update the caller to handle that error, and add a
concurrency test interleaving ApplyConfiguredHostsAndSave between the prior
guard and write to verify the endpoint is not persisted.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a5e7b751-9a20-403e-95eb-2178733bbdc2
📥 Commits
Reviewing files that changed from the base of the PR and between d534379 and 8336bdc.
📒 Files selected for processing (19)
cmd/anvil-scheduler/main.go
cmd/anvil-scheduler/server_timeouts_test.go
cmd/goose-agent/main.go
cmd/goose-agent/server_timeouts_test.go
cmd/goose-daemon/api.go
cmd/goose-daemon/builtins.go
cmd/goose-daemon/config_api.go
cmd/goose-daemon/config_api_test.go
cmd/goose-daemon/main.go
cmd/goose-daemon/mcp_binding.go
cmd/goose-daemon/mcp_gateway.go
cmd/goose-daemon/server_timeouts_test.go
cmd/goose-daemon/umask_test.go
ephemera.service.in
go.mod
internal/anvilmcp/scheduler_service.go
internal/anvilmcp/scheduler_service_test.go
internal/storage/provisioner.go
internal/storage/workspace_perm_test.go
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+5
to
+13
|
|
// Pin the build toolchain to a patch release rather than letting CI float on the
|
|
|
// `go` directive floor above. Both CI and the release workflow resolve their
|
|
|
// toolchain from this file, so without this line builds track 1.25.0 and ship
|
|
|
// every standard-library advisory fixed since. The 2026-08-06 security audit
|
|
|
// measured 14 reachable stdlib vulnerabilities at 1.25.5 (crypto/tls, crypto/x509,
|
|
|
// net/url, os, net, net/textproto, net/http, archive/tar) and 0 at 1.25.12.
|
|
|
// Raise this line — do not remove it — when adopting a newer patch release.
|
|
|
toolchain go1.25.12
|
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
workflow=".github/workflows/release.yml"
rg -n -C 5 \
'actions/setup-go@|go-version-file:|go-version:|GOTOOLCHAIN|go version' \
"$workflow"
echo "Confirm that the release build uses go1.25.12, not only the go.mod floor."
Repository: HardcoreMonk/anvil
Length of output: 712
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== go.mod toolchain/go directives =="
sed -n '1,20p' go.mod
echo
echo "== release workflow relevant lines =="
sed -n '1,120p' .github/workflows/release.yml
echo
echo "== setup-go `@v5` references in repo =="
rg -n 'actions/setup-go@[0-9]+' .github/workflows || true
Repository: HardcoreMonk/anvil
Length of output: 2786
🌐 Web query:
github actions setup-go v5 toolchain go-version-file support v6
💡 Result:
The setup-go action supports the Go toolchain directive when reading from a go.mod file [1][2]. Starting with version 6.0.0, when the go-version-file input points to a go.mod file, the action automatically detects and prioritizes the toolchain directive [3][2]. If a toolchain directive is present, the action uses its specified version; if not, it falls back to the version defined in the go directive [1][2]. This functionality is a standard feature of setup-go version 6 (v6) and later [2]. It is not a feature of v5, which does not natively support the toolchain directive in the same way for version resolution from go.mod [3]. To utilize this automatic toolchain detection, you should use setup-go@v6 or a newer version [2].
Citations:
Update the release job to honor the pinned Go toolchain.
.github/workflows/release.yml uses actions/setup-go@v5 with go-version-file: go.mod, while only setup-go v6+ resolves toolchain go1.25.12 from go.mod. This can leave the release build on the older go 1.25.0 toolchain and ship the stdlib vulnerabilities described in the go.mod comment. Change the release job to actions/setup-go@v6, or set go-version: '1.25.12' and add a go version check before the build.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@go.mod` around lines 5 - 13, Update the release workflow’s setup-go step to
use actions/setup-go@v6 while preserving go-version-file: go.mod, so the release
job resolves the pinned toolchain go1.25.12. Locate the setup-go action in the
release job and change only its action version; do not remove the toolchain
directive from go.mod.
Source: MCP tools
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+103
to
+106
|
|
if s.placements.IsConfigManagedHost(host.Name) {
|
|
|
http.Error(w, "config-managed host must be changed in the hosts file", http.StatusConflict)
|
|
|
return
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -u
rg -n -C 12 \
'IsConfigManagedHost|SetHostAndSave|ApplyConfiguredHostsAndSave|ConfigManagedHosts' \
internal/anvilmcp --glob '*.go'
Repository: HardcoreMonk/anvil
Length of output: 50374
Authorization Bypass (CWE-367): Time-of-check Time-of-use (TOCTOU) Race Condition
Reachability: Internal
Make the managed-host guard atomic with the write.
IsConfigManagedHost reads and releases the lock before SetHostAndSave acquires its write lock. If ApplyConfiguredHostsAndSave marks the same trimmed host.Name as managed in that window, the PUT guard can pass and then persist the attacker-supplied endpoint. Move the managed-host check inside SetHostAndSave: re-read ConfigManagedHosts inside the write lock and return an error before saving, and add a concurrency test that interleaves configuration loading between the guard and the write.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/anvilmcp/scheduler_service.go` around lines 103 - 106, Make the
managed-host validation atomic with persistence by moving the ConfigManagedHosts
check from the PUT handler into SetHostAndSave, where it must re-read the
trimmed host name while holding the write lock and return an error before
saving. Update the caller to handle that error, and add a concurrency test
interleaving ApplyConfiguredHostsAndSave between the prior guard and write to
verify the endpoint is not persisted.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Companion to the toolchain pin. The gate is reachability-aware, so an
advisory that exists in the firecracker-go-sdk transitive tree but is never
called does not block the build — the audit confirmed every third-party
advisory in this tree is unreachable, so only genuine exposure fails CI.
Also declares `permissions: contents: read`, which the workflow previously
left to the repository default.
Co-Authored-By: Claude Fable 5 <[email protected]>
Flagged by the commit security review, and consistent with what the audit
itself says about mutable dependency references. Pinning the tool costs no
detection coverage — govulncheck fetches advisory data from the vulnerability
database at run time, so the binary version does not bound what it can find.
Co-Authored-By: Claude Fable 5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 6, 2026
HardcoreMonk
added a commit
that referenced
this pull request
Aug 6, 2026
…-series
docs: record the #91~#99 security hardening series in RELEASE_NOTES
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|