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.
This commit is contained in:
dsad
2026-07-07 00:14:42 +03:00
committed by Teknium
parent d2d7766750
commit 6c7cfd6621
+8 -4
View File
@@ -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 -----