Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Teammate addresses: refuse every link-local, metadata or reserved literal when saving
Bugfixer 23a528f4fde25
diff --git a/server/remote-teammates.test.ts b/server/remote-teammates.test.tsindex 8f0daa9de5..df6fa58845 100644--- a/server/remote-teammates.test.ts+++ b/server/remote-teammates.test.ts@@ -61,6 +61,9 @@ describe("remoteAddress", () => {expect(() => remoteAddress("http://2852039166", "b1")).toThrow(/link-local/);expect(() => remoteAddress("http://[fe80::1]:8799", "b1")).toThrow(/link-local/);expect(() => remoteAddress("http://[fd00:ec2::254]", "b1")).toThrow(/link-local/);+ expect(() => remoteAddress("https://[64:ff9b::a9fe:a9fe]", "b1")).toThrow(/link-local/);+ expect(() => remoteAddress("https://[::a9fe:a9fe]", "b1")).toThrow(/link-local/);+ expect(() => remoteAddress("https://100.100.100.200", "b1")).toThrow(/link-local/);expect(() => remoteAddress(`https://maus.example.com/${"p".repeat(300)}`, "b1")).toThrow(/too long/);});diff --git a/server/remote-teammates.ts b/server/remote-teammates.tsindex fc4add20ad..4db3d55ecc 100644--- a/server/remote-teammates.ts+++ b/server/remote-teammates.ts@@ -30,9 +30,6 @@ const THREAD_ID = /^[\w-]{1,128}$/;const KEY = /^bak_[\w-]{16,200}$/;const ENDPOINT_PATH = /^(.*?)\/hooks\/api\/bots\/([^/]+)\/messages\/?$/;const MAX_BASE_CHARS = 300;-/** Link-local hosts (169.254/16, fe80::/10) and the cloud metadata service: never another OpenMausBot server, and a key- * must not open a way from this server to them. */-const LINK_LOCAL = /^(?:169\.254\.|\[fe[89ab][0-9a-f]:|\[::ffff:a9fe:|\[fd00:ec2::254\]$)/i;/** No other server answers on these, whatever a name resolves to. */const NOT_A_SERVER = new Set<AddressClass>(["link-local", "metadata", "reserved"]);/** This server's own addresses count as any other: a teammate may run on this computer. */@@ -107,7 +104,7 @@ export function remoteAddress(address: string, botId?: string): { base: string;if (!allowedServerOrigin(url.origin)) {throw new RemoteTeammateError(url.protocol === "http:" ? `http://${url.host} is on the open internet and plain http isn't encrypted; use its https:// address` : "the address must start with https:// (or http:// on a private network)", 400);}- if (LINK_LOCAL.test(url.hostname)) throw new RemoteTeammateError(`${url.hostname} is a link-local address, not another server`, 400);+ if (notAServerAddress(url.hostname.replace(/^\[|\]$/g, ""))) throw new RemoteTeammateError(`${url.hostname} is a link-local, metadata or reserved address, not another server`, 400);const endpoint = ENDPOINT_PATH.exec(url.pathname);const path = (endpoint ? endpoint[1]! : url.pathname).replace(/\/+$/, "");// A bot id is only word characters and dashes, so it never needs %-decoding.