Skip to content

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

fix(browser): keep OpenMausBot's own ports shut inside an egress allow entry

DeryFerdf2aae4a25406
diff --git a/server/browser/egress/policy.test.ts b/server/browser/egress/policy.test.ts
index 564769273a..6508091b31 100644
--- a/server/browser/egress/policy.test.ts
+++ b/server/browser/egress/policy.test.ts
@@ -166,6 +166,13 @@ describe("what each host lets a bot's browser reach", () => {
}
});
+ it("keeps OpenMausBot's own ports shut inside an allow entry, as the owner's switch already does", async () => {
+ const entry = { allowed: () => true, localNetwork: false };
+ expect(await decide("server", "172.18.0.1:8799", ["172.18.0.1"], entry)).toBe("omb");
+ // The entry still opens the rest of that range.
+ expect(await decide("server", "172.18.0.1:5432", ["172.18.0.1"], entry)).toBeNull();
+ });
+
it("refuses when any address a name resolves to is refused", async () => {
expect(await decide("cloud", "mixed.example:443", ["93.184.215.14", "10.0.0.1"])).toBe("local-network");
});
diff --git a/server/browser/egress/policy.ts b/server/browser/egress/policy.ts
index 4172c79801..965fc2e254 100644
--- a/server/browser/egress/policy.ts
+++ b/server/browser/egress/policy.ts
@@ -140,7 +140,13 @@ export async function refusalFor(
if (kind === "public") continue;
if (kind === "metadata" || kind === "link-local" || kind === "reserved") return kind;
if (kind === "private") {
- if (rules.host === "desktop" ? rules.localNetwork : rules.host === "server" && rules.allowed(address, port)) continue;
+ // An entry in the owner's allow list opens a private range, never OpenMausBot's own ports inside it: the switch
+ // below refuses those, and an entry must not be a wider door than the switch.
+ if (rules.host === "server" && rules.allowed(address, port)) {
+ if (rules.ownPort(port)) return "omb";
+ continue;
+ }
+ if (rules.host === "desktop" && rules.localNetwork) continue;
// The owner's switch opens the local network, but never OpenMausBot's own ports through it (a Docker host's gateway).
if (rules.host === "server" && rules.localNetwork) {
if (rules.ownPort(port)) return "omb";