Skip to content

fix(core): redact base64 blobs and message history from debug dumps#6326

Merged
bug-ops merged 1 commit into
mainfrom
fix/6315-debug-dump-tool-output-redact
Jul 16, 2026
Merged

fix(core): redact base64 blobs and message history from debug dumps#6326
bug-ops merged 1 commit into
mainfrom
fix/6315-debug-dump-tool-output-redact

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • dump_tool_output, dump_response, dump_tool_error, and dump_focus_knowledge in crates/zeph-core/src/debug_dump/mod.rs wrote raw text to disk with no redaction, so a tool returning binary data as plain text (e.g. a vision/screenshot tool emitting base64 image bytes instead of a typed MessagePart::Image) leaked full payloads into debug dump files.
  • Added redact_binary_blobs to crates/zeph-core/src/redact.rs: replaces contiguous runs of 200+ base64-alphabet characters with a <redacted possible binary data: N bytes, blake3:...> marker (decode-then-hash, with an undecodable-run fallback). Applied alongside the existing scrub_content across all four text-dump sinks.
  • dump_request (json_dump/raw_dump) also recursively redacts every string leaf of its assembled JSON payload via a new redact_json_value helper — without this, a blob closed off in dump_tool_output would resurface unredacted one turn later as message history serialized into the next request dump (found during adversarial review, same class of gap as the prior debug_dump writes raw MessagePart::Image base64 bytes to disk #6306 cycle).
  • Unconditional, no new config flag — debug dumps remain an opt-in, off-by-default diagnostic aid ([debug] enabled).

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins (targeted redact/debug_dump filter: 95/95 passed)
  • RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"
  • gitleaks protect --staged — clean
  • New unit tests for redact_binary_blobs (redaction, marker stability, short-string passthrough, non-over-redaction on IDs/hashes, undecodable fallback, proptest never-panics)
  • New end-to-end tests proving each of the four dumper methods (plus dump_request) redacts through the real public call path, asserting raw-payload absence, not just marker presence
  • Live-test the base64 heuristic against real web_scrape tool output for false positives (flagged during review as a recommended follow-up, not required to close this issue)

Closes #6315

@bug-ops
bug-ops enabled auto-merge (squash) July 16, 2026 18:14
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/L Large PR (201-500 lines) labels Jul 16, 2026
@bug-ops
bug-ops force-pushed the fix/6315-debug-dump-tool-output-redact branch from 1654b28 to 1ca70d0 Compare July 16, 2026 19:18
@github-actions github-actions Bot added size/XL Extra large PR (500+ lines) and removed size/L Large PR (201-500 lines) labels Jul 16, 2026
dump_tool_output, dump_response, dump_tool_error, and dump_focus_knowledge
wrote raw text to debug dump files with no redaction, so a tool returning
binary data as plain text (e.g. a vision tool emitting base64 image bytes
instead of a typed MessagePart::Image) leaked full payloads to disk.

Add redact_binary_blobs to scrub_content's redaction pipeline: contiguous
runs of 200+ base64-alphabet characters are replaced with a length/hash
marker. Apply it plus scrub_content across all four text-dump sinks, and
recursively across dump_request's assembled JSON payload via a new
redact_json_value helper, since a blob closed off in dump_tool_output
otherwise resurfaces unredacted one turn later as message history in the
next request dump.

Closes #6315
@bug-ops
bug-ops force-pushed the fix/6315-debug-dump-tool-output-redact branch from 1ca70d0 to 8b08e42 Compare July 16, 2026 19:19
@bug-ops
bug-ops merged commit 322108b into main Jul 16, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6315-debug-dump-tool-output-redact branch July 16, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug_dump: dump_tool_output writes raw tool-output text unredacted

1 participant