Skip to content

fix: Restrict server listening to loopback for security; update CPU and TPU server configurations - #117

Merged
shangkunwang01 merged 1 commit into
mainfrom
shangkun-fix-server-address
Oct 13, 2026
Merged

shangkunwang01 merged 1 commit into
mainfrom
shangkun-fix-server-address

Conversation

@shangkunwang01

Copy link
Copy Markdown
Collaborator

Bind CPU/TPU execution servers to loopback

Fixes an unauthenticated remote code execution vulnerability. cpu_server.py and tpu_server.py run submitted Python code with no authentication, and they listened on 0.0.0.0. Anyone who could reach ports 5463/5464 could run arbitrary code on the host.

Changes

  • cpu_server.py, tpu_server.py: bind 127.0.0.1 instead of 0.0.0.0.
  • eval_server.py: connect to backends on this machine through 127.0.0.1, even when eval_config.yaml lists the VM's network IP (which prepare_maxkernel.sh generates).
  • server_config.py: skip CPU backends with a tpu_vm block when deciding which local servers to start, matching the existing TPU logic.

@shangkunwang01
shangkunwang01 requested a review from NinaCai October 9, 2026 23:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request restricts CPU and TPU servers to listen on loopback (127.0.0.1) instead of 0.0.0.0, and updates the evaluation server to resolve local IPs to 127.0.0.1. It also updates get_local_cpu_port to exclude TPU VMs. A review comment suggests caching the result of get_local_ip() in eval_server.py to avoid inefficient, blocking network calls inside a loop.

Comment on lines +177 to +181
ip = backend_config["ip"]
# CPU/TPU servers only listen on loopback, so reach local ones via
# 127.0.0.1 even when the config lists this machine's network IP.
if ip in ["localhost", get_local_ip()]:
ip = "127.0.0.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Calling get_local_ip() inside a loop can be highly inefficient and slow down server startup, as get_local_ip() performs a blocking network socket connection to 8.8.8.8. We should cache the resolved local IP address on the Evaluator instance so that it is only fetched once.

        ip = backend_config["ip"]
        # CPU/TPU servers only listen on loopback, so reach local ones via
        # 127.0.0.1 even when the config lists this machine's network IP.
        local_ip = getattr(self, "_local_ip", None) or get_local_ip()
        self._local_ip = local_ip
        if ip in ["localhost", local_ip]:
          ip = "127.0.0.1"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The _load_backends only execute once and adds little overhead.

@shangkunwang01
shangkunwang01 merged commit 566f503 into main Oct 13, 2026
8 checks passed
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.

2 participants