fix(security): bind balance_serve scheduler ZMQ socket to loopback (#2087)#2091
Merged
Merged
Conversation
…vcache-ai#2087) The balance_serve scheduler binds its ROUTER socket with tcp://*, i.e. 0.0.0.0 (all interfaces), and calls pickle.loads() on every received message with no authentication. Any host that can reach the auto-assigned sched_port can send a crafted pickle whose __reduce__ runs a shell command, achieving unauthenticated remote code execution as the server process (GHSA-83vp-v6wg-x93x). The scheduler RPC is purely inter-process: SchedulerClient always connects to tcp://localhost:{sched_port}, and the server is launched as a local subprocess. Binding to tcp://127.0.0.1 is therefore functionally identical for the legitimate local client while removing the socket from every non-loopback interface, closing the network attack surface. Applied to both the main and kt-sft copies of sched_rpc.py.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Collaborator
|
Good security hardening. Binding the scheduler ZMQ socket to 127.0.0.1 prevents exposing the internal control channel on external interfaces while preserving same-host communication. |
yyj6666667
approved these changes
Jul 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2087 (GHSA-83vp-v6wg-x93x): unauthenticated pickle-deserialization RCE on the
balance_servescheduler.The scheduler binds its ZeroMQ ROUTER socket with
tcp://*(i.e.0.0.0.0, all interfaces) and callspickle.loads()on every received message with no authentication. Any host that can reach the auto-assignedsched_portcan send a crafted pickle whose__reduce__runs a shell command, achieving remote code execution as the server process.Fix
Bind the scheduler socket to loopback (
tcp://127.0.0.1) instead oftcp://*.This is safe because the scheduler RPC is purely inter-process on the same host:
SchedulerClient.__init__already connects totcp://localhost:{sched_port}(sched_rpc.py), andbalance_servebackend (subprocess.Popen([... sched_rpc.py ...])).So loopback binding is functionally identical for the legitimate local client, while removing the socket from every non-loopback interface and closing the network attack surface. This implements the primary remediation from the issue ("Bind the scheduler socket to loopback").
Scope
archive/ktransformers/server/balance_serve/sched_rpc.pyarchive/kt-sft/ktransformers/server/balance_serve/sched_rpc.pytcp://*→tcp://127.0.0.1).Left out of scope (larger change): the
pickle.loads()on the inter-process channel remains. With the socket now loopback-only the network RCE vector is closed, but replacing pickle with a schema-validated format (JSON/msgpack) or adding ZeroMQ CURVE auth is a broader design change best handled separately — happy to follow up if maintainers want it.🤖 Generated with Claude Code