Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion archive/ktransformers/server/balance_serve/sched_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ def __init__(self, settings, main_args):
self.context = zmq.Context()
self.frontend = self.context.socket(zmq.ROUTER)
print(f"sched zmq rpc server on port {main_args.sched_port}")
self.frontend.bind(f"tcp://*:{main_args.sched_port}")
# Security: the scheduler RPC speaks pickle in both directions and has no
# authentication, so any peer that can reach this socket can achieve RCE
# via a crafted pickle payload. The protocol carries CUDA IPC tensor
# handles (mp.reductions.reduce_tensor) that are only valid on the same
# host, and SchedulerClient always connects to localhost, so this RPC is
# local-only by design. Bind to the loopback interface instead of all
# interfaces (tcp://*) so the pickle sink is never exposed to the network.
self.frontend.bind(f"tcp://127.0.0.1:{main_args.sched_port}")

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.

high

Binding the server to 127.0.0.1 restricts it to the IPv4 loopback interface. However, SchedulerClient (on line 169) connects to tcp://localhost:{sched_port}. On systems where localhost resolves to the IPv6 loopback address (::1) first, the client will fail to connect to the server. To ensure reliable local connectivity, please also update SchedulerClient to connect to 127.0.0.1 instead of localhost in this file. Additionally, please note that there is another identical scheduler RPC file at archive/kt-sft/ktransformers/server/balance_serve/sched_rpc.py which still binds to * and should be updated similarly to prevent the same security vulnerability.


# 创建内部的 DEALER 套接字,用于与工作线程通信
self.backend = self.context.socket(zmq.DEALER)
Expand Down