Repository navigation
feat(llm): add secret shield for outbound credential redaction - #50905
Closed
GiacomoSaccaggi wants to merge 4 commits into
Closed
GiacomoSaccaggi wants to merge 4 commits into
GiacomoSaccaggi wants to merge 4 commits into
Conversation
Scan LLM requests for credential patterns before sending to providers. Four opt-in modes: off (default), warn, mask, block. Detects 16 API key prefix families, JSON sensitive fields, HTTP auth headers, connection string URIs, and JWT tokens. Returns ShieldResult discriminated union so callers handle errors in their own channel.
85 tests: prefix patterns, JSON fields, headers, URIs, JWTs, idempotency, overlap, false positives, edge cases, tool description scanning, and full request-level ShieldResult handling. Runner: shield applied after publisher so block surfaces as Step.Failed in the UI. Detections logged via Effect.logWarning.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
This was referenced Oct 23, 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.
Issue for this PR
Closes #50904
Type of change
What does this PR do?
Adds opt-in credential scanning for outbound LLM requests. When enabled via
secret_shieldin config (orOPENCODE_SECRET_SHIELDenv var), it scans messages, system parts, and tool descriptions for credential patterns before they reachllm.stream().Four modes:
off(default, zero overhead),warn(log count, send original),mask(replace with[REDACTED]),block(fail the step).Detection covers 16 API key prefix families (OpenAI, Anthropic, GitHub, AWS, Stripe, etc.), JSON sensitive fields (
password,api_key,token), HTTP auth headers, connection string URIs, and JWTs.applySecretShield()returns aShieldResultdiscriminated union (ok | blocked) instead of throwing, so the runner surfaces blocks asStep.Failedin the UI via the existing publisher. Detections are logged throughEffect.logWarning.Files changed:
packages/llm/src/secret-shield.ts— redaction engine +applySecretShield()packages/llm/src/index.ts— exportspackages/core/src/config.ts—secret_shieldconfig fieldpackages/core/src/session/runner/llm.ts— shield wired after publisher setuppackages/llm/test/secret-shield.test.ts— 85 testsHow did you verify your code works?
Full monorepo typecheck also passes (30/30 packages via pre-push hook).
Screenshots / recordings
N/A — no UI changes. This is a transport-layer feature.
Checklist