Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(browser): keep OpenMausBot's own ports closed through fake-IP addresses

AdityaUmale364984853e12
diff --git a/server/browser/egress/policy.test.ts b/server/browser/egress/policy.test.ts
index 848ebf4018..63ed7f6f94 100644
--- a/server/browser/egress/policy.test.ts
+++ b/server/browser/egress/policy.test.ts
@@ -121,6 +121,8 @@ describe("what each host lets a bot's browser reach", () => {
// The proxy's own interface is this computer: only a name for this machine reaches it, never a public one.
expect(await decide("desktop", "example.com:443", ["198.18.0.1"])).toBe("rebinding");
expect(await decide("desktop", "198.18.0.1:8080", ["198.18.0.1"])).toBeNull();
+ // The proxy may route a fake-IP answer to this computer, so OpenMausBot's own ports stay closed through it.
+ expect(await decide("desktop", "example.com:8799", ["198.18.0.7"])).toBe("omb");
for (const host of ["server", "cloud"] as const) {
expect(await decide(host, "example.com:443", ["198.18.0.7"], { allowed: () => true }), host).toBe("reserved");
}
diff --git a/server/browser/egress/policy.ts b/server/browser/egress/policy.ts
index da822223f6..00af67480d 100644
--- a/server/browser/egress/policy.ts
+++ b/server/browser/egress/policy.ts
@@ -109,7 +109,11 @@ export async function refusalFor(
for (const { address } of addresses) {
let kind = addressClass(address, own);
// On the desktop these come from the person's own proxy: the local network, unless this computer holds the address.
- if (kind === "reserved" && rules.host === "desktop" && listed(FAKE_IP, address)) kind = listed(own, address) ? "this-machine" : "private";
+ if (kind === "reserved" && rules.host === "desktop" && listed(FAKE_IP, address)) {
+ // The proxy picks the real destination, which may be this computer: never let it reach OpenMausBot's own ports.
+ if (rules.ownPort(port)) return "omb";
+ kind = listed(own, address) ? "this-machine" : "private";
+ }
if (kind === "public") continue;
if (kind === "metadata" || kind === "link-local" || kind === "reserved") return kind;
if (kind === "private") {