Repository navigation
fix(security): deny same-user inspection of tole, scrub the mission verify command and stop gates - #687
Merged
Conversation
…p-gate children (wip)
…cret, docs and changelog
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Nov 13, 2026
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
Two HIGH findings of the #594 audit, fixed together because each one alone leaves the other open:
toleprocess now marks itself non-dumpable on Linux (prctl(PR_SET_DUMPABLE, 0)) as the first statement ofmain. A same-user child (arun_commandcall, a job, a cron script, a hook, an MCP server, a test run by--verify) can no longer read tole's/proc/<ppid>/environor/proc/<ppid>/mem, or ptrace it.tole mission --verifycommand and theon_turnendstop gates run through the ENV-1 scrub as their own[secrets]consumers,verifyandturnend, which receive no secret by default. An explicit[secrets]grant restores one.Why
The ENV-1 scrub only edits the environment a child starts with.
/proc/<ppid>/environshowed the child every secret tole was exec'd with (provider key,GITHUB_TOKEN,TOLE_SERVE_TOKEN, webhook keys), whatever the scrub removed. Separately,run_verifyransh -cwith tole's full, unscrubbed environment, without approval, and the command usually runs code the agent just wrote (cargo testruns build scripts and tests). The stop gates ran as thehookconsumer, which keepsGITHUB_TOKENby default, and they also usually run workspace code.Changes
tole_core::process_guard(new, not feature-gated):deny_inspection()(Linux:PR_SET_DUMPABLE0; a no-op returningOkelsewhere) andinspection_denied(). libc was already a dependency of both crates; no new dependency. The Linux code is behindcfg(target_os = "linux").tole-climain: calls it before argument parsing, so before any thread or child exists. serve, mission, cron,hookand child agents (tole runprocesses) all start in thismain, so there is no other entry point to cover.tole-replay(an eval binary behind thereplayfeature) does not call it.secret_release: new consumersVERIFY = "verify"andTURNEND = "turnend". The default release does not bind them.mission.rsrun_verify:scrub_env_for(.., VERIFY).hooks.rsProcessHook::run_raw(used only by the turn-end gates): consumerturnendinstead ofhook. Pre/post tool hooks keephookand itsGITHUB_TOKENdefault.secrets-integrations-design.md§9 table and rationale, README[secrets]paragraph, and two CHANGELOG[Unreleased]entries. The verify and stop-gate one is marked BREAKING with a migration note.Decisions to check
/proc/<pid>/environshows the exec-time block, whichunsetenvdoes not erase. tole also reads several secrets lazily (provider chain,[secrets]grants passed togh/git/hooks/MCP by inheritance), so removing them would break those consumers. Andremove_varis unsound once threads may exist. Non-dumpable is what actually closes/proc/<pid>/environand/proc/<pid>/mem./proc/self/environbecomes root-owned too; tole never reads it./proc/<pid>/statstays world-readable, so delegation lease liveness is unchanged, and a test covers that.verifyandturnendare separate so an owner can grant one without the other.CAP_SYS_PTRACEstill reads tole's files. macOS (KERN_PROCARGS2) and Windows expose a same-user process's environment by other means. A secret the owner keeps in a readable file (a config,~/.netrc) is readable by any same-user child. These belong to the sandbox work in feat(plugins): sandbox wrapper for third-party stdio servers, lazy start, tool retrieval by meaning #601. Also, the flag resets to 1 in an exec'd child, which is expected: eachtolechild sets it again in its ownmain.Testing
crates/tole-core/tests/process_guard.rs(Linux). The test re-runs itself with a canary secret in its exec-time environment, so the canary sits in/proc/<pid>/environ. When run as root, it re-runs asnobody, because root bypasses the check. Control: before the guard, a child does read the canary through/proc/$PPID/environ. After the guard, the read fails and the canary is absent. A second test checks thatcurrent_exe,/proc/self/stat,/proc/self/cgroupand a child's read of the parent's/proc/<pid>/statstill work.crates/tole-cli/tests/mission_e2e.rswith the real binary, a mock provider,TOLE_API_KEYandGITHUB_TOKENset. Atole mission --verifyand atole run --on-turnend <gate.sh>each recordprintenvandtr '\0' '\n' < /proc/$PPID/environ.verify_and_stop_gates_get_no_secret_by_default: neither secret appears in any of the four outputs.a_secrets_grant_restores_a_token_for_verify_and_stop_gates: withGITHUB_TOKEN = { tools = ["verify", "turnend"] }, both children see the token and still not the provider key.run_verifyscrub fails both e2e tests ("verify env holds the provider key").hookfails both ("gate env holds GITHUB_TOKEN" / "lacks the granted token").deny_inspectioncall frommainfails the default test ("tole's environ read by verify holds the provider key").deny_inspectionset dumpable to 1 fails the core test.--verify "printenv > verify_env.txt") now prints neitherTOLE_API_KEYnorGITHUB_TOKEN(status complete, verify failures 0).cargo fmt --all --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo test --workspace,cargo test -p tole-core --no-default-features,cora review --no-llm --base origin/develop(no issues). The non-Linux branches ofprocess_guardcompile foraarch64-apple-ios(checked in a scratch crate, because ring needs an iOS C toolchain to build all of tole-core).Closes #675
Closes #676