
Missing Authorization on sglang /load_lora_adapter_from_tensors endpoint (CVE-2026-127222)
/load_lora_adapter_from_tensors EndpointAffected: sglang 0.5.8 through 0.5.21 (inclusive)
Fixed in: 0.5.22
CWE: CWE-862 (Missing Authorization)
Component: sglang.srt.entrypoints.http_server → POST /load_lora_adapter_from_tensors
Reported by: Rahul Karne
CNA: VulnCheck
sglang's HTTP server protects its administrative endpoints with a per-route
authorization decorator, @auth_level(AuthLevel.ADMIN_OPTIONAL), enforced by an
ASGI middleware.
The endpoint POST /load_lora_adapter_from_tensors is missing that decorator,
while both of its sibling LoRA endpoints (/load_lora_adapter and
/unload_lora_adapter) have it.
Because an undecorated route resolves to the default AuthLevel.NORMAL, the
endpoint does not receive the same authorization treatment as the other LoRA
administrative endpoints. In affected key configurations this allows an
administrative action to be invoked without the expected credential.
This was a day-one defect: the endpoint and the @auth_level system were both
introduced in 0.5.8, and this endpoint was the single administrative route that
shipped without the decorator.
/load_lora_adapter_from_tensors is an administrative endpoint that loads a LoRA
adapter into the running model from caller-supplied data. Invoking it without
authorization allows an unauthorized caller to:
The authorization defect is independent of, and compounds, any weakness in the downstream payload-handling code: an endpoint that is supposed to require an admin credential should never be reachable without one.
The practical effect of the missing decorator depends on how the server's API keys are configured. This report is deliberately precise about that, because the issue is not "always unauthenticated for everyone."
| Server configuration | /load_lora_adapter (sibling) | /load_lora_adapter_from_tensors (this bug) | Effect |
|---|---|---|---|
--admin-api-key only | requires admin key | reachable with NO credential | Unauthenticated access to an admin action |
both --api-key and --admin-api-key | requires admin key | reachable with the low-priv --api-key | Privilege downgrade (normal key unlocks an admin-only action) |
--api-key only | requires api key | requires api key | No bypass in this configuration |
| no keys configured | open | open | Auth middleware is not installed at all; unrelated to this bug |
The headline case is the first row: with --admin-api-key set, the endpoint is
reachable with no credential at all.
Reaching the LoRA code additionally requires the server to be started with
--enable-lora. Note also that sglang binds to 127.0.0.1 by default; network
exposure depends on the deployment (--host 0.0.0.0, container port mapping, etc.).
sglang authorizes administrative routes with a decorator defined in
sglang/srt/utils/auth.py:
def auth_level(level: AuthLevel):
"""Mark endpoint with auth level (stored in endpoint metadata)."""
def decorator(func):
func._auth_level = level
return func
return decorator
An ASGI middleware (add_api_key_middleware → _ApiKeyASGIMiddleware) resolves
each request to its route, reads that route's _auth_level, and calls
decide_request_auth(). A route with no @auth_level decorator resolves to the
default:
# _get_auth_level_from_app_and_scope(...)
level = getattr(endpoint, "_auth_level", None)
return level if isinstance(level, AuthLevel) else AuthLevel.NORMAL
And for AuthLevel.NORMAL, when no plain api_key is configured,
decide_request_auth() returns allowed:
# decide_request_auth(..., auth_level=AuthLevel.NORMAL)
if api_key:
return AuthDecision(allowed=_check_bearer_token(authorization_header, api_key))
return AuthDecision(allowed=True) # <-- no api_key configured => allowed
In the vulnerable releases, http_server.py decorates the siblings but not the
target:
@app.api_route("/load_lora_adapter", methods=["POST"])
@auth_level(AuthLevel.ADMIN_OPTIONAL) # protected
async def load_lora_adapter(...):
...
@app.api_route("/load_lora_adapter_from_tensors", methods=["POST"])
# <-- NO @auth_level decorator : the bug
async def load_lora_adapter_from_tensors(...):
...
@app.api_route("/unload_lora_adapter", methods=["POST"])
@auth_level(AuthLevel.ADMIN_OPTIONAL) # protected
async def unload_lora_adapter(...):
...
So when the server is launched with --admin-api-key (and no plain --api-key),
the two siblings require the admin bearer token, while
/load_lora_adapter_from_tensors resolves to NORMAL and is allowed through with
no credential.
A single administrative route was added without the @auth_level decorator that
every other administrative route carries. The authorization model is
decorator-opt-in: a route that forgets the decorator silently falls back to the
least-restrictive NORMAL level instead of failing closed.
poc_sglang_missing_auth.py demonstrates the issue
using sglang's own code, two independent ways, with no GPU, no model, and no
RCE payload:
PART 1 — static, against the real http_server.py: it AST-parses sglang's
actual srt/entrypoints/http_server.py at a pinned release tag and prints the
three LoRA endpoints with their decorators, showing that
/load_lora_adapter_from_tensors is the lone administrative LoRA route missing
@auth_level.
PART 2 — dynamic, against the real auth.py: it loads sglang's genuine
srt/utils/auth.py (the real @auth_level decorator, the real route-level
resolver, the real decide_request_auth, and the real add_api_key_middleware
ASGI middleware), mounts two endpoints whose decoration is driven by what PART 1
found in the real source, starts the server as --admin-api-key ..., and sends
credential-free requests. The protected sibling returns 401; the vulnerable
endpoint returns 200 (its handler is reached).
The stubbed 200-returning handler is intentional and sufficient: the
vulnerability lives entirely in the authorization layer that runs before the
model-loading handler, so a credential-free request reaching the handler at all is
itself the proof that authorization was bypassed.
The demonstration drives sglang's real authorization module rather than a hand-written imitation. The only thing not executed is the heavyweight model-loading handler body (which requires torch/CUDA), which is exactly the code that authorization is supposed to gate.
The PoC needs only a few pure-Python packages:
pip install fastapi starlette httpx
It fetches the two sglang source files it analyzes directly from the pinned release
tag on GitHub (no sglang install, no GPU). To run entirely offline, point it at a
locally extracted sglang source tree with --source/--sglang-src.
Against the default vulnerable tag (v0.5.13.post1):
python poc_sglang_missing_auth.py
Against any affected tag (v0.5.8 … v0.5.21):
python poc_sglang_missing_auth.py --tag v0.5.21
Against a local extracted source tree (offline):
python poc_sglang_missing_auth.py --sglang-src /path/to/sglang