Commit Graph
11 Commits
Author SHA1 Message Date
Hasan BasbunarandClaude Opus 5.5 af1aa5d2a2 proxy: the identity wall reads the Bearer scheme in any case
With QWEN38_CLIENT_KEYS_FILE set, _label_peer named a client only when
its header started with "Bearer " exactly, while SGLang, vLLM's
middleware (vllm_engine_auth.py) and the door without the wall
(engine_admits) all read the scheme in any case, as RFC 9110 11.1 has
it. A listed key sent as "bearer <key>" got the wall's 401 "missing or
unknown client key" from a proxy whose engine admits that header.
Reproduced against v6.41 with a live proxy: "Bearer" 503 (no engine
behind it, so past the wall), "bearer" and "BEARER" 401.

The scheme is now compared case-insensitively and the token after it is
stripped as before; an empty token or another scheme still gets the 401.

Found in a cloud review of v1.36.1 (pull request #52). The reference box
does not set QWEN38_CLIENT_KEYS_FILE, so there it changes nothing. The
new test fails on the old code (401 != 200 for "bearer") and passes on
this one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 17:37:32 +02:00
Hasan BasbunarandClaude Opus 5.5 b674f9f6aa proxy: behind the wall a client key reaches the other dialects' reading routes
The wall's allow list refused Ollama's /api/tags and /api/show,
SageMaker's /ping and the root as operator routes, though SGLang v0.5.21
only reads there (a model list, a model card, an empty 200, "is
running"). They are client routes now. /encode and /classify stay out:
they run the model outside the size guard, and /v1/embeddings and
/v1/classify, which it guards, are a client's way there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 02:11:24 +02:00
Hasan BasbunarandClaude Opus 5.5 55f363adaa proxy: relay engine redirects instead of following them, mask /server_info/
urllib's default handler followed an engine redirect on a GET, resending
the engine's key, and the answer went out under the path the caller had
asked for, the one that decides the /server_info masking: /server_info/
came back 307 to /server_info, was followed, and was relayed unmasked.
Engine redirects are now relayed with a Location that points back at the
proxy, and the masking ignores trailing slashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 02:11:24 +02:00
Hasan BasbunarandClaude Opus 5.5 ff4fb96bc8 proxy: a listed client key no longer reaches the engine's operator routes
Behind the identity wall the proxy signs every relayed request with the
engine's own key, so any listed client key could reload or update the
weights, start the profiler, pause or slow the engine, flush its cache or
abort every request, as the operator. A listed key now reaches an allow
list (everything under /v1/, the native generation routes, counting,
server info, health and metrics) and gets a 403 elsewhere. The cockpit
calls the engine's operator routes on 127.0.0.1:30000 directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 02:11:24 +02:00
Hasan BasbunarandClaude Opus 5.5 0b27e26d99 proxy: the serving key is checked before a body is read
Without the identity wall, the engine's key is the port's one gate (README), and a
request without it still had its body read whole and, when large, counted by the
engine on the proxy's own key before the engine's 401. The proxy now applies the
engine's own rule first (measured on the live engine: bearer in any case, one space,
the key exactly) and answers the engine's own 401, before the body and before an
Expect: 100-continue invitation; /health and /metrics stay open. The test harnesses
decide which key their proxy holds, whatever HOME holds: those that give it one
present it, as every real client does, and those whose clients send none give it
none (the CI's offline step gives HOME a key). The cockpit knows the new outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:01:56 +02:00
Hasan BasbunarandClaude Opus 5.5 13d346b30c proxy v6.32: the engine key is masked everywhere in /server_info
SGLang's /server_info repeats the engine's whole command line in
launch_command, the API key included, and the proxy took out only the
key fields (api_key, admin_api_key, at the top and in every internal
state). Behind the identity wall, a named client could read through the
proxy the one secret the wall keeps from it; without the wall the
caller already holds it.

Every string of the answer now goes through mask_secrets: the value of
--api-key, --admin-api-key and --ssl-keyfile-password, in any form a
command line gives it, and the engine's own key wherever it shows (not
looked for by value under 8 characters, which no real key is and which
would garble unrelated strings). ssl_keyfile_password joins the key
fields.

Found by the flash audit of 2026-10-03; checked on the reference box:
through the proxy the key was in launch_command and in no other answer
(/v1/loads, /v1/models, /metrics, /model_info). The fake engine now
answers as the real one does; the server-info test and two new ones
fail against v6.31.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 18:12:56 +02:00
Hasan BasbunarandClaude Opus 5.5 7e58a19e77 proxy: Anthropic bodies counted by the engine, raw query bytes refused, bounded logging, labelled first lines; cockpit reads the running proxy's banner
- P3: an Anthropic body goes to the engine's own /v1/messages/count_tokens
  (its conversion, tools included), each image priced from its header and
  replaced by an empty text block (an empty list is a 500 there). Measured on
  the box: five screenshots in tool_result blocks were counted 2,044,251 and
  refused, the engine serves 28,463 (28,458 counted now); 8 tools, 422 counted
  before, 2,709 now and served
- P4: a raw control or non-ASCII byte in the query is a 400, not a dropped
  socket and a "client vanished" line
- P5: the logged-once memories keep 16-byte digests, 512 at most; the moved
  effort is printed 40 characters long (five 20 MB values: 22 -> 346 MiB and
  a 20,000,137-character journal line each, before)
- P7: a client named by the identity wall is named on the request's first
  line too, as one word; the cockpit's feed accepts the label after the peer
- P6: the cockpit greps the banner in its current shape ("on 0.0.0.0:30001");
  it showed v6.20 while v6.24 ran. U7: the too-old-to-abort warning compares
  versions part by part, server-side (as floats, v6.2 to v6.9 passed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 15:25:16 +02:00
Hasan BasbunarandClaude Opus 5.5 7a8d0afdd7 v1.18.7: a full review of v1.18.6, and the defects it found fixed with a test each
- cockpit: a non-digit Content-Length is a 400 before any read (-1 read an
  unlimited body before login)
- proxy v6.24: the identity wall covers every route and method but /health;
  a path still escaped after one decode is refused; relayed /server_info loses
  the engine key fields; an unreadable keys file says so
- docs/clients.md: the keys file is installed owned by the user, the engine
  key goes in an EnvironmentFile
- image unit: After= on the text units, so a switch stops before it starts
- lifecycle: a down unit with a live container is an orphan, busy for the gate
- cockpit: its own /health probe no longer counts as activity (the canary
  never ran)
- install.sh: sudo asked at step 1 and renewed at step 8 with a prompt;
  CONTEXT_MODE=1m refused on a flash box after the convergence; the flash
  engine bind is read from the launcher
- switch-model.sh: downloads into the cache the installed unit mounts
- uninstall.sh, install-image.sh: remove only venv/ and sglang/ of the lane
- opencode limits hold the engine window (205000/32000 flash,
  173000/64000 native), fit() and the cockpit's verdict and autofit use the
  same rule, the 27B entry of a flash install comes from the table;
  collect_opencode has its @guard back
- Setup's Fit button has a click handler
- bench-agent: the TTFT slope is in the unit it prints
- CI: negated grep, generated script lists, exact sudoers argv, flash flags
  read from install.sh

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:40:38 +02:00
Hasan BasbunarandClaude Opus 5 9d6967687c proxy: refuse the request fields SGLang dies on, and close three holes of this route's own (v6.20)
Reading logprobs is what /v1/systemone does, so an audit went looking at what
else can ask for them. OpenAI documents top_logprobs as "an integer between 0
and 20"; SGLang declares it Optional[int] with no constraint and hands it to
logprobs.topk(max_k), where a number past the vocabulary raises "selected index
k out of range" INSIDE the scheduler. One request from one client ends the
engine for everybody, and this box needs about nine minutes to come back
(sglang#40076, open). It was then reproduced the hard way here, by relaying one
such request during a test of the refusal meant to prevent it.

sglang#31597 catalogued the same family in July with reproductions, and both
PRs that bounded them were closed without being merged, which is why the first
had to be reported again in September. Checked one by one in the served
v0.5.19: stop_token_ids indexes a scatter_add_ out of bounds whenever
min_new_tokens > 0; input_ids indexes the embedding, and the validator that
would stop it has zero callers; n becomes parallel_sample_num unbounded. All
reachable from an ordinary chat request.

So the proxy refuses them, on the three relayed routes that carry the logprob
count under three names, element by element when a batch sends a list. The two
id fields need the vocabulary, which the engine publishes nowhere, so it is
asked for the only way it is offered: an out-of-range logit_bias is refused
with a message that names it. One probe an hour, built to be refused, never
reaching the scheduler; it matched the checkpoint's config.json to the digit.
A negative id is refused whatever happens, and a probe that fails stands the
rest of the guard down rather than refuse traffic it cannot judge.

Three defects of this route's own, found in the same audit and in review:
  * the retry that asks a second, wider time went straight to the engine
    without the door, and ignored SYSTEMONE_TOP_K_MAX, the clamp an operator
    sets because their build refuses a wide top-k
  * a percent-encoded non-ASCII byte in any path decoded to something
    http.client encodes as ASCII, raising UnicodeEncodeError, a ValueError no
    arm here catches: an empty reply and a traceback, before any key is checked
  * a lone surrogate outside the state cost a full fan-out and returned 500;
    the check now runs over the whole parsed request, before any inference, and
    never echoes the text it cannot encode
  * a branch still queued for a slot was aborted with a rid the engine had
    never seen, then sent anyway when a slot freed

And one trap written down rather than fixed, because the code was already right
and nothing said why: on the speculative path this lane runs, the engine
divides the logprobs it returns by the request's temperature, and on the
ordinary path it does not. Only the 1.0 this route sends makes the two agree.

keepalive-proxy.py at 84% branch coverage, floor raised to 83.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 10:22:37 +02:00
Hasan BasbunarandQwen3.8-flash-next via opencode 4458a2c4a7 proxy v6.17: the identity wall learns admission, not just naming
v6.16 named WHO and admitted no one: the client's bearer went upstream
verbatim and met the engine's own --api-key there, so every labeled
request died with the engine's 401 past a wall that had correctly
identified it. Found live on the reference box against the real engine,
not in any test, because every fake engine in the suite lets everything
through: that is the hole's whole biography, and the fix carries its own
enforcing fake engine so it cannot reopen unnoticed. QWEN38_UPSTREAM_API_KEY
names the engine's key to the proxy; when both halves are set, the
client's bearer names them on the journal line and the engine's key admits
them upstream, on relays and on abort calls alike (the abort path had the
same verbatim habit). Without the upstream key the old verbatim behavior
stays, for an engine with no check of its own or one shared key on
purpose, and the banner warns loudly about the combination. Three new
admission scenarios (substitution observed engine-side, verbatim pinned as
the documented fallback, upstream key dormant with the wall off); root
proxy coverage 78% over its 74% floor.

Co-Authored-By: Qwen3.8-flash-next via opencode <noreply@opencode.ai>
2026-09-13 19:15:09 +02:00
Hasan BasbunarandQwen3.8-flash-next via opencode c0eef5765f proxy v6.16: the TLS and identity walls operators kept building in front, built in
Two opt-in walls, both because local production asks them and both
designed so the loopback/tailnet default does not notice their
existence. TLS: name QWEN38_TLS_CERT (QWEN38_TLS_KEY when the key is
separate) and the socket speaks the operator's certificate, TLS1.2
floor, and refuses to start rather than half-wrap. Per-client identity:
QWEN38_CLIENT_KEYS_FILE, a JSON map of bearer token to label; when set
a /v1/ request without a listed key gets a 401 in its own dialect
(authentication_error parses on the Claude side, error.type on the
OpenAI side), /health stays open because a monitored endpoint behind an
identity wall stops being monitoring, and the label rides every journal
line of the request, which is the question one shared key can never
answer. Both walls fail closed: a cert that cannot load or a keys file
that is missing, empty or malformed boots nothing, because a wall that
vanished silently is worse than no wall. Authorization is still
forwarded verbatim, so this is identity in front of the engine's
--api-key, not a second key to rotate in two places. Nine tests drive
the real subprocess and socket (handshake, plain-rejected-beside-TLS,
the dialects of the 401, open /health, the refuse-to-start trios); the
guard crashed once already in development on ssl.TLSVersion.TLS1_2
against TLSv1_2, the exact class of bug these tests exist to catch
before an operator meets it at 2 a.m. on a unit whose Restart=always
respawns it into the same crash. The closed outcome vocabulary names
its own new member: the 401 registers as the fail kind, the same
reading its 400 and 413 siblings got, and the vocabulary gate pointed
at it before this line was written.

Co-Authored-By: Qwen3.8-flash-next via opencode <noreply@opencode.ai>
2026-09-13 17:53:34 +02:00