From 6c7cfd662152c875ec3b048fb27970131cab07f3 Mon Sep 17 00:00:00 2001 From: dsad Date: Tue, 7 Jul 2026 00:14:42 +0300 Subject: [PATCH] fix(security): redact secrets in background process notifications Apply _redact_process_result() to completion and watch_match notifications before enqueuing them in the completion_queue. Previously, the explicit process tool path (poll/log/wait) applied redact_terminal_output() via _redact_process_result(), but the automatic notification delivery path (notify_on_complete, watch_patterns) only applied strip_ansi(). This meant API keys, tokens, and other secrets from background process output were injected into the LLM conversation unmasked. The fix ensures both code paths apply the same redaction, matching the foreground terminal tool behavior. --- tools/process_registry.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/process_registry.py b/tools/process_registry.py index 0883fa1c22..d46341d039 100644 --- a/tools/process_registry.py +++ b/tools/process_registry.py @@ -621,7 +621,7 @@ class ProcessRegistry: if not self._global_watch_admit(now): return - self.completion_queue.put({ + notification = { "session_id": session.id, "session_key": session.session_key, "command": session.command, @@ -635,7 +635,9 @@ class ProcessRegistry: "user_name": session.watcher_user_name, "thread_id": session.watcher_thread_id, "message_id": session.watcher_message_id, - }) + } + _redact_process_result(notification) + self.completion_queue.put(notification) def _global_watch_admit(self, now: float) -> bool: """Return True if this watch_match event is allowed through the global breaker. @@ -1563,7 +1565,7 @@ class ProcessRegistry: if was_running and session.notify_on_complete: from tools.ansi_strip import strip_ansi output_tail = strip_ansi(session.output_buffer[-2000:]) if session.output_buffer else "" - self.completion_queue.put({ + notification = { "type": "completion", "session_id": session.id, "session_key": session.session_key, @@ -1576,7 +1578,9 @@ class ProcessRegistry: # a consumer-observed completion timestamp, this does not vary # based on which watcher notices exit first. "started_at": session.started_at, - }) + } + _redact_process_result(notification) + self.completion_queue.put(notification) # ----- Query Methods -----