Skip to content

The agent that grows with you

fix(profiles): keep OS credential stores and .envrc out of profile export

JerryLiu3699dfb2b27b30e
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 624a332c944..a8768e24591 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -179,6 +179,7 @@ PROFILE_CREDENTIAL_PATHS = frozenset({
"chrome-debug", # /browser connect Chrome profile (cookies, logins)
"home", # subprocess HOME: gh, git, ssh, npm and skill-CLI credentials
"backups", "state-snapshots", # pre-update zips, config copies, update snapshots of the stores
+ ".ssh", ".aws", ".gnupg", ".kube", ".envrc", # OS credential stores file_safety denies under a home
})
_CREDENTIAL_PATH_PARTS = tuple(tuple(p.casefold().split("/")) for p in PROFILE_CREDENTIAL_PATHS)
@@ -2240,7 +2241,8 @@ def _default_export_ignore(root_dir: Path):
# Credential names dropped at ANY depth of a named-profile export, on top of the root-relative
# PROFILE_CREDENTIAL_PATHS. ``bot-desktop`` is the screen's runtime state:
# its persistent Chromium profile (Cookies, Login Data — the bot's live web sessions), Xauthority, sockets.
-_EXPORT_CREDENTIAL_FILES = frozenset({"auth.json", ".env", "bot-desktop"})
+# The OS stores are dropped wherever they sit (a skill dir copied from a home carries its ``.ssh``).
+_EXPORT_CREDENTIAL_FILES = frozenset({"auth.json", ".env", "bot-desktop", ".ssh", ".aws", ".gnupg", ".kube", ".envrc"})
# Text/config suffixes secret-scrubbed on export; binary DBs, images etc. are left alone.
_EXPORT_REDACT_SUFFIXES = frozenset({
diff --git a/tests/hermes_cli/test_profile_export_credentials.py b/tests/hermes_cli/test_profile_export_credentials.py
index fd084bf420b..bf00b8ea01d 100644
--- a/tests/hermes_cli/test_profile_export_credentials.py
+++ b/tests/hermes_cli/test_profile_export_credentials.py
@@ -35,10 +35,12 @@ _EXTRA_STORES = {
DEFAULT_TEAMS_PIPELINE_STORE_FILENAME, "mem0.json",
"browser-profiles/live/Default/Cookies", "browser_profiles/default/Default/Login Data",
"mcp-tokens/srv.json", "vault/vault.key", "platforms/pairing/approved.json", "slack_tokens.json",
- "webhook_subscriptions.json",
+ "webhook_subscriptions.json", ".ssh/id_rsa", ".aws/credentials", ".gnupg/x", ".kube/config", ".envrc",
}
# Single-file stores whose name has no dot; every other dotless store is a token directory.
_DOTLESS_FILES = {"npmrc"}
+# Dot-named stores that are directories.
+_DOT_DIRS = {".ssh", ".aws", ".gnupg", ".kube"}
def _seed_stores(root):
@@ -50,7 +52,7 @@ def _seed_stores(root):
(root / "config.yaml").write_text("model: gpt-4\n")
(root / "platforms" / "keep.json").write_text("{}")
for rel in stores:
- is_dir = "." not in rel.rsplit("/", 1)[-1] and rel not in _DOTLESS_FILES
+ is_dir = rel in _DOT_DIRS or ("." not in rel.rsplit("/", 1)[-1] and rel not in _DOTLESS_FILES)
target = root / rel / "store" if is_dir else root / rel
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text("fake-credential")
@@ -106,6 +108,10 @@ class TestCredentialExclusion:
(profile_dir / "config.yaml.bak-my-note").write_text(f"model:\n api_key: {_LEAKED_KEY}\n")
(profile_dir / "GOOGLE_CHAT_USER_TOKENS").mkdir(exist_ok=True)
(profile_dir / "GOOGLE_CHAT_USER_TOKENS" / "upper.json").write_text("fake-credential")
+ nested = ["skills/s/.ssh/id_rsa", "skills/s/.aws/credentials", "skills/s/.envrc"]
+ for rel in nested:
+ (profile_dir / rel).parent.mkdir(parents=True, exist_ok=True)
+ (profile_dir / rel).write_text("fake-credential")
monkeypatch.setenv("HERMES_HOME", str(profile_dir))
copies = [
create_pre_update_backup(hermes_home=profile_dir),
@@ -124,7 +130,7 @@ class TestCredentialExclusion:
assert {"testprofile/config.yaml", "testprofile/platforms/keep.json"} <= set(members)
assert _LEAKED_KEY not in note
- rels = {*_EXTRA_STORES, *PROFILE_CREDENTIAL_PATHS, "google_chat_user_tokens/upper.json",
+ rels = {*_EXTRA_STORES, *PROFILE_CREDENTIAL_PATHS, "google_chat_user_tokens/upper.json", *nested,
*(c.relative_to(profile_dir).as_posix() for c in copies)}
folded = {n.casefold() for n in members}
leaked = sorted(r for r in rels if any(