Skip to content

The agent that grows with you

fix: log a warning when parent-dir hardening is skipped for the install tree

Ben Barclay8b48f621c5dd
diff --git a/hermes_constants.py b/hermes_constants.py
index e26075ba345..6c45ba58257 100644
--- a/hermes_constants.py
+++ b/hermes_constants.py
@@ -1032,6 +1032,19 @@ def secure_parent_dir(path: Path) -> None:
# traversal in Docker (UID 10000) and any other install where the
# runtime user doesn't own the install dir. See #25821, #93050.
if parent == _INSTALL_ROOT or _INSTALL_ROOT in parent.parents:
+ # A credential file inside the install tree usually means HERMES_HOME
+ # resolved somewhere unexpected — surface it instead of skipping
+ # silently, since this same misconfiguration previously caused
+ # production lockouts.
+ import logging
+
+ logging.getLogger(__name__).warning(
+ "Not restricting permissions on %s: it is inside the "
+ "hermes-agent install directory (%s). Credential files are "
+ "normally stored under the hermes home directory instead.",
+ parent,
+ _INSTALL_ROOT,
+ )
return
try:
os.chmod(parent, 0o700)