Skip to content

feat(docker): terminal network toggle with full-path coverage and reuse guard - #59149

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-9390f55d
Jul 5, 2026
Merged

feat(docker): terminal network toggle with full-path coverage and reuse guard#59149
teknium1 merged 2 commits into
mainfrom
hermes/hermes-9390f55d

Conversation

@teknium1

@teknium1 teknium1 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

terminal.docker_network: false now air-gaps the Docker sandbox (--network=none) across every environment-creation path, and container reuse can no longer silently hand back a networked container under lockdown.

Salvages #46358 (the toggle itself) and widens it per review: the original only threaded the toggle through terminal_tool.py, so the file_tools / code_execution container paths fell back to bridge networking — the same exec/probe asymmetry class @ignasivegas reported on the issue. Label-only cross-process reuse also ignored the toggle entirely.

Changes

  • Cherry-picked toggle commit: hermes_cli/config.py (terminal.docker_network, default true), env bridge in cli.py / gateway/run.py, wiring in tools/terminal_tool.py, 4 tests
  • tools/file_tools.py, tools/code_execution_tool.py: carry docker_network in their container_config dicts
  • tools/environments/docker.py: reuse path inspects HostConfig.NetworkMode when lockdown is requested; mismatched (networked) containers are removed and replaced with a fresh --network=none container, warning logged. Fails closed on inspect failure. Default-network config never churns containers (docker_extra_args --network=none users unaffected)
  • tests/tools/test_docker_network_config.py: +4 tests — AST invariant (every container_config site with docker_run_as_host_user must carry docker_network) and three reuse-guard behaviors
  • website/docs/user-guide/configuration.md: docker_network key + env-var table row

Validation

Check Result
scripts/run_tests.sh tests/tools/test_docker_network_config.py 8 passed
scripts/run_tests.sh (docker_network + env_sync + docker_environment) all passed
E2E, real Docker: network=FalseNetworkMode=none, egress NET_BLOCKED (Errno 101), local exec OK pass
E2E: bridge container exists → flip to docker_network: false → old container removed, fresh none container, egress blocked pass
ruff on all touched files clean

Source

Infographic

Docker terminal network toggle

teknium1 added 2 commits July 5, 2026 14:07
Port from nanocoai/nanoclaw#2713: expose Hermes' existing Docker network isolation primitive through terminal config so operators can opt out of container egress.
…tainer reuse

Follow-up to the salvaged toggle commit:

- file_tools.py / code_execution_tool.py: carry docker_network in their
  container_config dicts so those environment-creation paths honor the
  lockdown instead of silently defaulting back to bridge (the probe/exec
  asymmetry class reported on #46358).
- docker.py: cross-process reuse now inspects HostConfig.NetworkMode when
  docker_network=false and removes a mismatched (networked) container
  before starting a fresh air-gapped one. Fails closed when inspect fails.
  Default-network config never churns containers, so operators using
  docker_extra_args --network=none are unaffected.
- tests: AST invariant that every container_config site carrying
  docker_run_as_host_user also carries docker_network, plus three reuse
  guard tests (reject bridge under lockdown / keep matching none /
  no inspect when network enabled).
- docs: configuration.md gains terminal.docker_network + env var row.
@alt-glitch alt-glitch added type/feature New feature or request backend/docker Docker container execution area/docker Docker image, Compose, packaging comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades P3 Low — cosmetic, nice to have labels Jul 5, 2026
@teknium1
teknium1 merged commit 3167dba into main Jul 5, 2026
31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-9390f55d branch July 5, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging backend/docker Docker container execution comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants