fleet: the admin routes read all three legs, as the engine's guards do

The fleet front guarded its admin routes with the loopback socket alone.
The socket is the one leg that forges: a DNS-rebinding page is same-origin
with its victim's browser and dials through loopback, and a localhost proxy
delivers remote clients on loopback sockets carrying the public Host. With
CORS open by default, a web page in the operator's browser could unload and
park any model, reload the fleet, and read the topology -- disk paths in
the body -- from outside the machine.

The three-leg rule (loopback socket, no foreign Origin, a Host that names
this box) was Server::local_operator's, locked inside Server. Hoist it to
server::local_operator(request, bind_host, local_hosts) beside the request
whose fields it reads, keep the member as the delegate it now is, and let
the fleet's guard call the very same predicate with its own config's host
and --allow-host names. One rule, two callers, no forked wording.
This commit is contained in:
fl0l0u committed 2026-11-15 20:38:09 +00:00
1 parent 2a2b756371
commit 41a1aa00fe
6 files changed
+83 -32

No files matched your search

+6
View File
@@ -89,6 +89,12 @@ bool cidr_valid(const std::string& cidr);
* happens to embed it. */
bool ip_in_cidr(const std::string& addr, const std::string& cidr);
/* The identity the keyless "loopback only" guards accept -- the three legs the engine's admin
* routes read (see the definition in http.cpp for why the socket alone forges). Every guard that
* answers loopback callers keyless reads this, the fleet's front included. */
bool local_operator(const HttpRequest& req, const std::string& bind_host,
const std::vector<std::string>& local_hosts);
/* The caller a proxy chain vouches for. `raw_addr` is the socket peer (no port), `xff` the
* request's X-Forwarded-For value ("" when there is none), `trusted` the vouched CIDRs.
* Nothing is read from the header unless the socket itself belongs to a vouched CIDR -- an