The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(debug): block non-loopback requests in web-ui debug runs
Steven Enamakelf96f2eda9002
diff --git a/scripts/__tests__/debug-web-ui.test.mjs b/scripts/__tests__/debug-web-ui.test.mjsindex 7308e736af..d07a6a063c 100644--- a/scripts/__tests__/debug-web-ui.test.mjs+++ b/scripts/__tests__/debug-web-ui.test.mjs@@ -5,6 +5,7 @@ import test from "node:test";import {devConnectUrl,freePort,+ isLoopback,parseArgs,runStamp,waitFor,@@ -78,3 +79,12 @@ test("waitFor resolves once the probe passes and times out otherwise", async ()/timed out waiting for the thing/,);});++test("isLoopback admits only local hosts and inline URLs", () => {+ assert.equal(isLoopback("http://localhost:1420/src/main.tsx"), true);+ assert.equal(isLoopback("http://127.0.0.1:7788/rpc"), true);+ assert.equal(isLoopback("ws://127.0.0.1:7788/socket.io/"), true);+ assert.equal(isLoopback("data:image/png;base64,AAAA"), true);+ assert.equal(isLoopback("https://panel.tinyhumans.ai/api/track"), false);+ assert.equal(isLoopback("https://raw.githubusercontent.com/x"), false);+});diff --git a/scripts/debug/web-ui-lib.mjs b/scripts/debug/web-ui-lib.mjsindex 9b1e171781..999d5175d5 100644--- a/scripts/debug/web-ui-lib.mjs+++ b/scripts/debug/web-ui-lib.mjs@@ -119,3 +119,12 @@ export async function waitFor(fn, { timeoutMs, intervalMs = 200, what }) {await new Promise(resolve => setTimeout(resolve, intervalMs));}}++const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);++/** True for http(s)/ws(s) URLs on a loopback host, plus data:/blob: URLs. */+export function isLoopback(url) {+ const parsed = typeof url === "string" ? new URL(url) : url;+ if (parsed.protocol === "data:" || parsed.protocol === "blob:") return true;+ return LOOPBACK_HOSTS.has(parsed.hostname);+}diff --git a/scripts/debug/web-ui.mjs b/scripts/debug/web-ui.mjsindex c370080ea2..4675871e45 100644--- a/scripts/debug/web-ui.mjs+++ b/scripts/debug/web-ui.mjs@@ -23,6 +23,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";import {devConnectUrl,freePort,+ isLoopback,parseArgs,runStamp,USAGE,@@ -186,8 +187,17 @@ async function main() {args: ["--disable-dev-shm-usage"],});const context = await browser.newContext({ viewport: { width: 1300, height: 900 } });- const page = await context.newPage();const browserLog = fs.createWriteStream(path.join(logDir, "browser.log"));+ // Everything the run needs is on loopback. Abort the rest (analytics,+ // remote assets) so a scenario never reaches a real third-party service.+ await context.route(+ url => !isLoopback(url),+ route => {+ browserLog.write(`[blocked] ${route.request().method()} ${route.request().url()}\n`);+ return route.abort("blockedbyclient");+ },+ );+ const page = await context.newPage();page.on("console", msg => browserLog.write(`[${msg.type()}] ${msg.text()}\n`));page.on("pageerror", err => browserLog.write(`[pageerror] ${err.stack ?? err.message}\n`));page.on("requestfailed", req =>