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.

Say how a Bot's egress proxy reaches a computer on Kubernetes (#252)

beardthelion7fda66a7cd41
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a5550af0..7fa0f51f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -149,6 +149,13 @@ jobs:
# A browser inside every replica of a replicated API.
refuses "an embedded browser across several replicas" \
--set server.embeddedComputer=true --set server.replicaCount=2
+ # A Bot's egress proxy on a port the computer's own network policy does not allow. The
+ # variables reach the computer through extraEnv, so nothing else notices that the policy
+ # then refuses to let it be reached.
+ refuses "an egress proxy the network policy blocks" \
+ --set networkPolicy.enabled=true \
+ --set computers.extraEnv[0].name=EGRESS_PROXY_DEFAULT \
+ --set-string computers.extraEnv[0].value=http://proxy.internal:3128
test:
name: tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43d359ac..a7cced0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -66,6 +66,19 @@ the same clock the offer runs on, so a Bot cannot come back round as idle until
Nothing to configure, and the sweep already runs on a schedule. A deployment where each Bot has its
own computer stops paying for browsers that were used once.
+### A Bot's egress proxy is reachable on Kubernetes, or the install is refused
+
+The chart named no egress variable anywhere, so a Helm deployment read the per-Bot proxy settings
+nowhere and every Bot went out directly. They were always settable through `computers.extraEnv`,
+which reaches the computer in both the shared and the sandbox arrangement, but nothing in the chart
+or its README said so, and a setting whose whole purpose is to give a security team a per-Bot
+address is not one to leave undocumented.
+
+The other half is that setting it was not enough. A computer is allowed 80 and 443 to public
+addresses and nothing else, which is almost no proxies: they sit on a private address, or on 3128 or
+8080. So a proxy the network policy provably blocks is now refused at `helm install`, naming
+`networkPolicy.computerExtraEgress`, rather than found later as a Bot that fails on every page.
+Nothing changes for a deployment that sets no proxy, or one that already opened a path to it.
### A finished turn shows the page it opened, not the one open now
diff --git a/charts/openbot/README.md b/charts/openbot/README.md
index e783de07..b43a71c3 100644
--- a/charts/openbot/README.md
+++ b/charts/openbot/README.md
@@ -216,6 +216,32 @@ the policy on with an external database and no `networkPolicy.extraEgress` is re
enforcing cluster it would fence the API off from its own database, which reads as the database
being down.
+A Bot's computer is allowed 80 and 443 to public addresses and nothing else, which is what stops a
+browser reaching the cluster, the database, or the cloud's credential endpoint. A per-Bot egress
+proxy is therefore two settings rather than one: the variable that names it, and the rule that lets
+the computer reach it.
+
+```yaml
+computers:
+ extraEnv:
+ - name: EGRESS_PROXY_DEFAULT
+ value: http://proxy.internal:3128
+ - name: EGRESS_PROXY_SALES_BOT
+ value: http://sales.proxy.internal:3128
+networkPolicy:
+ computerExtraEgress:
+ - to:
+ - ipBlock:
+ cidr: 10.4.0.0/16
+ ports:
+ - port: 3128
+ protocol: TCP
+```
+
+`EGRESS_PROXY_DEFAULT` covers every Bot and `EGRESS_PROXY_<BOT>` names one, with the Bot's id
+upper-cased and anything unusual replaced. Naming a proxy the policy provably blocks is refused at
+install rather than found as a browser that fails on every page.
+
## Upgrades
Migrations run as a `pre-install,pre-upgrade` Job, so no replica ever serves in front of a schema it
diff --git a/charts/openbot/templates/validation.yaml b/charts/openbot/templates/validation.yaml
index 7f16e1b0..8d34c137 100644
--- a/charts/openbot/templates/validation.yaml
+++ b/charts/openbot/templates/validation.yaml
@@ -247,3 +247,31 @@ This template renders nothing.
{{- end }}
{{- end }}
{{- end }}
+
+{{- /*
+ A Bot's egress proxy, against the network policy that decides whether it can be reached.
+
+ `EGRESS_PROXY_DEFAULT` and `EGRESS_PROXY_<BOT>` are how a Bot gets a stable outbound address, and
+ on Kubernetes they arrive through `computers.extraEnv`. The computer's own policy allows 80 and
+ 443 to public addresses and nothing else, which is most of the internet and almost no proxies:
+ they sit on a private address, or on 3128 or 8080, or both. Setting one without opening a path to
+ it produces a Bot whose every page fails, which reads as a broken browser rather than as a network
+ rule, so it is refused here instead.
+
+ Only what the value provably shows: a port that is not 80 or 443, or a literal private address.
+ A private DNS name on 443 is blocked by the `ipBlock` rules just the same and cannot be told from
+ a public one at template time, so this misses that case rather than guessing at it. A proxy
+ supplied through `extraEnvFrom` is not readable here at all.
+*/}}
+{{- if and .Values.networkPolicy.enabled (not .Values.networkPolicy.computerExtraEgress) }}
+{{- range .Values.computers.extraEnv }}
+{{- if hasPrefix "EGRESS_PROXY" (.name | default "") }}
+{{- $value := .value | default "" | trim | trimSuffix "/" }}
+{{- $port := regexFind ":[0-9]+$" $value | trimPrefix ":" }}
+{{- $private := regexMatch "(^|//)(10\\.|127\\.|169\\.254\\.|192\\.168\\.|172\\.(1[6-9]|2[0-9]|3[01])\\.)" $value }}
+{{- if or (and $port (not (has $port (list "80" "443")))) $private }}
+{{- fail (printf "%s names a proxy the computer's network policy blocks, so every page a Bot opens would fail. Name it in networkPolicy.computerExtraEgress, or turn networkPolicy.enabled off." .name) }}
+{{- end }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/charts/openbot/values.yaml b/charts/openbot/values.yaml
index dbb42f81..65f98420 100644
--- a/charts/openbot/values.yaml
+++ b/charts/openbot/values.yaml
@@ -212,6 +212,11 @@ computers:
nodeSelector: {}
tolerations: []
+ # Free-form additions, and where a Bot's outbound address is set. `EGRESS_PROXY_DEFAULT` covers
+ # every Bot and `EGRESS_PROXY_<BOT>` names one, upper-cased with anything unusual replaced, so
+ # `sales-bot` reads `EGRESS_PROXY_SALES_BOT`. Both reach the computer whichever mode it runs in.
+ # With `networkPolicy.enabled` the proxy also has to be named in
+ # `networkPolicy.computerExtraEgress`, or the computer cannot reach it.
extraEnv: []
# `mode: sandbox` only. Where the per-Bot computers are created and what may create them.