@feigi/fleet-ctl 3.24.15 → 3.24.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/board.mjs +20 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.24.15",
3
+ "version": "3.24.17",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/scripts/board.mjs CHANGED
@@ -1375,8 +1375,28 @@ async function main() {
1375
1375
 
1376
1376
  import { copyFileSync, mkdirSync } from "node:fs";
1377
1377
 
1378
+ // The names a browser on this machine can legitimately put in `Host` to reach
1379
+ // a loopback-only cockpit. DNS rebinding points an attacker-chosen name at
1380
+ // 127.0.0.1, and the browser then sends THAT name as `Host`, so the hostname —
1381
+ // not the peer address, which is loopback either way — is what separates the
1382
+ // operator's own tab from a rebound page. The port is deliberately not
1383
+ // compared: an `ssh -L` forward reaches the cockpit under a different local
1384
+ // port, and the port tells a rebound page nothing it could not scan for.
1385
+ const COCKPIT_HOSTNAMES = new Set(["127.0.0.1", "localhost", "[::1]"]);
1386
+ // A bracketed IPv6 literal or a bare name, then an optional `:port` — anything
1387
+ // else (userinfo, a second colon outside brackets, a path) is not a Host value.
1388
+ const HOST_HEADER = /^(\[[^\]]+\]|[^:[\]]+)(?::\d*)?$/;
1389
+ function isCockpitHost(host) {
1390
+ const m = HOST_HEADER.exec(host ?? "");
1391
+ return m !== null && COCKPIT_HOSTNAMES.has(m[1].toLowerCase());
1392
+ }
1393
+
1378
1394
  export function createBoardServer(dir) {
1379
1395
  return createServer((req, res) => {
1396
+ // Checked before routing, so an unknown path on a foreign Host is as
1397
+ // opaque as a known one: 403, never a 404 that tells a rebound page which
1398
+ // paths exist.
1399
+ if (!isCockpitHost(req.headers.host)) { res.writeHead(403); res.end("forbidden"); return; }
1380
1400
  const url = (req.url || "/").split("?")[0];
1381
1401
  const path = url === "/" || url === "/board.html" ? join(dir, "board.html")
1382
1402
  : url === "/board.json" ? join(dir, "board.json") : null;