Skip to content

Isolate Docker runtime networking - #2469

Closed
xeophon wants to merge 1 commit into
mainfrom
fix/isolate-docker-networking
Closed

Isolate Docker runtime networking#2469
xeophon wants to merge 1 commit into
mainfrom
fix/isolate-docker-networking

Conversation

@xeophon

@xeophon xeophon commented Aug 29, 2026

Copy link
Copy Markdown
Member

Superseded by #2528.

Overview

Give each Docker runtime its own network namespace so task services cannot collide with listeners on the host. Closes #2319.

Details

  • Run containers directly on Docker's bridge network and publish the reserved runtime service port on host loopback.
  • Make mapped exposure part of Runtime.expose() so MCP URLs remain reachable without host networking.
  • Route only framework-owned HTTP loopback callbacks through a token-scoped relay, preserving callback redirects without rewriting response bodies or cookies.
  • Keep namespace isolation separate from restricted-egress enforcement and preserve published-port replies when restricted routing is active.
  • Merge image and process NO_PROXY exclusions into the runtime environment used for execution.

The callback relay intentionally supports framework-owned HTTP endpoints. It rewrites loopback Location headers to keep redirects reachable, but it does not rewrite application cookies or provide transparent TLS forwarding.


Note

High Risk
Changes core Docker networking, MCP reachability, and egress/callback security boundaries; misconfiguration or kernel differences in the iptables cut could break sandboxes or leak host access.

Overview
Docker runtimes no longer use host networking. Containers run on bridge, reserve SERVICE_PORT (8000), and publish it to a host-chosen 127.0.0.1 port so task listeners cannot collide with the host.

Exposure and MCP URLs are unified on Runtime.expose(): the base implementation now returns http://127.0.0.1:{port} instead of None; DockerRuntime returns the recorded mapped URL. reachable_url always goes through expose, opens a PrimeTunnel when a local runtime must be reached from a remote consumer, and fails clearly if exposure is missing. serve_in_runtime binds 0.0.0.0 only when the server is exposed and the runtime has a published_port.

Host-loopback callbacks from inside Docker go through EgressProxy.callback_url (tokenized /.vf-host/ paths) in unrestricted mode, with Origin / Location rewriting so HTTP redirects stay reachable; restricted mode still uses HOST_ALIAS and dynamic route registration. Policy egress treats all loopback targets as non-proxyable.

Restricted egress gets a reworked route flush + iptables cut (conntrack for replies, minimal default route). Unrestricted runtimes still start the proxy for callbacks only; exec/background env merges image and process NO_PROXY and applies the policy proxy only after the cut (or for detached restricted servers).

Reviewed by Cursor Bugbot for commit 3d72db2. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Isolate Docker runtime networking via bridge network and host-callback proxy

  • Docker runtime now uses bridge networking, publishes SERVICE_PORT (8000) to a random host loopback port, and always starts an EgressProxy — policy-enforced in restricted mode, callback-only in unrestricted mode.
  • EgressProxy gains tokenized host-callback routing so container-originated HTTP traffic can reach host-loopback services via stable proxy URLs, with correct header and redirect handling (egress.py).
  • MCP launch logic in launch.py only sets MCP_HOST when exposed=True and the runtime has a published_port; reachable_url now selects a direct, exposed, or tunneled URL based on colocation.
  • Restricted-mode network cut in prepare_execution is reworked to use explicit ip/iptables routing rules; container environment composition is centralized in _container_env.
  • Risk: Runtime.expose default now returns http://127.0.0.1:<port> instead of None; callers that previously handled None from expose() need to adapt. DockerRuntime.host_url now raises ValueError for non-HTTP or non-loopback URLs where it previously may have passed through.

Macroscope summarized 3d72db2.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T13:08:35.032994Z 3d72db2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4319376412

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a23d638a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py
@macroscopeapp

macroscopeapp Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes Docker network namespaces, host callback routing, service exposure, and restricted-egress enforcement, affecting both runtime behavior and security boundaries. An unresolved review comment also identifies a concrete localhost IPv6 compatibility regression that needs validation.

You can add or adjust custom eligibility rules. Learn more.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bde69926eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from bde6992 to 0307fbf Compare August 30, 2026 10:18
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0307fbf184

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/__init__.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 0307fbf to 15a7f8d Compare August 30, 2026 15:19
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15a7f8d046

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 15a7f8d to 591b638 Compare August 30, 2026 15:35
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 591b638000

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/egress.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 591b638 to 669944a Compare August 30, 2026 15:43
Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 669944aef1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch 2 times, most recently from ea1b4e9 to f2d3ebc Compare August 30, 2026 15:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2d3ebcea6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from f2d3ebc to 752a16f Compare August 30, 2026 16:04
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 752a16f2c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 752a16f to 944a671 Compare August 30, 2026 16:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 944a671cce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 944a671 to 4844f9f Compare August 30, 2026 16:19
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from af7126b to bee40a7 Compare September 1, 2026 11:09
Comment thread verifiers/v1/runtimes/docker/__init__.py Outdated
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/egress.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from bee40a7 to bd81959 Compare September 1, 2026 11:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd81959afc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment on lines +251 to +254
if host.lower() == HOST_ALIAS or (
callback is not None and host.lower().endswith("localhost")
):
dial_host = "127.0.0.1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve localhost callbacks without forcing IPv4

When an unrestricted Docker harness receives a callback such as http://localhost:<port> but the host service listens only on ::1, this branch replaces the hostname with 127.0.0.1, so the relay returns 502 even though the URL worked with the previous host-network path and explicit ::1 callbacks are supported. Resolve localhost normally and try its loopback addresses rather than unconditionally pinning these names to IPv4.

Useful? React with 👍 / 👎.

@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from bd81959 to 3693ce7 Compare September 1, 2026 11:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3693ce7b60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 3693ce7 to f914d34 Compare September 1, 2026 11:52
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from f914d34 to a2dddb7 Compare September 1, 2026 12:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2dddb7bfb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a2dddb7. Configure here.

Comment thread verifiers/v1/runtimes/docker/__init__.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from a2dddb7 to 9ef4e74 Compare September 1, 2026 12:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ef4e74b7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 9ef4e74 to 2a083c7 Compare September 1, 2026 12:32
Comment thread verifiers/v1/runtimes/docker/__init__.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a083c700a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 2a083c7 to 0db4210 Compare September 1, 2026 12:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0db4210bb1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/__init__.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from 0db4210 to c7ea548 Compare September 1, 2026 12:56
Comment thread verifiers/v1/runtimes/docker/egress.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7ea548714

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
@xeophon
xeophon force-pushed the fix/isolate-docker-networking branch from c7ea548 to 3d72db2 Compare September 1, 2026 13:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d72db2a21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/docker/egress.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DockerRuntime uses --network host for unrestricted tasks, silently corrupting grading when host ports collide

1 participant