Skip to content

The agent that grows with you

fix(secrets): redact command in process checkpoint file (#77484)

Soheil Fakour8969ebac1cb3
diff --git a/tests/tools/test_process_registry.py b/tests/tools/test_process_registry.py
index 0ad0c658e58..ce81457012a 100644
--- a/tests/tools/test_process_registry.py
+++ b/tests/tools/test_process_registry.py
@@ -903,6 +903,26 @@ class TestCheckpoint:
data = json.loads(checkpoint.read_text())
assert data == []
+ def test_checkpoint_redacts_command_with_inline_secret(self, registry, tmp_path):
+ """Issue #77484: the checkpoint file persists raw commands; inline
+ credentials (e.g. ``curl -H 'Authorization: Bearer sk-...'``) must be
+ redacted before write. Recovery only uses command for display/logging
+ (the process is already running), so masking is lossless."""
+ checkpoint = tmp_path / "procs.json"
+ with patch("tools.process_registry.CHECKPOINT_PATH", checkpoint):
+ secret = "sk-secret1234567890"
+ command = f"curl -H 'Authorization: Bearer {secret}' http://x"
+ s = _make_session(sid="proc_secret", command=command)
+ s.pid = 12345
+ s.host_start_time = int(time.time())
+ registry._running[s.id] = s
+ registry._write_checkpoint()
+
+ data = json.loads(checkpoint.read_text())
+ assert data[0]["session_id"] == "proc_secret"
+ assert secret not in data[0]["command"]
+ assert data[0]["command"] != command
+
# =========================================================================
# Kill process
# =========================================================================
diff --git a/tools/process_registry.py b/tools/process_registry.py
index c04148e47e1..04d93fbd255 100644
--- a/tools/process_registry.py
+++ b/tools/process_registry.py
@@ -49,6 +49,8 @@ from typing import Any, Dict, List, Optional
from hermes_cli.config import get_hermes_home
+from agent.redact import redact_sensitive_text
+
logger = logging.getLogger(__name__)
@@ -2067,7 +2069,14 @@ class ProcessRegistry:
s.host_start_time = self._safe_host_start_time(s.pid)
entries.append({
"session_id": s.id,
- "command": s.command,
+ # Redact inline credentials before persisting to
+ # disk — the checkpoint file lives under
+ # ~/.hermes/processes.json with the raw command
+ # (issue #77484). Recovery only uses command for
+ # display/logging (the process is already running;
+ # adoption re-validates the PID, never re-runs the
+ # command), so masking is lossless.
+ "command": redact_sensitive_text(s.command, code_file=True),
"pid": s.pid,
"pid_scope": s.pid_scope,
"host_start_time": s.host_start_time,