Guard the admin API and pprof with a token only root and the server can read

The admin listener answered any local process: models added, nodes
upgraded, engine keys listed, the heap dumped. /api and /debug now demand
the token the server writes 0600 to its state directory on first start;
ctl, the console and node add send it (sudo, LLMGW_ADMIN_TOKEN or
--token-file). pprof is off unless debug_pprof. admin_listen off loopback
is refused unless admin_remote. Dashboard pages, /metrics and /health are
unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 10:02:44 +02:00
1 parent 2d47427cdc
commit c0421bc7ee
12 files changed
+365 -19

No files matched your search

+12
View File
@@ -65,6 +65,18 @@ type Server struct {
// cover the client-facing one: that surface is fronted by a publicly
// trusted certificate, while this one is mutual and private.
AgentTLS tlsconf.Config `koanf:"agent_tls"`
// AdminTokenFile holds the token the admin API's /api and /debug paths
// demand. Empty is admin-token in the systemd unit's state directory
// (/var/lib/llmgw), or secrets/admin-token beside this file for a server
// run by hand. Made, 0600, when the server starts and it does not exist;
// `sudo llmgw ctl` and the console read it from there.
AdminTokenFile string `koanf:"admin_token_file"`
// AdminRemote allows admin_listen on an address other than loopback. The
// token still guards the API, but it then crosses the network in clear.
AdminRemote bool `koanf:"admin_remote"`
// DebugPprof serves Go's profiler on the admin listener, behind the token.
// Off by default: a heap profile holds the API keys requests presented.
DebugPprof bool `koanf:"debug_pprof"`
// AgentInsecure lets a control plane run its agent port without
// agent_tls: plaintext, and any machine that reaches it may register as
// any node — be given replicas, and so be sent users' prompts — or, in