feat(harness): hard-block the embedded agent from reading .env; drop WebFetch - #57
Merged
itelo merged 1 commit intoAug 24, 2026
Conversation
The embedded integration agent was only *instructed* not to read secrets — no enforcement. A developer's .env routinely holds secrets beyond the Seam key (DB URLs, Stripe keys, …) that must never enter the model context. - Add a PreToolUse deny hook (anthropic harness) that blocks any tool whose input targets .env / .env.* (except .env.example). A deny overrides the broad Read allow and fires for every tool, so Read/Grep/Edit/Write are all covered. - Remove WebFetch from ALLOWED_TOOLS: arbitrary web egress isn't needed (docs come from the seam-docs MCP; the pi harness already omits it) and it was the obvious exfiltration channel. - Shared, unit-tested helpers isSecretFilePath / toolInputTouchesSecret. pi harness (eval-only) tracked as a follow-up in ENG-2925.
itelo
deleted the
itelo/eng-2925-wizard-hard-block-the-embedded-agent-from-reading-env
branch
August 24, 2026 19:10
4 tasks
itelo
added a commit
that referenced
this pull request
Aug 24, 2026
Follow-up to ENG-2925 (#57), completing ENG-2926. - pi harness: wrap the built-in Read/Edit/Write/Ls/Find/Grep tools so a call whose input targets a secret file (.env, …) is refused before it runs — parity with the anthropic PreToolUse deny. Reuses toolInputTouchesSecret; pi's path fields (path/glob/dir/directory) are now covered too. - anthropic harness: add a PostToolUse hook that strips .env-sourced lines from Grep output via updatedToolOutput. The PreToolUse deny only fires when a tool *names* a secret path, so a repo-wide grep (path ".") could still surface .env lines; this closes that residual. - secret-paths.ts: add redactSecretGrepLines + the pi path-field keys, with tests.
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.
Summary
Closes the gap where the wizard's embedded integration agent was only instructed not to read secrets (a system-prompt line), with no enforcement. A developer's
.envroutinely holds secrets beyond the Seam key — DB URLs, Stripe keys, etc. — that must never enter the model context.Implements ENG-2925.
Changes
src/lib/steps/harness/anthropic.ts): blocks any tool call whose input targets.env/.env.*(except.env.example). A deny overrides the broadReadallow and fires for every tool, so Read/Grep/Edit/Write are all covered.WebFetchfromALLOWED_TOOLS(the "review WebFetch" ask): arbitrary web egress isn't needed — references come from the seam-docs MCP, and the pi harness already omits it — and it was the obvious exfiltration channel. Reintroduce behind an allowlist if a real need appears.src/lib/steps/harness/secret-paths.ts(isSecretFilePath/toolInputTouchesSecret) with unit tests.Already safe (unchanged, for context)
buildAgentEnvdropsANTHROPIC_API_KEYand injects only the short-lived scoped wizard token..envgitignored + value-less.env.example.Scope / follow-ups (in ENG-2925)
SEAM_WIZARD_HARNESS=pi(eval), the eval workspace carries no real secret, and pi'sToolDef.executeshape isn't documented enough to guard without guessing.Grepacross the repo could still surface secret lines from other files; a PostToolUse redaction pass is the natural next step. The direct-.env-access vector is closed here.Testing
npm run lintcleannpm run typecheckcleannpm test— 155 passed (+5 new:secret-paths.test.ts)Security & Compliance
🤖 Generated with Claude Code