EC2: support network allowlists and changing network policy between phases

Open
#4,293 2 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
aws, docker-compose, python
Domain
cloud

Research direction

Start in the EC2 environment's capabilities declaration and _EC2ComposeOps(DinDComposeOps), then compare with DockerEnvironment._requires_egress_control, docker-compose-egress-control.yaml and docker-compose-no-network.yaml, plus validate_network_policy_support. Reproduce by constructing a Trial with environment.type: ec2 on a task whose agent phase sets no-network over a public environment, without launching an instance. Done when that construction is accepted and the policy is enforced through the sidecar.

Written by the indexing model from the issue text.

Description

Summary

The EC2 environment can run a task fully online or fully offline, but it cannot restrict egress to an allowlist or change the network policy after the sandbox starts. Tasks that set up with public internet and then run the agent with no-network are rejected, so they cannot run on EC2 at all.

Checked on Harbor 0.25.0 and on main at b06002e (2026-11-13).

Current behaviour

  • EC2Environment.capabilities declares only disable_internet and docker_compose. It does not declare network_allowlist or dynamic_network_policy.

  • no-network is applied by adding docker-compose-no-network.yaml (network_mode: none) when the task container starts inside the VM. That cannot be changed afterwards and has no exceptions.

  • A task whose agent phase is more restricted than its environment baseline is rejected when the environment is constructed:

    ValueError: The execution phase network policy differs from a broader setup or
    shared phase policy, but this environment cannot change network policy after
    start. Execution mode: 'no-network'; broadest mode: 'public'.
    
  • For an installed agent, Harbor adds the inference host to a no-network agent phase, which makes it an allowlist policy. validate_network_policy_support rejects that on EC2 too.

Reproduction

Any task with a public environment and [agent] network_mode = "no-network". All 113 tasks in datacurve/deep-swe-1-1 are like this:

[agent]
network_mode = "no-network"

[verifier]
network_mode = "no-network"
environment_mode = "separate"

Trial.create with environment.type: ec2 raises the error above for these tasks, with both the oracle agent and an installed agent. The same task with environment.type: docker is accepted. I reproduced this without launching an instance.

Why it matters

Benchmarks built from public repositories cut network access during the agent and verifier phases so the agent cannot look up the upstream fix. On EC2 today there is no way to run them without editing the tasks, which changes the benchmark.

Possible approach

Happy to hear a different preference; this is only a sketch.

The EC2 environment already runs Docker Compose inside the VM (_EC2ComposeOps(DinDComposeOps)), so it could reuse the Docker environment's egress-control sidecar there, the way #4193 does for Daytona's Docker-in-Docker sandboxes and #3138 does for GKE:

  1. When any phase is restricted, add docker-compose-egress-control.yaml and the generated services override after the task's compose files, in the same order as on Docker.
  2. Implement _apply_network_policy by running network-policy in the sidecar through docker compose exec, and use the sidecar's deny-all for no-network instead of docker-compose-no-network.yaml.
  3. Advertise network_allowlist* and dynamic_network_policy under the same rule as DockerEnvironment._requires_egress_control. Public-only tasks keep today's behaviour, and the VM itself stays public.

One open question is how the sidecar image reaches the VM: built there during bootstrap, or pulled.

Workaround in use

Run these tasks on Modal or local Docker.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.