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

+8 -1
View File
@@ -354,8 +354,15 @@ func newServerCmd() *cobra.Command {
// No write timeout: responses stream for minutes and the proxy
// enforces its own per-phase deadlines.
}
if err := checkAdminListen(cfg); err != nil {
return err
}
adminToken, err := ensureAdminToken(adminTokenPath(configPath, cfg))
if err != nil {
return err
}
adminSrv := &http.Server{
Handler: router.AdminGuard(adminMux),
Handler: router.AdminGuard(router.AdminAuth(adminToken, cfg.DebugPprof, adminMux)),
ReadHeaderTimeout: 10 * time.Second,
}