Skip to content

The agent that grows with you

fix(debug): mask URL tokens and passwords in debug share uploads

FroRautb8a8be185d6e
diff --git a/hermes_cli/debug.py b/hermes_cli/debug.py
index 6de6cfed832..34e4aee801a 100644
--- a/hermes_cli/debug.py
+++ b/hermes_cli/debug.py
@@ -256,9 +256,12 @@ def _resolve_log_path(log_name: str) -> Optional[Path]:
return None
-def _redact_log_text(text: str, *, redact_url_credentials: bool = False) -> str:
+def _redact_log_text(text: str, *, redact_url_credentials: bool = True) -> str:
"""``redact_sensitive_text(force=True)`` + email scrub — fires regardless of the operator's
- ``security.redact_secrets`` setting; only the in-memory upload copy is sanitized."""
+ ``security.redact_secrets`` setting; only the in-memory upload copy is sanitized. URL
+ credentials (``?token=``, ``user:pass@``) are masked too by default: log lines keep them, since
+ default redaction spares OAuth/magic-link URLs, but nothing follows a link out of an uploaded
+ report."""
if not text:
return text
from agent.redact import redact_sensitive_text
@@ -351,7 +354,7 @@ def _capture_default_log_snapshots(
def _capture_dump(redact: bool = True) -> str:
"""Run ``hermes dump`` and return its stdout, force-redacted unless *redact* is False: the dump
is upload-bound and quotes config values (e.g. ``fallback_providers``), so URL credentials are
- redacted too, unlike the logs (whose policy spares OAuth/magic-link URLs)."""
+ redacted too, as in the uploaded logs."""
from hermes_cli.dump import run_dump
capture = io.StringIO()
with contextlib.redirect_stdout(capture), contextlib.suppress(SystemExit):
diff --git a/tests/hermes_cli/test_debug.py b/tests/hermes_cli/test_debug.py
index 542936298a8..31c319d26f5 100644
--- a/tests/hermes_cli/test_debug.py
+++ b/tests/hermes_cli/test_debug.py
@@ -870,6 +870,27 @@ class TestCollectShareBundle:
# With redaction it must be scrubbed everywhere.
assert secret not in "\n".join(redacted.values())
+ def test_redaction_masks_url_credentials(self, hermes_home):
+ """Log-time redaction leaves ``?token=`` and ``user:pass@`` in URLs for tool flows;
+ the upload must not carry them."""
+ from hermes_cli.debug import collect_share_bundle
+
+ query_token = "Q7fK2mZp9RtX4vLb8NcW1yHs"
+ password = "Pw7Kq2Lm9Xs4Vb"
+ (hermes_home / "logs" / "agent.log").write_text(
+ "2026-09-29 01:00:00 INFO plugins.web.firecrawl.provider: Firecrawl scraping: "
+ f"https://files.example.com/export.csv?token={query_token}&page=2\n"
+ f"2026-09-29 01:00:01 INFO agent: using proxy http://alice:{password}@10.0.0.5:3128\n"
+ )
+ with patch("hermes_cli.dump.run_dump"):
+ bundle = "\n".join(collect_share_bundle(log_lines=50, redact=True).values())
+
+ assert query_token not in bundle
+ assert password not in bundle
+ # Only the credential values go; the URLs stay readable.
+ assert "export.csv?token=***&page=2" in bundle
+ assert "alice:***@10.0.0.5:3128" in bundle
+