feat(vault-agent): anti-leak hardening — disable core dumps + ptrace#31
Merged
Conversation
On startup the agent now disables core dumps and marks itself non-dumpable (which also blocks same-user ptrace), so the in-memory user key / refresh token can't escape to a core file or a debugger. PRD §12 M7 hardening groundwork. - harden.rs: `harden_process()` wraps `secmem_proc::harden_process()` (audited rustix syscalls — keeps the crate's forbid(unsafe_code)). Best-effort: a sandbox that restricts setrlimit logs a warning and the agent keeps running (Priority 1 Stability). Linux test asserts /proc/self/status `Dumpable: 0` where the field is exposed. - main.rs: called first thing after arg parse, before `try_resume` reloads a key from the keyring, so any in-memory key already lives in a non-dumpable, core-dump-free process. Applies to the headless agent too (the dep is non-optional). - docs: CHANGELOG, README security note. mlock/no-swap (the other half of the persona's ask) remains a tracked follow-up. Co-Authored-By: Claude Opus 4.8 <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.
What
On startup the agent now disables core dumps and marks itself non-dumpable (which also blocks
ptraceby another same-user process). The agent holds the unwrapped user key and refresh token in memory; this closes two ways that material could escape the process — a crash writing a core file to disk, or a debugger attaching. PRD §12 M7 hardening groundwork.How
crates/vault-agent/src/harden.rs—harden_process()wraps [secmem_proc::harden_process()], which lowersRLIMIT_COREand setsPR_SET_DUMPABLE(0)via the auditedrustixsyscall layer — so this keeps the agent's#. Best-effort: if a sandbox restrictssetrlimit, it logs a warning and the agent keeps running (Priority 1 Stability — a partial-hardening failure must not take the agent down).main.rs— called first thing afterArgs::parse()(so--version/--helpstill exit cleanly) and beforetry_resumereloads a key from the keyring, so any in-memory key already lives in a non-dumpable, core-dump-free process. The dep is non-optional, so the headless agent hardens too.Tests
A Linux test asserts
/proc/self/statusshowsDumpable: 0after hardening (conditional: where a sandboxed/procomits the field, the call just must not panic —PR_SET_DUMPABLE(0)is unprivileged, so the assertion is deterministic where it applies).Verification
fmt --check, fresh-isolatedclippy --all-features -D warnings,cargo test --workspace --all-targets(agent 38/38),cargo deny check(secmem-proc / rustix / anyhow all license-clean), and both headless builds — all green.Manual runtime check on a normal kernel:
grep -E 'Dumpable|Max core' /proc/$(pgrep -n vault-agent)/status /proc/$(pgrep -n vault-agent)/limits→Dumpable: 0and a0core-file limit.Out of scope (tracked follow-up)
mlock/no-swap (lock key pages so secrets never hit swap) — the other half of the persona's ask; trickier withoutunsafeand can hitRLIMIT_MEMLOCK. Its own slice.🤖 Generated with Claude Code