image and video lanes: the scheduler's channel stays on 127.0.0.1 whatever --host

The diffusion runtime's scheduler takes its requests on a ZMQ ROUTER that unpickles what
it is sent, and upstream derives that socket's address from the HTTP --host: a lane bound
to an address other machines reach took requests on that channel from them too, with no
key (D01 of the 2026-10-24 security review). image-sglang/scheduler-loopback.patch keeps it
on 127.0.0.1 for both lanes; here the HTTP server and the scheduler run on one machine.
Upstream's main pins only 0.0.0.0 and IPv6 to loopback.

0.0.0.0 stays possible for the image lane (Hasan, 2026-10-24): the proxy relays no image
route, so a client elsewhere reaches the lane by its bind; the warning now says what
0.0.0.0 costs and that the channel stays on loopback. Proved on the pinned file of the
box (e00930c5): before the patch the endpoint followed --host (0.0.0.0, a LAN and a tailnet
address, ::, a hostname), after it is tcp://127.0.0.1 for each, replicas included. The new
tests fail on the old tree (7 in test_image_lane.py, 4 in test_video_lane.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-10-24 10:42:29 +02:00
1 parent a9fd5e4c3d
commit 5f51fad3c8
8 files changed
+136 -15

No files matched your search

+11
View File
@@ -104,6 +104,17 @@ counted by the engine on the proxy's own key before the engine refused it. Paths
under `/health`, `/ready` and `/metrics` stay open, as the engine keeps them (`/ready`
since v1.26.1).
**The image and video lanes take no key, and their scheduler's channel stays on
loopback** (since v1.40.1). Their HTTP API binds where `IMAGE_BIND` and `VIDEO_BIND` say,
loopback by default, and the installer says what another address costs: anyone who reaches
it generates on the GPU. Behind it, the diffusion runtime's scheduler takes its requests on a
ZMQ socket that unpickles what it is sent, and upstream derives that socket's address from
the same `--host`: until v1.40.1 a lane bound off loopback took requests on that channel from
the network too, which let anyone who reached it run code as the lane's user (found in a
security review, 2026-10-24). `image-sglang/scheduler-loopback.patch` keeps it on 127.0.0.1
whatever `--host` is. An image or video lane that serves during an update keeps the code it
started with until it restarts.
**The cockpit (`dashboard/`, :30090)** runs as the user who installed the box,
and that user is already root-equivalent: `install.sh` requires it to be in the
`docker` group, and a member of that group can start a container with the host's
+11
View File
@@ -186,6 +186,17 @@ authenticated door in front of it. That bind does not follow `ENGINE_BIND`, whic
to the lane that does have a key; `IMAGE_BIND=<addr>` overrides it, and the installer says
out loud what that costs.
Behind the HTTP API, the diffusion runtime's scheduler takes its requests on a ZMQ socket
that unpickles what it is sent, and upstream derives that socket's address from the same
`--host`. Until v1.40.1, a lane bound to an address other machines reach took requests on
that channel from them too, with no key, which let them run code as the lane's user
(found in a security review, 2026-10-24). `image-sglang/scheduler-loopback.patch` keeps it
on 127.0.0.1 whatever `--host` is, for this lane and the video lane: here the HTTP server and
the scheduler always run on the same machine. Upstream's `main` pins only `0.0.0.0` and IPv6
to loopback and keeps an explicit address. A side effect, the same path every lane on
loopback already took: with a local channel, the scheduler hands large outputs over through
a temporary file instead of in the message.
## The Turbo checkpoint
[`Qwen/Qwen-Image-2.1-Turbo`](https://huggingface.co/Qwen/Qwen-Image-2.1-Turbo), published by
+4 -3
View File
@@ -76,9 +76,10 @@ not dubbed afterwards, so the two stay in sync.
This lane serves the cookbook's MiniMax-H3 recipe as upstream wrote it at the pinned
commit, the v0.5.21 release's as the image lane's (main's `ddebc52` until v1.25), with
**one local source patch**: the image lane's idle-loop wait
(`image-sglang/scheduler-idle-poll.patch`, one file for both lanes: the loop it patches is
the same at both lanes' pinned commits, which CI checks against the real files). The diffusion scheduler's loop never waits, so a lane with nothing to do
**two local source patches**, the image lane's files (one copy for both lanes, checked by CI
against the real files at both lanes' pinned commits): `scheduler-loopback.patch`, since
v1.40.1, keeps the scheduler's own channel on 127.0.0.1 whatever `--host` is (why: the image
lane's page, docs/image-lane.md), and the idle-loop wait, `scheduler-idle-poll.patch`. The diffusion scheduler's loop never waits, so a lane with nothing to do
held one CPU core at 100%, which kept the box's hottest zone near 61 °C at rest (43 °C
with no lane loaded) and its fans loud. Measured on the reference box (2026-10-06), 3 min
after the lane was ready: 1.05 cores without the patch, 0.05 with it, the hottest zone 67
+17
View File
@@ -0,0 +1,17 @@
diff --git a/python/sglang/multimodal_gen/runtime/server_args/server_args.py b/python/sglang/multimodal_gen/runtime/server_args/server_args.py
index 75b683f..44b7192 100644
--- a/python/sglang/multimodal_gen/runtime/server_args/server_args.py
+++ b/python/sglang/multimodal_gen/runtime/server_args/server_args.py
@@ -3112,9 +3112,9 @@
def scheduler_endpoint_for(self, replica: int) -> str:
"""Ingress endpoint of one DP replica's driver rank."""
- scheduler_host = self.host
- if scheduler_host is None or scheduler_host == "localhost":
- scheduler_host = "127.0.0.1"
+ # dgx-spark-qwen38: the scheduler's ROUTER unpickles what it is sent, so it stays
+ # on loopback whatever --host the HTTP API is given (these lanes run on one machine).
+ scheduler_host = "127.0.0.1"
if self.scheduler_ports is not None:
port = self.scheduler_ports[replica]
else:
+12 -1
View File
@@ -126,6 +126,10 @@ case "$IMAGE_BIND" in
127.0.0.1|localhost) ;;
*) echo "WARNING: binding $IMAGE_BIND. This lane has no API key (the diffusion runtime has"
echo " no --api-key), so anyone who can reach that address can generate on your GPU."
if [ "$IMAGE_BIND" = 0.0.0.0 ]; then
echo " 0.0.0.0 is every interface: the LAN, the tailnet and any added later."
fi
echo " The scheduler's own channel stays on 127.0.0.1 whatever this bind (scheduler-loopback)."
echo " Loopback plus the cockpit is the intended shape." ;;
esac
case "$IMAGE_BIND" in
@@ -342,16 +346,23 @@ fi
# and a generation holds one for as long as it runs. A Stop during a 2048x2048 request
# sat 60 s in "stopping" until systemd killed the lane and marked the unit failed
# (2026-09-23). Now 5 s, then the requests in flight are cancelled and it stops clean.
# scheduler-loopback: the scheduler takes its requests on a ZMQ socket that unpickles what it
# is sent, and upstream derives that socket's address from --host: a lane bound to an
# address other machines reach took requests on that channel from them too, with no key
# (found in a security review, 2026-10-24). It stays on 127.0.0.1 now, whatever --host is:
# here the HTTP server and the scheduler always run on the same machine. Upstream's main
# pins only 0.0.0.0 and IPv6 to loopback and keeps an explicit address.
# The other three are sgl-project/sglang#43391, merged upstream on 2026-10-10 and in SGLang
# v0.5.22 (2026-10-16), the release after this pin, one file each: the Turbo checkpoint's eight-step sigma grid, which its
# model_index.json carries, reaches the sampler. Without them the Turbo weights load and
# sample on a uniform schedule from num_inference_steps, which is not how it was trained;
# with them the base checkpoint, which has no grid, samples exactly as before.
# One line: CI reads this list with a one-line pattern.
PATCHES=(scheduler-idle-poll http-graceful-timeout qwen-image21-turbo-sigma-config qwen-image21-turbo-sigma-pipeline qwen-image21-turbo-sigma-stage)
PATCHES=(scheduler-idle-poll http-graceful-timeout scheduler-loopback qwen-image21-turbo-sigma-config qwen-image21-turbo-sigma-pipeline qwen-image21-turbo-sigma-stage)
declare -A PATCH_FIXES=(
[scheduler-idle-poll]="an idle lane no longer holds a CPU core"
[http-graceful-timeout]="a stop during a generation takes 5 s instead of timing out"
[scheduler-loopback]="the scheduler's channel stays on 127.0.0.1 whatever --host"
[qwen-image21-turbo-sigma-config]="the Turbo's sigma grid has a place in the pipeline config"
[qwen-image21-turbo-sigma-pipeline]="the Turbo's sigma grid is read from its model_index.json"
[qwen-image21-turbo-sigma-stage]="a Turbo request samples on that grid, eight steps"
+8 -4
View File
@@ -134,6 +134,7 @@ case "$VIDEO_BIND" in
0.0.0.0) die "VIDEO_BIND=0.0.0.0 puts a keyless video generator on EVERY interface (LAN, tailnet, future NICs). This lane has no --api-key; bind loopback (the cockpit is the door) or name one specific address." ;;
*) echo "WARNING: binding $VIDEO_BIND. This lane has no API key (the diffusion runtime has"
echo " no --api-key), so anyone who can reach that address can generate on your GPU."
echo " The scheduler's own channel stays on 127.0.0.1 whatever this bind (scheduler-loopback)."
echo " Loopback plus the cockpit is the intended shape." ;;
esac
case "$VIDEO_BIND" in
@@ -325,9 +326,11 @@ fi
if [ ! -d "$SRC/.git" ]; then
git clone --quiet https://github.com/sgl-project/sglang "$SRC" || die "could not clone SGLang."
fi
# One local change to the pinned source, the image lane's scheduler-idle-poll (one file
# in image-sglang/ for both lanes, which applies to the pin of each). The diffusion
# scheduler's loop never waits: recv_reqs() polls its socket without blocking and nothing
# Two local changes to the pinned source, the image lane's scheduler-idle-poll and
# scheduler-loopback (one file each in image-sglang/ for both lanes, which applies to the
# pin of each). scheduler-loopback keeps the scheduler's own channel, a socket that
# unpickles what it is sent, on 127.0.0.1 whatever --host is (install-image.sh says why,
# 2026-10-24). For scheduler-idle-poll: the diffusion scheduler's loop never waits: recv_reqs() polls its socket without blocking and nothing
# else in the loop sleeps, so a lane with nothing to do held one CPU core at 100%, kept
# the box's hottest zone near 61 C at rest (43 C with no lane loaded) and its fans
# loud. The patch waits on the request socket for up to a second, as the LLM scheduler's
@@ -339,9 +342,10 @@ fi
# template (a stop cancels the generation in flight, measured under a second on all
# seven logged stops, with TimeoutStopSec as a ceiling, not a wait) and in
# docs/video-lane.md.
PATCHES=(scheduler-idle-poll)
PATCHES=(scheduler-idle-poll scheduler-loopback)
declare -A PATCH_FIXES=(
[scheduler-idle-poll]="an idle lane no longer holds a CPU core"
[scheduler-loopback]="the scheduler's channel stays on 127.0.0.1 whatever --host"
)
CURRENT="$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)"
if [ "$CURRENT" != "$PIN" ]; then
+50 -1
View File
@@ -314,6 +314,8 @@ PATCH = REPO / "image-sglang" / "scheduler-idle-poll.patch"
PATCHED = "python/sglang/multimodal_gen/runtime/managers/scheduler.py"
HTTP_PATCH = REPO / "image-sglang" / "http-graceful-timeout.patch"
HTTP_PATCHED = "python/sglang/multimodal_gen/runtime/launch_server.py"
LOOPBACK_PATCH = REPO / "image-sglang" / "scheduler-loopback.patch"
LOOPBACK_PATCHED = "python/sglang/multimodal_gen/runtime/server_args/server_args.py"
# Each hunk's context as it stands at the pin, three lines either side of the insertion.
CONTEXT_AT_PIN = (
" self._poller.poll(timeout=remaining_ms)\n"
@@ -435,6 +437,50 @@ class TheLocalPatches(unittest.TestCase):
def test_the_http_patch_only_bounds_the_graceful_shutdown(self):
self.assertEqual(added_code(HTTP_PATCH), ["timeout_graceful_shutdown=5,"])
def test_the_loopback_patch_takes_the_scheduler_off_the_http_host(self):
"""The scheduler takes its requests on a ZMQ ROUTER that unpickles what it is sent, and
upstream derived its address from --host: a lane bound off loopback took requests on it
from the network, with no key (D01 of the 2026-10-24 security review). The patch takes
out exactly upstream's three lines and puts loopback in their place."""
diff = LOOPBACK_PATCH.read_text()
self.assertEqual(re.findall(r"^\+\+\+ b/(.+)$", diff, re.M), [LOOPBACK_PATCHED])
self.assertIn(" def scheduler_endpoint_for(self, replica: int) -> str:", diff)
removed = [ln[1:] for ln in diff.splitlines() if ln.startswith("-") and not ln.startswith("---")]
self.assertEqual(removed, [' scheduler_host = self.host',
' if scheduler_host is None or scheduler_host == "localhost":',
' scheduler_host = "127.0.0.1"'])
self.assertEqual(added_code(LOOPBACK_PATCH), ['scheduler_host = "127.0.0.1"'])
def test_both_diffusion_lanes_keep_their_scheduler_on_loopback(self):
for inst in (INSTALLER, REPO / "install-video.sh"):
text = inst.read_text()
self.assertIn("scheduler-loopback", re.search(r"^PATCHES=\((.*)\)$", text, re.M).group(1).split(), inst.name)
self.assertIn('[scheduler-loopback]="', text, inst.name)
def _bind(self, value):
"""The installer's own lines for the bind, run as they are written."""
t = INSTALLER.read_text()
block = t[t.index('IMAGE_BIND="${IMAGE_BIND:-$(unit_flag --host)}"'):t.index("WEIGHTS_GB=")]
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n' + block],
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin", "IMAGE_BIND": value})
return r.returncode, r.stdout + r.stderr
def test_the_image_lane_still_takes_every_interface_when_asked(self):
"""Hasan, 2026-10-24: no refusal of 0.0.0.0 here. The proxy relays no image route, so a
client on another machine or in a container (Open WebUI) reaches this lane by its bind,
and with the scheduler on loopback what 0.0.0.0 still costs is what the warning says."""
rc, out = self._bind("0.0.0.0")
self.assertEqual(rc, 0, out)
self.assertIn("anyone who can reach that address can generate on your GPU", out)
self.assertIn("0.0.0.0 is every interface", out)
self.assertIn("The scheduler's own channel stays on 127.0.0.1 whatever this bind", out)
rc, out = self._bind("192.168.1.20")
self.assertEqual(rc, 0, out)
self.assertIn("The scheduler's own channel stays on 127.0.0.1 whatever this bind", out)
self.assertNotIn("every interface", out)
rc, out = self._bind("127.0.0.1")
self.assertEqual((rc, out), (0, ""))
def test_the_installer_applies_exactly_the_patches_in_the_repo(self):
listed = re.search(r"^PATCHES=\((.*)\)$", INSTALLER.read_text(), re.M).group(1).split()
on_disk = sorted(f.stem for f in (REPO / "image-sglang").glob("*.patch"))
@@ -457,7 +503,7 @@ class TheLocalPatches(unittest.TestCase):
self._git(d, "init", "-q")
turbo = [(re.search(r"^\+\+\+ b/(.+)$", f.read_text(), re.M).group(1), pre_image(f))
for f in TURBO_PATCHES.values()]
for rel, text in [(PATCHED, sched), (HTTP_PATCHED, http)] + turbo:
for rel, text in [(PATCHED, sched), (HTTP_PATCHED, http), (LOOPBACK_PATCHED, pre_image(LOOPBACK_PATCH))] + turbo:
(d / rel).parent.mkdir(parents=True, exist_ok=True)
(d / rel).write_text(text)
self._git(d, "add", "-A")
@@ -479,6 +525,7 @@ class TheLocalPatches(unittest.TestCase):
self.assertEqual(rc, 0, out)
self.assertIn("scheduler-idle-poll: applied", out)
self.assertIn("http-graceful-timeout: applied", out)
self.assertIn("scheduler-loopback: applied", out)
for name in TURBO_PATCHES:
self.assertIn(f"{name}: applied", out)
self.assertNotIn("NOTE:", out)
@@ -491,7 +538,9 @@ class TheLocalPatches(unittest.TestCase):
self.assertEqual(note.stat().st_mtime, 1_000_000, "nothing changed: the date stays")
self.assertIn("scheduler-idle-poll: already applied", out)
self.assertIn("http-graceful-timeout: already applied", out)
self.assertIn("scheduler-loopback: already applied", out)
self.assertEqual((src / PATCHED).read_text().count("self._poller.poll(timeout=1000)"), 1)
self.assertNotIn("scheduler_host = self.host", (src / LOOPBACK_PATCHED).read_text())
self.assertEqual((src / HTTP_PATCHED).read_text().count("timeout_graceful_shutdown=5"), 1)
def test_a_new_pin_checks_out_over_a_patched_tree(self):
+23 -6
View File
@@ -266,12 +266,14 @@ class TheInstaller(unittest.TestCase):
def test_the_source_overlay_needs_no_rust_toolchain(self):
self.assertIn("SGLANG_BUILD_RUST_EXTS=none", self.text)
def test_it_carries_the_image_lanes_idle_patch_and_nothing_else(self):
def test_it_carries_the_image_lanes_idle_and_loopback_patches_and_nothing_else(self):
"""Hasan, 2026-09-25: the official recommendations, nothing added on top. Hasan,
2026-10-06: except the idle wait, measured holding one core at rest. The patch is
the image lane's own file: one copy for both lanes, so no video-sglang directory."""
2026-10-06: except the idle wait, measured holding one core at rest. Hasan,
2026-10-24: and the scheduler's channel kept on loopback, a security fix (D01). The
patches are the image lane's own files: one copy for both lanes, so no video-sglang
directory."""
listed = re.search(r"^PATCHES=\((.*)\)$", self.text, re.M).group(1).split()
self.assertEqual(listed, ["scheduler-idle-poll"])
self.assertEqual(listed, ["scheduler-idle-poll", "scheduler-loopback"])
self.assertFalse((REPO / "video-sglang").exists())
self.assertIn('PF="$HERE/image-sglang/$P.patch"', self.text)
self.assertTrue((REPO / "image-sglang" / "scheduler-idle-poll.patch").is_file())
@@ -382,6 +384,16 @@ class TheInstaller(unittest.TestCase):
PATCHED = "python/sglang/multimodal_gen/runtime/managers/scheduler.py"
LOOPBACK_PATCH = REPO / "image-sglang" / "scheduler-loopback.patch"
LOOPBACK_PATCHED = "python/sglang/multimodal_gen/runtime/server_args/server_args.py"
def pre_image(patch):
"""The patched file as the patch expects to find it: its context and removed lines."""
out = [ln[1:] if ln else "" for ln in patch.read_text().splitlines()
if not ln.startswith(("diff --git", "index ", "--- ", "+++ ", "@@")) and (ln.startswith((" ", "-")) or ln == "")]
return "\n".join(out) + "\n"
# The hunk's context as it stands at the pin, three lines either side of the insertion:
# the same as tests/test_image_lane.py's, since both lanes serve the same commit.
CONTEXT_AT_PIN = (
@@ -414,8 +426,9 @@ class TheIdlePatch(unittest.TestCase):
d = pathlib.Path(tempfile.mkdtemp(prefix="vid-src-"))
self.addCleanup(shutil.rmtree, d, True)
self._git(d, "init", "-q")
(d / PATCHED).parent.mkdir(parents=True, exist_ok=True)
(d / PATCHED).write_text(sched)
for rel, text in ((PATCHED, sched), (LOOPBACK_PATCHED, pre_image(LOOPBACK_PATCH))):
(d / rel).parent.mkdir(parents=True, exist_ok=True)
(d / rel).write_text(text)
self._git(d, "add", "-A")
self._git(d, "commit", "-qm", "pin")
self._git(d, "remote", "add", "origin", str(d))
@@ -442,6 +455,8 @@ class TheIdlePatch(unittest.TestCase):
rc, out = self._install(src, pin)
self.assertEqual(rc, 0, out)
self.assertIn("scheduler-idle-poll: applied", out)
self.assertIn("scheduler-loopback: applied", out)
self.assertNotIn("NOTE:", out)
# the commit is noted for the cockpit's Turbo (video_runtime_stale), and a run that
# changes nothing leaves the note's date alone: a lane started since keeps its Turbo
self.assertEqual(self.note.read_text().strip(), pin)
@@ -453,7 +468,9 @@ class TheIdlePatch(unittest.TestCase):
rc, out = self._install(src, pin)
self.assertEqual(rc, 0, out)
self.assertIn("scheduler-idle-poll: already applied", out)
self.assertIn("scheduler-loopback: already applied", out)
self.assertEqual((src / PATCHED).read_text().count("self._poller.poll(timeout=1000)"), 1)
self.assertNotIn("scheduler_host = self.host", (src / LOOPBACK_PATCHED).read_text())
self.assertEqual(int(self.note.stat().st_mtime), 1_000_000)
self.assertEqual(int(runtime.stat().st_mtime), 1_000_000, "nothing changed: the date stays")