Skip to content

The agent that grows with you

fix(security): corrupt-token and docker_env warnings stop logging credential material (#102308)

Sahil Vishnalyaaa0beef6848b
diff --git a/tools/environments/docker.py b/tools/environments/docker.py
index 33bc0919062..a000a311968 100644
--- a/tools/environments/docker.py
+++ b/tools/environments/docker.py
@@ -65,7 +65,7 @@ def _normalize_env_dict(env: dict | None) -> dict[str, str]:
if not env:
return {}
if not isinstance(env, dict):
- logger.warning("docker_env is not a dict: %r", env)
+ logger.warning("docker_env is not a dict: %s", type(env).__name__)
return {}
normalized: dict[str, str] = {}
for key, value in env.items():
@@ -73,7 +73,7 @@ def _normalize_env_dict(env: dict | None) -> dict[str, str]:
logger.warning("Ignoring invalid docker_env key: %r", key)
continue
if not isinstance(value, (str, int, float, bool)):
- logger.warning("Ignoring non-string docker_env value for %r: %r", key.strip(), value)
+ logger.warning("Ignoring non-string docker_env value for %r: %s", key.strip(), type(value).__name__)
continue
normalized[key.strip()] = value if isinstance(value, str) else str(value)
return normalized
diff --git a/tools/mcp_oauth.py b/tools/mcp_oauth.py
index 99ccb081a18..0ba5854dde9 100644
--- a/tools/mcp_oauth.py
+++ b/tools/mcp_oauth.py
@@ -302,7 +302,13 @@ class HermesTokenStorage:
try:
return cls.model_validate(data)
except (ValueError, TypeError, KeyError) as exc:
- logger.warning("Corrupt %s at %s -- ignoring: %s", label, path, exc)
+ # A pydantic ValidationError's str() echoes the raw input (the token material); log
+ # only which fields failed.
+ detail = exc
+ if hasattr(exc, "errors"): # pydantic ValidationError
+ detail = "validation failed for " + ", ".join(
+ ".".join(map(str, e.get("loc", ()))) for e in exc.errors(include_input=False))
+ logger.warning("Corrupt %s at %s -- ignoring: %s", label, path, detail)
return None
def _rebase_expires_in(self, data: dict) -> None: