Repository navigation
feat(secrets): sensitive files read redacted, approved raw reads, doctor report - #632
Merged
Merged
Conversation
…tor report #598 part b (design secrets-integrations §4). read_file on .env*, *.pem, id_*, .npmrc, .netrc or *.key (file name, case-insensitive, by the requested name or the resolved real path, so a symlink to .env counts) returns KEY=«redacted» lines, a key file one marker, and no content hash. The verbatim read is the new read_file_raw tool, Risk::Write: approve its call or start with --allow read_file_raw. The git tool's diff hides every hunk line of a sensitive file and the text after its hunk ranges; cora_search hides the text of a hit in one. read_file now opens with O_NONBLOCK|O_NOFOLLOW, checks the open handle and reads with a cap, so a FIFO or a file swapped in after the check cannot hang or bloat the read. tole doctor adds a secrets report, names only: which secret names are set, which tools may receive each (flagged when a model command may), what reaches the children of model commands and of a child session, and how to approve a verbatim read.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
11 tasks done
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
#598 part (b). Sensitive files (
.env*,*.pem,id_*,.npmrc,.netrc,*.key) never come back verbatim from a tool that returns file bytes.read_fileshowsKEY=«redacted», and a verbatim read is a separate, approval-gated tool,read_file_raw(Risk::Write).tole doctorgains a secrets report that shows names only.Why
Owner decision 2026-11-11 (
docs/secrets-integrations-design.md§4). A.envinside the workspace was readable verbatim, so its values entered the model's context and the session log. AI-assisted code leaks secrets at about twice the baseline (GitGuardian 2026).Changes
tole-core/src/sensitive.rs(new):is_sensitive_name: matches the file name, case-insensitive.is_sensitive_path(requested, real): true when the name the tool was asked for OR the resolved real path matches, so a symlinknotes.txt -> .envis sensitive.redact_content: blank lines stay,KEY=valuebecomesKEY=«redacted», and every other line becomes the marker (comments included, since they can hold values). A key or pem file becomes a single«redacted».redact_diff: in a sensitive file's diff section, headers and hunk ranges stay, every hunk line becomes+«redacted»,-«redacted»or«redacted», and the file text git prints after a hunk range is dropped.redact_hits: a search hit that names a sensitive file keeps its path; every other string field, at any depth, becomes the marker.read_file:redacted: true, and anotenamingread_file_raw.DefaultHasherof a short secret could be brute-forced offline, and editing such a file needs the verbatim read anyway.O_NONBLOCK|O_NOFOLLOW, checked on the open handle (regular file, size cap) and read throughtake(cap+1), so a FIFO or a file swapped in after the check cannot hang or bloat the read.read_file_raw(new,ReadFileTool::raw):Risk::Write, so each call needs approval, or an explicit--allow read_file_raw(the only way in a mission). It is a risk tier, not an environment opt-out. It is registered in plan mode too, since it writes nothing.gittool: stdout passes throughredact_diff.cora_search: the JSON passes throughredact_hits.tole doctor: a "secrets (names only)" block:[secrets]release lets receive it, marked!when that includesrun_command,job_startorcron;docs/secrets-integrations-design.md§10, with the tool table and how to approve;Every tool that can return file bytes, and what it does with a sensitive file:
read_fileKEY=«redacted»lines; a key or pem file one marker; no hashread_file_raw(new)Risk::Write)gitdiffgitstatuscora_searchedit_file,write_file,delete_fileedit_fileneeds the hash, so it needsread_file_rawfirst)run_command,job_start/job_pollSecretSetredacts known secret values on egress (documented residual)web_fetch,ghThere is no separate search, grep, list or diff tool: search is
cora_search(or a command), and diff is thegittool.Testing
All run locally on 0117e9f (develop 9f66f13), with
CARGO_TARGET_DIRset andCARGO_INCREMENTAL=0.cargo test --workspace --no-fail-fastpasses: 1564 passed, 0 failed (84 suites).cargo test -p tole-core --no-default-featurespasses: 545 passed;cargo check -p tole-core --no-default-features --testspasses.cargo test -p tole-cli --no-default-featurespasses: 463 passed; with--features shell-toolsadded, 626 passed. These ran on the commit before the final clippy and fixture-text fix, which changed no behaviour; the tole-core sensitive and read_file tests were rerun on the final head.cargo fmt --all -- --checkpasses.cargo clippy -D warningspasses for--workspace --all-targets,-p tole-core --no-default-features --all-targets,-p tole-cli --no-default-featuresand-p tole-cli --no-default-features --features shell-tools.cora review --no-llm --staged: "No issues found". Its first run flagged the fake private-key block in a test fixture; the fixture is now neutral text.New tests:
sensitive::tests:env.rs,my.envelope,npmrc);.envline redaction (export, spaces around=,\r\n, comments);read_file::tests::sensitive_files_read_redacted_and_raw_only_with_approval:.env,Server.PEM,.ENV.Local, and a symlinknotes.txt -> .env;read_file_raw;read_file_rawisRisk::Writeand returns verbatim content with a hash;read_file::tests::a_fifo_never_hangs_the_read: a FIFO named.enverrors within 5 s instead of blocking.git::tests::a_diff_hides_the_lines_of_a_sensitive_file: end to end through a fakegitbinary.doctor::tests::the_secrets_report_names_secrets_and_their_tools_never_values:!on a command grant, the command-children line and the child-session line;Red/green: each rule was broken on purpose, the named test failed, and it passed again once restored. All 13 breaks were caught:
Size: 648 changed lines (610 added, 38 removed) across 11 files.
Related Issues
Part (b) of #598 (secrets epic #594; follows #631).
Checklist
feat/sensitive-path-reads)develop