feat(security): exfiltration guards (Phase 4, #1195)#1246
Merged
Conversation
… writes (Phase 4, #1195) Add ExfiltrationGuard to zeph-core with three independently toggleable guards under [security.exfiltration_guard] config section: - Output scanner: strips markdown image injection (inline + reference-style) from LLM responses at 5 integration points (streaming, non-streaming, native text, ToolUse text, cache hits) - Tool URL validator: cross-references URLs in tool call arguments against flagged untrusted content using HashSet for O(1) lookups - Memory write guard: skips Qdrant embedding for injection-flagged content while preserving SQLite conversation continuity Addresses all architecture critic findings (S1-S4, M1-M4) and code review issues (SEC-EX-01 through SEC-EX-06). Adds 20 unit tests, 3 metrics counters, and updates docs and READMEs.
This was
linked to
issues
Mar 5, 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.
Summary
Phase 4 of Untrusted Content Isolation epic (#1195). Adds
ExfiltrationGuardtozeph-corewith three independently toggleable guards:) and reference-style (![alt][ref]) image injection from LLM output at 5 integration points (streaming, non-streaming, native text, ToolUse text, cache hits)Config
Changes
crates/zeph-core/src/sanitizer/exfiltration.rs(new):ExfiltrationGuard,ExfiltrationGuardConfig,ExfiltrationEvent, 20 unit testscrates/zeph-core/src/agent/tool_execution.rs: 5 scan integration points, tool URL validation, flagged URL collectioncrates/zeph-core/src/agent/persistence.rs:has_injection_flagsparameter onpersist_messagecrates/zeph-core/src/config/types.rs:ExfiltrationGuardConfigunderSecurityConfigcrates/zeph-core/src/metrics.rs: 3 new countersReview process
Architecture critic (4 significant + 4 minor gaps) → all addressed in implementation → code review (2 critical + 3 important) → all fixed and re-review approved.
Known limitations (Phase 5)
%68ttps://)<img>tag injectionTest plan
cargo nextest run --features full: 4029/4029 passcargo clippy --features full: 0 warningscargo +nightly fmt --check: cleanCloses phase 4 of #1195.