- ProcessRegistry._log_delta_command (staticmethod alias of log_delta_command): its only
production use was the one internal call, which now calls log_delta_command.
- _load_hermes_env_vars in environments/ssh.py and docker.py: module rebinding kept only
for tests to patch; tests now patch load_hermes_env_vars on the same module.
- env_probe.get_environment_probe_line(force_refresh=...): documented as test-only; no
caller passes it (gateway/run.py, agent/system_prompt.py) and tests already reset via
_reset_cache_for_tests().
- managed_modal: touch_activity_if_due is imported at module top. The lazy import and the
try/except existed only for a test stub of tools.environments.base; touch_activity_if_due
already swallows callback errors itself. The stub now provides the name.
None of these names is in plugin_api.json or the frozen updater surface.
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/environments/vercel_sandbox.py: _exception_chain, _extract_status_code,
_RETRY_BACKOFF_STEP, _MIN_SANDBOX_TIMEOUT, _MIN_RUNNING_WAIT,
_RUNNING_WAIT_POLL_INTERVAL, _STOP_TIMEOUT, _STOP_POLL_INTERVAL,
_SNAPSHOT_STORE_NAME
- tools/environments/sandbox_scope.py: CredentialRef (docstring in
agent/terminal_env_provider.py and the terminal-environment-plugin guide no
longer name it)
- tools/environments/streams.py: supports_streams() (the provider attribute of
the same name stays)
- completion_reason "failed_start": its producer left in cd818a4d054; drop the
lookups in process_registry_notifications._REASON_STATUS (and its
"Failed to Start" branch), cli_process_dock._STATUS_BY_REASON,
ui-tui processRoster REASON_STATUS, and the field comments
- tools/terminal_hints.py: _EXIT_CODE_HINTS[137] (exit 137 always carries a
SIGKILL exit note, which gates annotate_failure off)
- ProcessRegistry._config_value: unread `fallback` parameter
tools/environments/base.py carried _load_json_store, a line-for-line copy of
utils.read_json_or_empty (same utf-8-sig read, same OSError/ValueError
fallback, same non-object check). base.py, modal.py and vercel_sandbox.py now
call the shared helper and the copy is gone.
Its direct test moves to tests/test_utils_read_json_or_empty.py, since no test
of the shared helper covered missing, malformed or non-object files. The modal
lock test now patches read_json_or_empty in base.py, where the store update
looks it up.
_usable_cwd judged a relative cwd against the Python process's cwd, so a valid
relative workdir was swapped for TMPDIR (with a cwd_fallback notice) and a typo'd
one ran there instead of being refused. Resolve it where bash's cd does.
Review fixes for the dead-cwd recovery:
- The fallback notice was parked on the shared environment until the command
finished, so a concurrent healthy command could take another command's
notice. `_usable_cwd()` now returns it with the resolved directory and
`execute()` keeps it local.
- A foreground command handed to the background dropped the notice; the
yielded response now carries it.
- An explicit `workdir` the model names is no longer swapped for its parent
(lucasfdale: a typo'd `workdir` with `rm -f ./*.txt` deleted files one level
up). It is refused with exit 126 and a message saying the command did not
run. Only a cwd the session inherited (its recorded cd state or the env's own
cwd) falls back.
A local session whose working directory was deleted (a command removed its
own cwd, a scratch dir got pruned, a mount went away) wedged: the wrapper's
`builtin cd -- <cwd> || exit 126` failed before the command ran, on every
call, until the gateway restarted, with a misleading "chmod +x" exit-126 hint.
_recover_cwd() only repaired self.cwd inside _run_bash(), after execute()
had already built the script, and it never saw the explicit cwd the terminal
tool passes from the session's recorded cd state. execute() now resolves the
effective cwd through _usable_cwd() before building the wrapper (Local swaps a
dead directory for _resolve_safe_cwd's nearest usable ancestor; sandboxes are
untouched), and reports the move as a one-shot `cwd_fallback` note in the tool
result, background spawns included, so the model knows relative paths now
resolve elsewhere. The session record heals from the next observed pwd.
The file_operations hunk from the previous commit is superseded by the
execute-level resolution and reverted.
LocalEnvironment._recover_cwd() ran inside _run_bash, one step too late.
execute() reads self.cwd to compute effective_cwd and embeds it in the
wrapper's 'builtin cd -- <cwd>', so the script still cd'd into the removed
directory and the command exited 126 without running - while the log
reported the cwd as repaired. The recovery now runs in _before_execute,
the pre-command hook base.execute() already calls before building the
script, so the spawn and the script agree on one usable directory.
ShellFileOperations._exec had the same defect independently: it read
env.cwd and passed it back as an explicit cwd=, which outranks the
recovery. It now lets the env resolve its own cwd unless the caller
passed one explicitly.
2.53.0.3 predates three Git for Windows security releases: 2.56.0.3
(eMudhra CA compromise, Git LFS CVE-2026-105803), 2.56.0.4 (bundled
brotli 1.2.1, CVE-2026-111497, reachable via libcurl's br encoding) and
2.56.1 (git CVE-2026-111760 recursive-clone RCE and five others).
2.56.1 was published 2026-11-10, past the release-age window; its first
build ships as PortableGit-2.56.1-*, which the salvaged fetch_url fix
resolves.
2.56 moved the x64 MSYS2 prefix from mingw64/ to ucrt64/, so the
trampoline self-heal git-core candidates, the non-login bash coreutils
PATH dirs and the desktop bundle-arch PortableGit exemption now also
cover ucrt64 (mingw64 kept for existing installs).
Fixes#148835
The config loader expands key_env: "${KEY_SLOT}" before the provider
reads it, so the key sits under KEY_SLOT's value while the deny set held
the literal. Expand template pointers on every call (the referenced
value can change without the file changing); plain names stay cached
on the file signature.
Refs #147329
A snapshot captured before the key_env declaration kept re-exporting the
key to every later command. Exclude the declared names like the plugin
session names, filtered to shell names: they are interpolated into the
wrapper as parameter names.
Refs #147329
Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
Follow-up to the salvaged commit, rebased over 95f2010b73 (which already
strips HERMES_CUSTOM_*/HERMES_PROVIDER_*_API_KEY as internal secrets):
- drop the HERMES_CUSTOM_ prefix rule; main covers it in a stricter tier
- reuse _config_declared_key_envs + _config_credential_env_refs (the walk
MCP stdio already trusts) instead of a second section-list reader, so
every *_key_env/*_token_env pointer and ${VAR} credential ref counts
- fold camelCase aliases (keyEnv/apiKeyEnv/apiKey) the readers accept
- read the raw file via read_raw_config_readonly, cache on its identity;
an unparsable file falls back to the newest good backup and keeps the
names already denied (never caches the fallback)
- compute the set once per env in _filter_secret_env/_scrub_credentials
Provider tier, so inherit_credentials children still drive the endpoint.
Fixes#147329
A custom endpoint's API key can live under a name no blocklist can know:
Hermes mints it per endpoint (custom_endpoint_key_env -> HERMES_CUSTOM_<SLUG>_API_KEY),
or the operator picks it in config.yaml via key_env / api_key_env under providers:,
model:, fallback_providers: and the legacy custom_providers:. Neither PROVIDER_REGISTRY
nor OPTIONAL_ENV_VARS sees either form, so _is_provider_env_blocklisted() returned False
and the key reached every terminal child and was written in plaintext into the persisted
session snapshot (hermes-snap-<id>.sh), while built-in keys such as COHERE_API_KEY stayed
out. Fixes#147329.
The minted shape is matched by prefix+suffix (both edges checked, so operator vars that
merely resemble it — HERMES_CUSTOM_BANNER, MY_CUSTOM_API_KEY — still pass). Declared names
are read from the bound profile's own config through read_raw_config_readonly, cached
per-home on the file signature like _home_adapter_secret_env, so an edit takes effect on
the next spawn; an unreadable config keeps the names this home already denied rather than
reopening the leak.
Both go in the provider tier, not _is_hermes_internal_secret: the internal tier strips even
under inherit_credentials=True and is excluded from the managed worker's launch-env restore,
so a child that drives the endpoint would lose its key. env_passthrough cannot re-allow
either form, matching GHSA-rhgp-j443-p4rf.
Subsumes e70d2e1 (PRATHAMESH75), which covers the minted shape only.
delegate_task children are aliased to the parent's environment (one shared
sandbox, #16177), and that environment owned ONE bash snapshot that every
command sources and re-dumps with `export -p`. A child's export/unset of
HOME, TMPDIR, XDG_*, GH_* therefore became the parent's and its siblings'
shell state, contradicting the "own terminal session" contract.
Each aliased task now reads and writes its own snapshot file next to the
environment's, seeded on first use from the nearest ancestor's (copy-on-spawn,
like the cwd record seed_workspace copies). The sandbox stays shared, so the
parent still sees the child's files; LocalEnvironment.cleanup removes the
per-task snapshots with the environment's own.
Regression test adapted from the one ar-labs-agent posted on the issue.
Fixes#84536
61 call sites counted directories up from their own __file__ to find the
install folder. They now call hermes_cli._startup_fast.project_root_str(),
so the layout move changes one line instead of 61.
Kept with a reason in the lint baseline: files that cannot import Hermes
code (bootstrap, update path, pm/) and the sys.path bootstraps left for
part 2b. The baseline drops from 89 to 28 root_from_file sites.
Six existing tests that patched a module __file__ now patch the owner.
The askpass form of sudo password delivery was selected only after a
separate capability probe command, and only the local, Docker and SSH
backends run that probe. Direct Modal, Managed Modal, Daytona and Vercel
kept the stdin form, where a password line left unused by a sudo that hit
a cached ticket (`sudo a && sudo b; cat`) is read by a later program in the
same command and can be printed.
The askpass prologue now makes the checks that only the probe made before,
as the first steps of its existing setup condition and before any read of
stdin:
- for each distinct sudo command word the counted invocations run, as
written in the command (`sudo`, `/usr/bin/sudo`, ...),
`SUDO_ASKPASS=/bin/false <word> -A -V` with stdin from /dev/null must
succeed. For `env ... sudo` the checked word is the sudo word itself,
which env looks up through PATH as the shell does;
- /bin/cat, /bin/rm and /bin/sleep must be executable;
- after the FIFOs exist, a harmless helper (`#!/bin/sh` + `exit 0`) is
written to the helper path, made mode 700 and run; only then is the
FIFO-reading helper written over it. A writable but noexec temp
directory therefore fails setup instead of failing authentication.
The real helper is written with `>|`, so a session with noclobber
(`set -C`) can still replace the harmless one.
When a step fails, the existing run-time fallback runs: the password
lines stay on stdin and every counted sudo keeps `-S -p ''`.
`sudo_command_words` collects the words from the same marked rewrite that
`has_own_stdin_or_askpass` inspects; `build_prologue` takes them as
`sudo_words` (default: bare `sudo`). When the words cannot be collected,
or one holds `$` or a backquote, `_transform_sudo_command` keeps the stdin
form and emits no prologue.
`sudo_askpass_supported_once` returns True without probing for a backend
that sets the new class attribute `_sudo_askpass_runtime_checked`; the four
SDK backends set it. Local, Docker and SSH keep running the probe as
before. Managed Modal's own `execute` now fills the prologue's timeout
token with `fill_timeout_token`, as `BaseEnvironment.execute` does.
Tests: tests/tools/test_sudo_askpass_sdk_backends.py drives each SDK
backend's real `execute` with the SDK or HTTP layer replaced by a local
bash runner and a stand-in sudo on PATH:
- `sudo true && sudo true; cat` with caller stdin `rest` prints only
`rest` (on the base commit it prints the password line);
- a stand-in sudo that rejects `-A` still authenticates through the stdin
form in the same single command, on every SDK backend and on
LocalEnvironment;
- a helper the shell cannot run (a chmod that leaves it mode 600, and
TMPDIR on a real noexec mount when the host has a writable one) and an
absolute-path sudo that rejects `-A` while PATH sudo accepts it both
fall back to the stdin form and succeed;
- each distinct sudo word gets its own check line; word lists that do not
match the counted sudos keep the stdin form.
Controls, passing on base and on this change: commands without sudo,
sudo with its own `-S`, no password, one probe run for Local, Docker and
SSH, and the helper/noexec/absolute-sudo cases above. The live tests in
test_sudo_askpass_delivery.py put the stand-in sudo first on PATH so the
check never reaches a host sudo, and test_managed_modal_sudo_stdin.py now
expects the askpass form with its timeout filled.
Two live tests there pin the noclobber case: a `bash -C` command and a
local backend whose BASH_ENV sets `set -C` keep the caller's input.
The one-time note built the backend name from the environment class, so a
plugin backend whose registered name differs from its class was named after
the class. backend_label now prefers the name _stamp_plugin_env records on
the environment (_hermes_backend_name) and keeps the class-derived name for
built-in backends.
Test: a plugin environment stamped through _stamp_plugin_env with a name
that differs from its class is named as registered (fails on the previous
commit with the class-derived name).
A sudo password (SUDO_PASSWORD, terminal.sudo_password or the interactive
prompt cache) is sent to whichever terminal backend runs the command. For
container, cloud sandbox, SSH and plugin backends, programs running in that
backend can read it there. Hermes sent it without saying so.
BaseEnvironment._prepare_command, which every backend goes through (managed
Modal included), now passes its result to
tools/environments/sudo_password_note.note_sudo_password_sent. The first time
a non-empty password is sent to a backend whose is_local is False, it logs one
WARNING per process per backend class, naming the backend (derived from the
class name, e.g. docker, ssh, vercel_sandbox) and advising a password that is
only valid there, or passwordless sudo in that environment's image. The
password itself is never logged. A lock guards the once-only state. Which
backends receive the password, the command text and the sudo stdin are all
unchanged.
The sudo docs in tools.md, cli-config.yaml.example and .env.example, and the
SUDO_PASSWORD row in the environment variable reference, now give the same
advice.
Tests (tests/tools/test_sudo_password_backend_note.py) go through real
execute / _prepare_command calls with a cached password: a non-local backend
logs exactly one warning across two commands, docker and ssh each log their
own, LocalEnvironment, a command without sudo, no password and an empty
password log none, and the message never contains the password. A control
test checks that the command text and stdin match the base output for
docker, ssh and local.
Resolves the docstring conflict in tools/environments/local_env_policy.py
additively: keeps main's HERMES_MODEL/DELEGATION/CUSTOM/PROVIDER key names and
this branch's HERMES_BRIDGED_* marker note.
The slug folded - . / : _ together, so https://my-host.com/v1 and
https://my.host.com/v1 (also a.com/x_y vs a.com/x/y, a.com:8443 vs
a.com/8443) shared HERMES_CUSTOM_MY_HOST_COM_API_KEY and the second
save sent its key to the first host. Endpoint-derived names now append
8 hex of sha256 over the normalized scheme/host/port/path; name-derived
names (providers.<name>, custom_providers rows) use HERMES_PROVIDER_ so
they never collide with host slugs. Existing configs keep the ${VAR}
they already reference; only new writes use the new names.
store_secret refuses to overwrite a variable another endpoint's block
reads with a different value. The dashboard main save reuses a known
endpoint row's key_env, and endpoint delete keeps a variable another
block still reads.
Refs #77471
`hermes config set model.api_key` (and auxiliary/delegation/custom provider
keys), the dashboard main and auxiliary pickers, `hermes model`'s aux flow and
new custom_providers rows wrote the plaintext secret into config.yaml. Each now
saves the value to the profile's .env under a deterministic name
(HERMES_MODEL_API_KEY, AUXILIARY_<TASK>_API_KEY, HERMES_DELEGATION_API_KEY,
HERMES_CUSTOM_<HOST[_PORT][_PATH]>_API_KEY) and writes the reference the field
already supports: ${VAR} where load_config expands it, key_env on
custom_providers rows. Resolution is unchanged; existing inline values keep
working and are not migrated. Remote Config keeps values as given, since its
document is shared across hosts that do not share .env.
The new HERMES_* key names are stripped from terminal/subprocess children
like AUXILIARY_*_API_KEY already is, so moving a key out of config.yaml does
not hand it to every child process.
The webhook half of the report does not reproduce: WEBHOOK_SECRET is folded
into the in-memory gateway config only; a test pins that config saves never
write it.
Fixes#77471
Co-authored-by: Franco <franco314@users.noreply.github.com>
Co-authored-by: Christopher <210261288+Christopher-Schulze@users.noreply.github.com>
The Tier-1 strip also reached served_profile_child_env(inherit_credentials=True), so a
key_cmd 'op read' helper and a gateway Hermes starts for its own home lost the bootstrap
token (process-env tokens even with a target). Restore it only when the child acts for the
launch home; routed homes, a bound served-profile scope and agent children keep the strip.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
The vault machine token a secret source reads to fetch every other secret
(BWS_ACCESS_TOKEN for Bitwarden Secrets Manager, OP_SERVICE_ACCOUNT_TOKEN
for 1Password) was on no scrub list, so terminal, background, cron-script,
browser, LSP and TTS children inherited it while the provider keys it
unlocks were stripped. Derive the names from the secret-source registry
(each source's token_env) and put them on both the provider blocklist and
the Tier-1 set, so every spawn path drops them, inherit_credentials
included. The sources still hand the token to their own CLI explicitly.
The dashboard starts its PTY child with HERMES_TUI_SIDECAR_URL and
HERMES_TUI_GATEWAY_URL, WebSocket URLs whose query string carries the
dashboard session token (loopback) or the process-lifetime internal
credential (gated). The TUI reads them once at start-up; the agent's own
children never need them. The scrub denylisted only the bare
HERMES_DASHBOARD_SESSION_TOKEN, so terminal("env") in a dashboard chat
printed a working /api/ws login. Both names are now on the provider
blocklist and the Tier-1 set, like the bare token.
Stripping only the HERMES_BRIDGED_* marker left the bridged value itself in
the agent's shell (DISCORD_ALLOWED_ROLES, DISCORD_ALLOW_BOTS, TELEGRAM_*).
A `hermes gateway restart` / `run --replace` from that shell started a
gateway that saw a marker-less value, treated it as operator-set and kept
the old, looser allowlist over the tightened config.yaml. A value that still
matches its marker's digest is the bridge's, so it goes too and the child
re-derives it from its own YAML; a value that does not match is the
operator's and stays. Applied in the shared scrub (_scrub_credentials,
_scrubbed_env) and strip_launch_profile_env; the own-profile restart
builder still carries matching markers when its base keeps them.
Fixes#144353
Greptile: importing the prefix and digest from tools.environments.local_env_policy made every
adapter import run the subprocess-policy builders. The shared leaf is stdlib only and is loaded
at the commit point (POST_MOVE_MODULES) with the other post-update modules.
The bridge-marker carry in served_profile_child_env late-imported gateway.platforms._shared, which
pulls the adapter stack from the moved checkout on the Windows restart path. The marker prefix and
digest now live in the leaf tools.environments.local_env_policy.
Review finding (blocking): each HERMES_BRIDGED_* marker stored the plain bridged
value and the HERMES_ prefix passed the subprocess scrub, so a credential-bearing
telegram.proxy_url and the allowlists the scrub strips reached the agent's terminal.
The marker now stores sha256 of the value; _is_hermes_internal_secret drops the
markers from every child env, strip_launch_profile_env drops them for routed homes,
and served_profile_child_env re-adds them only on the launch profile's own restart
child for values it still carries.
Review should-fix: the bridge now skips any load for another home (HERMES_HOME
override or a secret scope stamped with another home), not only a multiplexed
secondary's scope, so such a load cannot refresh or retract the launch profile's
allowlist.
The sudo rewrite appended the stdin option to every command-position sudo and
prepended one password line per counted sudo to the stdin shared by the whole
command string. An earlier command that reads stdin took a password line, and a
line left unused because sudo reused its ticket was read by a later command.
Where the backend's sudo supports an askpass helper, the command now starts with
a prologue that reads exactly one password line from stdin into a shell
variable, keeps it in a detached writer that serves it through a FIFO once per
counted sudo, and tears down (writer, FIFOs, helper, temp dir) when the
command's shell exits or after the command timeout plus 30 seconds. Each counted
sudo becomes `SUDO_ASKPASS="$__hermes_sudo_dir/a" sudo -A ...`, so the rest of
stdin reaches the command untouched and the password never appears in the
command text. The prologue uses \command / \builtin so snapshot aliases and
functions cannot shadow its commands, and treats a temp path holding a
double-quote-special character as a setup failure.
The form is chosen per environment by a cached capability probe (sudo accepts
-A with -V, and a 0700 helper in a mktemp -d under ${TMPDIR:-/tmp} runs next to
a FIFO the shell can open read+write). It runs only once a password is
available, only on backends that already allow in-backend sudo probes, and
never for the local backend on Windows. Commands where a counted sudo carries
its own stdin or askpass option keep the stdin form. Without askpass support,
the command text and stdin are byte-for-byte unchanged. BaseEnvironment.execute
fills the prologue's timeout placeholder with the effective timeout + 30.
New module tools/terminal_tool_sudo_askpass.py holds the prologue builder, the
option guard, the probe and the timeout fill; base.py keeps its line count.
Tests: tests/tools/test_sudo_askpass_delivery.py covers the askpass form for 1
and 3 sudo invocations, the one-line stdin, the timeout fill, every fallback
(byte-for-byte stdin form), probe caching, no password, NOPASSWD, an empty
configured password, the option-guard table, wrong-password text from both
forms, and live runs through the real LocalEnvironment and a real bash with a
fake sudo: an earlier stdin reader, a leftover line after ticket reuse, xtrace,
cleanup of temp dirs and processes, background sudo with wait, the session
snapshot, alias/function shadowing, odd temp paths and the live probe.
When Bot Desktop runs inside the terminal backend, the launcher writes an
env file there with six keys (DISPLAY, XAUTHORITY, DBUS_SESSION_BUS_ADDRESS,
XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME). sandbox_host._published()
read every KEY=VALUE line of that file back with no check, and
runtime.desktop_env() plus the local terminal run-env overlay merged the
result into the environment of processes started on the agent machine,
where those sandbox-side values name no real display or directory.
Now:
- sandbox_host keeps only the keys listed in PUBLISHED_KEYS (the set the
launcher's printf line writes). Each value must be non-empty and
printable, and DISPLAY must be a plain X display (":N" or ":N.M").
Other lines are dropped and their key name (never the value) is logged
once per process. Without a valid DISPLAY the screen counts as not
published.
- runtime.host_published_env() returns the published values that are
valid for a process on this machine: the gateway-hosted screen's, or an
empty dict while the sandbox marker routes the screen to the backend.
desktop_env() and the local run-env overlay use it. desktop_env() still
stamps activity while a sandbox-hosted screen is running.
- runtime.published_env() still returns the (filtered) sandbox values for
the consumers that run inside the backend (sandbox browser, sandbox
cua-driver, status, thumbnail, prompt note).
- Gateway-hosted screens behave as before.
Tests: tests/tools/test_bot_desktop_published_env.py drives the real entry
points with a faked streams.run_in transport: key filtering, DISPLAY and
value validation, log-once by name, launcher key-set drift, no backend
values in desktop_env / build_browser_env / cua_driver_child_env /
_make_run_env, plus controls for the gateway-hosted merge and for the
values handed into the backend.
ManagedModalEnvironment.execute placed sudo password lines in the command
string as a `printf ... |` prefix, so the command the backend received was
not the prepared command and the caller's own stdin was replaced by that
pipe for the first command in the string.
It now merges the lines in front of the caller's stdin on the request's
stdinData field, the same merge BaseEnvironment.execute does, and sends the
prepared command unchanged. Which backends receive a configured password
is not changed.
Docs (.env.example, tools.md Sudo Support) say that the password is sent
to the backend that runs the command, so it should be that backend's
sudo password.
Tests: tests/tools/test_managed_modal_sudo_stdin.py drives the real
execute() over a fake HTTP transport for a prompted password, a configured
password with two sudo invocations, and a command without sudo. The first
two fail on the base commit; the third passes on both.
ProcessRegistry._spawn_env (terminal background=True, PTY) built its env from
the gateway's os.environ with neither the launch-profile .env strip nor the
routed scope overlay, so a served profile's background commands still saw the
starting session's values. Share _make_run_env's base via routed_terminal_base.
Refs #142798
A host gateway keeps the process environment of the session that started it.
Under multiplex a served profile's terminal commands were built from that
environment only (after stripping launch leftovers): names declared in the
routed profile's own .env reached commands only when the launch process
happened to define them too, or they were declared passthrough, and on a name
clash the launch leftover won.
_make_run_env now matches build_subprocess_env(strip_launch_profile=True)
when multiplex is active: overlay the bound secret scope (first-party context
credentials excluded, they are never scope-resolved), then replay the
administrator-managed keys; the backend's own env still wins last.
Single-profile (multiplex off) behaviour is unchanged.
Repro: #142798 (MARKER probe: a served profile's command got the starter's value)
POSIX lstat('symlink/') and lstat('symlink/.') follow the link; an
attacker-mutable link may pass the new directory owner/mode check.
Parse the candidate with Path before lstat to strip trailing components
without collapsing inner '..' traversal. Cover both spellings with a
real ControlPath-length-budget regression.
Follow-up to c2h5oh's PR #154498 and Zentaur-hub's report #80284.
The SSH backend put its control socket under $XDG_RUNTIME_DIR whenever the variable named an
existing directory. An inherited or mis-set value (sudo -E, a shared /run path) can name a
group/world-accessible dir where another user pre-creates the hermes-ssh leaf; it outranked the
ownership-checked shared-tmp candidates. Apply the gateway control socket's test: a real dir we
own with no group/other bits, else fall through to the per-uid candidates.
Follow-up to #154127 (review nit). Refs #80284
A server's own env: entry named like a pointer (api_key_env: VENDOR_TOKEN)
is a literal for that server, not a Hermes credential; the sibling
${VAR} ref walk already skips the block.
Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com>
model.api is read as the main model's key, and the managed-scope config.yaml is expanded and
merged over the profile's, so a vault-supplied name referenced from either is a Hermes
credential. Only model.api counts: elsewhere 'api' is a base-URL alias.
Refs #126310
A credential field written as a whole-value ${VAR} / ${env:VAR} ref
(delegation.api_key: ${DELEGATION_KEY}) names a Hermes credential, but
load_config_readonly() has already expanded it, so read the raw config
for those names. mcp_servers.*.env refs stay forwarded by design.
Fixes#126310
A key_env / api_key_env on model, custom_providers, providers, auxiliary or
fallback entries makes that env name a Hermes provider credential, so a
secret-source copy of it must be withheld like the registry names. Walk the
active profile's loaded config for the field rather than listing sections, so
a new reader using the same convention is covered.
Fixes#126310
hermes_consumed_credentials matched the static blocklist only, so a secret
declared by the profile's user-installed platform plugin (or a registered
adapter's required_env) still reached every stdio MCP server when it came
from a secret source. Use _is_provider_env_blocklisted with the per-home
registered set, the predicate every other child scrub applies.
Moves the secret-source _build_safe_env tests into their own file to keep
test_mcp_tool.py under its size ratchet.
Fixes#126310
The source guard matched canonical blocklist names only, so a vault-backed credential still reached every stdio MCP server under the other names Hermes consumes it by: numbered rotation keys (DEEPSEEK_API_KEY_2), a variable a credential-pool row points at (source: env:VAR), the <NAME>_<PROFILE> source name hydration also applies as <NAME>, and adapter tokens outside the blocklist (WEIXIN_TOKEN).
hermes_consumed_credentials derives the set from the consumers, per call and for the active profile: the blocklist and internal secrets, profile_channels.credential_env_keys, numbered siblings, the profile's persisted env: pool rows and the profile alias target. Third-party source names and a server's own env: are unchanged; a name only another profile consumes is still forwarded to the profile that does not.
Docs: security.md MCP credential section (EN + zh-Hans).
With api_key=None the Daytona SDK falls back to DAYTONA_API_KEY from
os.environ and the cwd .env, so a served profile without its own key ran
as the launch profile's Daytona account. Refuse construction instead when
serving a routed profile; single-profile hosts keep the SDK's env fallback.
The credential tests now bind a real served profile home with
bind_profile_scope against a conflicting launch key, and cover the
missing-key refusal and the unchanged single-profile path.
DaytonaEnvironment built Daytona() with no config, so the SDK read DAYTONA_API_KEY from os.environ. Under a multiplexed gateway os.environ holds the launch profile's secrets, so a key saved in a served profile's .env never reached the SDK. Every command failed with "Authentication credentials not found" while the backend check (get_secret) reported the key as configured. Resolve the key through get_secret and pass it in DaytonaConfig. A None key keeps the SDK's own env fallback.
A weakref.finalize callback runs before __del__ in cyclic GC (a synced
env is always in a cycle via FileSyncManager's bound methods) and at
interpreter exit (LIFO atexit), so the final cleanup()'s sync_back and
-O exit went through a deleted ControlPath. Remove the dir in __del__
after super().__del__() instead.
Co-authored-by: BearHuddleston <BearHuddleston@users.noreply.github.com>