Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Refuse no sign-in on an address other people reach (#622)

CamoZeroDay5b730ff997e3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8572c754..26a7b9a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -125,6 +125,37 @@ documented and hoped for:
A deployment that names no domains and leaves the tenant multi-tenant warns instead of refusing,
because genuinely multi-tenant is a real deployment.
+### No sign-in cannot be combined with a public address
+
+`OPENBOT_SINGLE_USER=true` admits every request as one administrator. The flag is how somebody says
+they meant that, and it still is. What was missing is the second question: one administrator and no
+sign-in is a thing you run where only you can reach it, and nothing checked the address.
+
+It is now refused alongside an `OPENBOT_PUBLIC_URL`, `OPENBOT_APP_URL` or `TRUSTED_ORIGINS` entry
+that the public internet routes to, and the refusal names the address it objected to. This is the
+rule the chart already applies twice, in `validation.yaml`, moved to where a deployment that never
+goes near Helm is asked it too: `.env.example` ships the flag on so that a clone runs, and README's
+"Deploy it" hands that same `.env` to `docker run`, where the only thing separating a laptop from a
+server is an address.
+
+**Public, not "not loopback", and the difference is most of the deployments this flag has.** A home
+server at `192.168.1.10`, a Tailnet address, a VPN address, `openbot.local`, a bare hostname with
+no dot in it: none of those is loopback and none of them is a stranger's to reach. Refusing them
+would refuse the feature's own audience, and the only way out would be to turn off the flag that
+describes what the operator is doing. Those run, and warn once at boot that anybody on that network
+is the administrator. Loopback is silent. A value that cannot be parsed as a URL counts as public,
+because a value nobody could read is not one anybody checked.
+
+Nothing on loopback changes, so the local workflow the flag exists for is untouched, and neither is
+the chart's `config.singleUser` trial mode, which sets no public address. A deployment naming an
+external authority through `OPENBOT_ORGANIZATION_AUTH_URL` is unaffected too: the authority wins
+before this is consulted. Explicitly NOT gated on `NODE_ENV`: the image and the chart both set it
+to `production` for every deployment including that trial, so it says nothing about who can reach
+a deployment.
+
+`docs/architecture.md`, `docs/deployment.md` and `docs/configuration.md` all described the old rule
+and now describe this one.
+
### A coworker can be a file of its own
The example package declared every coworker in one `agents.yaml`, so adding one meant editing a file
diff --git a/docs/architecture.md b/docs/architecture.md
index 5e46c5f1..7dfc94dc 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -342,7 +342,7 @@ Connector credentials are stored through the credential vault and referenced by
- A provider's client secret and SAML signing material are encrypted at rest with `KEY_ENCRYPTION_KEY`, through a wrapper on the Better Auth storage adapter, since the plugin stores them as plaintext JSON. OAuth access and refresh tokens use Better Auth's own encryption, keyed on `BETTER_AUTH_SECRET`.
- Signing in, being refused, and being granted the administrator role by configuration each write an audit row. They are the only record that somebody who can edit `INITIAL_ADMIN_EMAILS` promoted themselves, and the only evidence a revoked person was ever here, since revoking them deletes their sessions.
- Removing somebody deletes their sessions and denies their address, because deleting the user row alone is not removal: the next sign-in through the provider recreates it.
-- With no identity provider configured, the deployment refuses to start unless `OPENBOT_SINGLE_USER=true` says every request may be one fixed administrator. That flag is the only thing that permits it; `NODE_ENV` does not.
+- With no identity provider configured, the deployment refuses to start unless `OPENBOT_SINGLE_USER=true` says every request may be one fixed administrator. That flag is the only thing that permits it; `NODE_ENV` does not. The flag alone is not enough on a public address: if `OPENBOT_PUBLIC_URL`, `OPENBOT_APP_URL` or any `TRUSTED_ORIGINS` entry resolves to an address the public internet routes to, the deployment refuses to start anyway, because no sign-in there means every visitor is the administrator. Loopback is silent, and a private address (a home LAN, a Tailnet, a VPN, a `.local` name) is allowed with a warning naming it, since that is the deployment the flag exists for.
- `KEY_ENCRYPTION_KEY` must be a base64-encoded 32-byte value. The example key is refused with `NODE_ENV=production`.
- Credential plaintext is encrypted at rest, never returned by APIs, and redacted from audit events.
- Browser navigation allows `http` and `https`; cloud metadata addresses are refused under every configuration.
diff --git a/docs/configuration.md b/docs/configuration.md
index 0976fbc0..0ece7b71 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -164,7 +164,7 @@ Two things are worth knowing before pointing a deployment at any gateway. Not ev
| Variable | Meaning |
| ---------------------------- | -------------------------------------------------------------------------------------- |
-| `OPENBOT_SINGLE_USER` | One fixed administrator and no sign-in. **Required** when no identity provider is configured, or the deployment refuses to start. Ignored when one is. |
+| `OPENBOT_SINGLE_USER` | One fixed administrator and no sign-in. **Required** when no identity provider is configured, or the deployment refuses to start. Refused on a public address. Ignored when a provider is configured. |
| `GOOGLE_OAUTH_CLIENT_ID` | Google OAuth client id. |
| `GOOGLE_OAUTH_CLIENT_SECRET` | Google OAuth client secret. |
| `MICROSOFT_OAUTH_CLIENT_ID` | Microsoft Entra ID application id. |
@@ -186,6 +186,14 @@ configure, because a public URL where every visitor is an administrator fails si
does not enter into it. `.env.example` ships the line switched on, so a clone runs with no
configuration at all.
+**But not on a public address.** The flag says you meant an open deployment; it does not say who can
+reach it. If `OPENBOT_PUBLIC_URL`, `OPENBOT_APP_URL` or any `TRUSTED_ORIGINS` entry is an address
+the public internet routes to, the deployment refuses to start and names it. Loopback is silent. A
+private address is allowed and warned about once at boot, because a home server, a Tailnet, a VPN
+address and a `.local` name are what this flag is mostly used for, and anybody on that network is
+the administrator. A value that cannot be parsed as a URL counts as public, because nobody checked
+it.
+
**Any one provider turns sign-in on**, and several may be configured at once. Each provider's id and
secret must be set together, Okta additionally needs its issuer, and any of them requires
`BETTER_AUTH_SECRET`, `BETTER_AUTH_URL` and `INITIAL_ADMIN_EMAILS`. Every incomplete combination is
diff --git a/docs/deployment.md b/docs/deployment.md
index 86c17f9b..ed3ef764 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -137,6 +137,14 @@ because a public URL where every visitor is an administrator fails silently: it
Configure Google, Microsoft or Okta, or set `OPENBOT_SINGLE_USER=true` to say you meant an open
deployment. `NODE_ENV` does not affect this.
+That flag does not cover a public address. `OPENBOT_SINGLE_USER=true` alongside an
+`OPENBOT_PUBLIC_URL`, `OPENBOT_APP_URL` or `TRUSTED_ORIGINS` entry that the public internet routes
+to now refuses to start and names the address, because an open deployment on a public address is
+one where every visitor is the administrator. A private address is a different thing and still
+runs: a home LAN, a Tailscale or VPN address, or a `.local` name is allowed, with a warning at boot
+saying anybody on that network is that administrator. If you want it open on a public address,
+put a sign-in provider in front of it.
+
**Put TLS in front of it.** Not only for the cookies. A page served from `http://<address>` is not a
secure context, which removes a set of browser APIs that are present on `http://localhost` and so
never missing on a laptop. The app does not depend on any of them, but sign-in cookies still want
diff --git a/server/src/config.ts b/server/src/config.ts
index e7ecb37a..6b93f347 100644
--- a/server/src/config.ts
+++ b/server/src/config.ts
@@ -417,6 +417,130 @@ function keyEncryptionKey(environment: Environment): string {
return value;
}
+/**
+ * Whether this deployment may run with no sign-in at all.
+ *
+ * {@link singleUserEnabled} answers whether somebody ASKED for it, and the flag is how they say so.
+ * That design is deliberate and stays: `single-user.test.ts` pins it, and the boot comment in
+ * `.github/workflows/ci.yml` says the same thing in the same words. This asks the second question
+ * the flag cannot answer, which is not "is this production" but "can anybody else reach it".
+ *
+ * NOT `NODE_ENV`. It looks like the signal and is not one here: `Dockerfile` sets
+ * `NODE_ENV=production` for every container and `openbot.commonEnv` sets it for every chart
+ * install, including the local trial the chart's own `validation.yaml` offers. Gating on it would
+ * refuse a mode the chart advertises and would fail the image-boot job in CI, which runs exactly
+ * this combination on purpose.
+ *
+ * The chart already asks the right question twice, and this is the same question moved to where a
+ * deployment that never goes near Helm is also asked it:
+ *
+ * config.singleUser + a LoadBalancer with no source ranges -> refused
+ * config.singleUser + config.publicUrl -> refused
+ *
+ * So: one administrator and no sign-in is a thing you run where only you can reach it. A public
+ * URL, or a trusted origin that is not loopback, says somebody else can. `.env.example` ships the
+ * flag on so a clone runs, and README's "Deploy it" hands that same `.env` to `docker run`; what
+ * separates those two is an address, which is what this reads.
+ */
+function singleUserAllowed(
+ environment: Environment,
+ hasProvider: boolean,
+): boolean {
+ if (!singleUserEnabled(environment, hasProvider)) return false;
+
+ const reachable = [
+ optional(environment, "OPENBOT_PUBLIC_URL"),
+ optional(environment, "OPENBOT_APP_URL"),
+ ...commaSeparated(environment, "TRUSTED_ORIGINS"),
+ ].filter((value): value is string => value !== undefined);
+
+ const published = reachable.filter((value) => reachOf(value) === "public");
+ if (published.length > 0) {
+ throw new Error(
+ `OPENBOT_SINGLE_USER admits every request as one administrator with no sign-in, so it cannot be combined with an address the public internet reaches: ${published.join(", ")}. Configure GOOGLE_OAUTH_*, MICROSOFT_OAUTH_* or OKTA_OAUTH_* with BETTER_AUTH_SECRET and BETTER_AUTH_URL, or serve it somewhere only you reach.`,
+ );
+ }
+
+ /*
+ * A private address is allowed and said out loud. index.ts already warns every boot that there is
+ * no sign-in; what it cannot say, because it never reads an address, is that this one is carried
+ * beyond the machine. Whoever is on that network is an administrator here.
+ */
+ const shared = reachable.filter((value) => reachOf(value) === "private");
+ if (shared.length > 0) {
+ console.warn(
+ `OPENBOT_SINGLE_USER admits every request as one administrator with no sign-in, and this deployment answers on an address beyond this machine: ${shared.join(", ")}. Anybody on that network is that administrator. Configure a sign-in provider before anybody else is on it.`,
+ );
+ }
+
+ return true;
+}
+
+/**
+ * How far an address reaches, which is the question `OPENBOT_SINGLE_USER` actually turns on.
+ *
+ * Not two answers but three, because the middle one is most of the deployments this flag exists
+ * for. "No sign-in, one administrator" is a thing people run on a home server at `192.168.1.10`,
+ * over Tailscale at `100.something`, on a VPN, or at `openbot.local`. None of those is loopback and
+ * none of them is a stranger's to reach, so refusing them would refuse the feature's own audience
+ * while the operator's only recourse is to turn off the flag that describes what they are doing.
+ *
+ * A routable public address is the different thing, and it is the one that refuses.
+ *
+ * UNPARSEABLE COUNTS AS PUBLIC, and so does an unrecognised name. A value nobody could read is not
+ * a value anybody checked, and the safe reading of "I cannot tell" is never "it is fine".
+ */
+type Reach = "loopback" | "private" | "public";
+
+function reachOf(raw: string): Reach {
+ let bare: string;
+ try {
+ bare = new URL(raw).hostname.toLowerCase();
+ } catch {
+ return "public";
+ }
+ bare = bare.replace(/^\[|\]$/g, "").replace(/\.+$/, "");
+
+ if (
+ bare === "localhost" ||
+ bare === "::1" ||
+ bare === "0:0:0:0:0:0:0:1" ||
+ /^127\./.test(bare)
+ ) {
+ return "loopback";
+ }
+
+ if (bare.includes(":")) {
+ // fc00::/7 is the unique local range and fe80::/10 the link-local one. Both are unroutable on
+ // the public internet, which is the only property being asked about here.
+ return /^f[cd]/.test(bare) || /^fe[89ab]/.test(bare) ? "private" : "public";
+ }
+
+ const octets = bare.split(".");
+ if (octets.length === 4 && octets.every((part) => /^\d{1,3}$/.test(part))) {
+ const [a, b] = octets.map(Number) as [number, number, number, number];
+ const privateV4 =
+ a === 10 ||
+ (a === 172 && b >= 16 && b <= 31) ||
+ (a === 192 && b === 168) ||
+ // 169.254/16 is link-local, and 100.64/10 is the carrier-grade NAT range Tailscale hands out.
+ (a === 169 && b === 254) ||
+ (a === 100 && b >= 64 && b <= 127);
+ return privateV4 ? "private" : "public";
+ }
+
+ // A name rather than an address. `.local` is mDNS, `.internal` and `.home.arpa` are reserved for
+ // exactly this, and a single label with no dot at all is a LAN name that no public resolver
+ // answers. Anything else is a name somebody could look up.
+ const privateName =
+ !bare.includes(".") ||
+ bare.endsWith(".local") ||
+ bare.endsWith(".internal") ||
+ bare.endsWith(".lan") ||
+ bare.endsWith(".home.arpa");
+ return privateName ? "private" : "public";
+}
+
function url(environment: Environment, name: string): string | undefined {
const value = optional(environment, name);
if (!value) {
@@ -1143,9 +1267,14 @@ export function loadConfig(
oauth: { google },
auth,
...(organizationAuthUrl ? { organizationAuthUrl } : {}),
+ /*
+ * The authority short-circuits this, and that ordering is load-bearing: a white-label
+ * deployment naming an external authority lets it win, and `singleUserAllowed` is never
+ * reached and so cannot refuse a combination that already resolves.
+ */
singleUser:
!organizationAuthUrl &&
- singleUserEnabled(environment, configuredAuthProviders(auth).length > 0),
+ singleUserAllowed(environment, configuredAuthProviders(auth).length > 0),
accessibility: accessibilityEnabled(environment),
generativeUi: generativeUiEnabled(environment),
...(optional(environment, "APP_DIST_DIR")
diff --git a/server/tests/config.test.ts b/server/tests/config.test.ts
index de4d2686..34b2156e 100644
--- a/server/tests/config.test.ts
+++ b/server/tests/config.test.ts
@@ -518,6 +518,74 @@ describe("deployment configuration", () => {
);
});
+ // One administrator and no sign-in is a thing you run where only you can reach it. NOT gated on
+ // NODE_ENV: the image and the chart both set it to production for every deployment, the local
+ // trial included, so it says nothing about who can reach this.
+ test.each([
+ ["a public URL", { OPENBOT_PUBLIC_URL: "https://openbot.example.com" }],
+ ["an app URL", { OPENBOT_APP_URL: "https://openbot.example.com" }],
+ ["a trusted origin", { TRUSTED_ORIGINS: "https://openbot.example.com" }],
+ [
+ "one published origin among loopback ones",
+ { TRUSTED_ORIGINS: "http://localhost:3010,https://openbot.example.com" },
+ ],
+ ["an address that is not a URL at all", { OPENBOT_PUBLIC_URL: "openbot" }],
+ ])("refuses no sign-in combined with %s", (_label, published) => {
+ expect(() =>
+ loadConfig({ ...withoutSignIn, ...OPEN, ...published }),
+ ).toThrow("OPENBOT_SINGLE_USER");
+ });
+
+ /*
+ * THE DEPLOYMENTS THE FLAG EXISTS FOR, WHICH ARE NOT LOOPBACK. A home server, a Tailnet, a VPN
+ * address, an mDNS name: none of these is a stranger's to reach, and refusing them would refuse
+ * this feature's own audience. They are allowed and warned about, not refused.
+ */
+ test.each([
+ ["a home LAN address", { OPENBOT_PUBLIC_URL: "http://192.168.1.10:3001" }],
+ ["a 10/8 address", { OPENBOT_PUBLIC_URL: "http://10.0.0.5:3001" }],
+ ["a 172.16/12 address", { OPENBOT_PUBLIC_URL: "http://172.20.1.4:3001" }],
+ ["a Tailscale address", { OPENBOT_PUBLIC_URL: "http://100.101.102.103" }],
+ ["a unique-local IPv6 address", { OPENBOT_PUBLIC_URL: "http://[fd00::1]" }],
+ ["an mDNS name", { TRUSTED_ORIGINS: "http://openbot.local:3010" }],
+ ["a single-label LAN name", { TRUSTED_ORIGINS: "http://nas:3010" }],
+ ])("still runs with no sign-in on %s", (_label, reachable) => {
+ expect(() =>
+ loadConfig({ ...withoutSignIn, ...OPEN, ...reachable }),
+ ).not.toThrow();
+ });
+
+ // 172.32 is outside 172.16/12, and 100.128 is outside 100.64/10. The near miss is the case a
+ // hand-written range check gets wrong, so both are pinned as refused.
+ test.each([
+ ["just outside 172.16/12", { OPENBOT_PUBLIC_URL: "http://172.32.0.1" }],
+ ["just outside 100.64/10", { OPENBOT_PUBLIC_URL: "http://100.128.0.1" }],
+ ])("refuses no sign-in on %s", (_label, published) => {
+ expect(() =>
+ loadConfig({ ...withoutSignIn, ...OPEN, ...published }),
+ ).toThrow("OPENBOT_SINGLE_USER");
+ });
+
+ // The local workflow the flag exists for, and the two addresses the quick start hands out.
+ test.each([
+ {},
+ { TRUSTED_ORIGINS: "http://localhost:3010" },
+ { TRUSTED_ORIGINS: "http://127.0.0.1:3010,http://[::1]:3010" },
+ { OPENBOT_PUBLIC_URL: "http://127.0.0.1:3001" },
+ // The chart and the image both set this for every install; it must decide nothing. A real key
+ // comes with it because the gate beside this one refuses the example key under production, and
+ // this case is about sign-in rather than about that.
+ {
+ NODE_ENV: "production",
+ KEY_ENCRYPTION_KEY: productionEnvironment.KEY_ENCRYPTION_KEY,
+ TRUSTED_ORIGINS: "http://localhost:3010",
+ },
+ ])("still runs with no sign-in on loopback: %j", (loopback) => {
+ expect(() =>
+ loadConfig({ ...withoutSignIn, ...OPEN, ...loopback }),
+ ).not.toThrow();
+ });
+
test("is off, and lists nothing, when no provider is configured", () => {
const config = loadConfig({ ...withoutSignIn, ...OPEN });
diff --git a/server/tests/single-user.test.ts b/server/tests/single-user.test.ts
index 16eaebac..38d1c500 100644
--- a/server/tests/single-user.test.ts
+++ b/server/tests/single-user.test.ts
@@ -11,6 +11,12 @@ import { singleUserEnabled } from "../src/auth/dev-actor";
* outside. It now takes an explicit flag and refuses to start without one.
*
* The cases below are the four a deployment can actually be in.
+ *
+ * This function still reads only the flag, which is what these cases pin, and `NODE_ENV` still
+ * decides nothing here. Whether a deployment may HAVE no sign-in is a second question, asked by
+ * `singleUserAllowed` in config.ts, which refuses it on any address other people can reach. The old
+ * lock is not back: that one granted permission from a variable unset by default, and this one only
+ * ever adds a refusal.
*/
describe("running with no sign-in", () => {
test("a configured provider always wins, whatever else is set", () => {