Settings → Browser, the conversation's Browser dock (noVNC live view and
take-over) and the container's on-demand life move into the lab-chrome
live plugin (ai-agent-plugins). The core keeps the Chrome chip (the
harness capability chrome) and gains three generic hooks:
- sockets[] + aiAgentPlugin.openSocket(id): a frame's websocket, opened by
the host with the reader's cookies and relayed over postMessage to
WS /api/plugins/{pid}/sockets/{sid}, which bridges only to the declared
upstream (owner only, the gate's handshake rules, never the guest host;
operator approval). GET …/sockets/{sid}/probe → {up, open, lastActiveAt}
for the plugin's handlers.
- provides chrome.lab (plugins/chrome_bridge.py): {op: status} → the chip
default and whether guests' runs keep --chrome; {op: ensure} before a
lab --chrome run launches (spawn and resume).
- ui.slots[].size on app.modal (full = near full screen, frame filling it);
conversation.gizmos' update and hub/conversations rows carry chrome.
Gone: backend/chrome/, /api/chrome*, schemas/chrome.py, the SSE chrome
event, the lab.integrations permission, BrowserDock/BrowserSettings/store,
the Browser header button and eye switch, @novnc/novnc. /settings/browser
redirects to /settings/plugin/lab-chrome; carryover.chrome moves
/data/chrome.json into the plugin's config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
459 lines
34 KiB
Markdown
459 lines
34 KiB
Markdown
# Security — guests and rogue agents
|
||
|
||
*Who may do what — roles, scopes, the route table — is [permissions.md](permissions.md) since 2026-11-23.
|
||
Analysis of 2026-11-01, then the fixes it led to (Gabriel's calls in form
|
||
`ai-agent-security-what-to-build-now_yjndzg`; see [Built](#built-2026-11-01)
|
||
and [Left](#left)). It covers what protects the hub, the host and the
|
||
owner's data from two kinds of actors: a **guest** (one of `users.json`'s
|
||
people, or someone holding their session) and a **rogue coding agent**, meaning any
|
||
run that a prompt injection (a mail, a newsletter, a web page, a dependency's
|
||
README) or a plain mistake turns against the lab. Related:
|
||
[multi-user.md](multi-user.md) (the guest design and its "Left" list) and
|
||
CLAUDE.md → "Security: the trusted-caller gate".*
|
||
|
||
## The one-paragraph answer
|
||
|
||
The **API side is in good shape**. Guests reach a default-deny route list and
|
||
handlers filter by ownership and grant. Guest writes must be same-origin,
|
||
tokens are stored hashed, and the guest host never counts as the owner. The
|
||
**run side has no boundary**. A guest's run is `claude -p` as uid 1000 on the
|
||
host, and only its `Edit`/`Read` tools are confined; Bash is not. From Bash,
|
||
a guest run, or any injected owner run, can be the owner on the API
|
||
(`curl 127.0.0.1:8096`), read the owner's SSH key and tokens, use
|
||
`docker` (root), type into the owner's live sessions through their inbox
|
||
sockets, and reach every container on the docker networks directly, without
|
||
Traefik or Authelia. Everything below the API is "prompt-level trust", as
|
||
multi-user.md says. That was an accepted trade-off for three trusted guests.
|
||
It does not hold up against an injected agent.
|
||
|
||
## Threat model
|
||
|
||
| actor | how it gets in | what it wants / could do |
|
||
|---|---|---|
|
||
| guest (honest) | its own session on `claude.lab` | a mistake in a project that isn't theirs, an expensive runaway run |
|
||
| guest (curious / compromised account) | a stolen magic link or session cookie, a reused mailbox | read the owner's conversations, secrets and other guests' projects; become owner |
|
||
| injected guest run | a page, package or file the guest's agent reads | the same as the guest's account plus everything Bash reaches on the host |
|
||
| injected owner run | mail (`mail-agent`, `check-mail`), newsletters (`radar`), feeds (`veille-pharma`, `lab-digest`), the web (`page-scrape`, Chrome), release notes (`container-updates`), a dependency | anything uid 1000 can do: persistence (hooks, rc files, units), exfiltration (tokens, SSH key), destruction (force push, `rm -rf`), lateral moves (docker, raspy2) |
|
||
| another process on the host | the 10 host-network containers (Home Assistant, phone, glances, comfy-proxy, agent-monitor…) | the owner on `:8096` (loopback is trusted) |
|
||
|
||
## What protects what today
|
||
|
||
### The API gate (`core/auth.py`, `users/caller.py`)
|
||
|
||
- **Holds**: a guest session decides the request outright: only
|
||
`GUEST_ROUTES` (default deny), and mutations must be same-origin. The guest
|
||
host (`GUEST_HOSTS`) is never the owner and anonymous requests may only log in. Session and
|
||
link tokens are hashed. Read-only API keys are downgraded before the IP check.
|
||
Uploaded HTML/SVG is served `nosniff` + `attachment`.
|
||
- **Gap: loopback and the docker gateway are the owner, unconditionally.** That means
|
||
every uid-1000 process (including guest and injected runs) and every
|
||
host-network container is the owner.
|
||
Verified 2026-11-01: `docker exec glances … wget 127.0.0.1:8096/api/users`
|
||
returns the owner-only user list. A `POST /api/spawn` from any of them is
|
||
host code execution.
|
||
- Route-by-route findings: see [API audit](#api-audit-guest-routes) below.
|
||
|
||
### The run (`sidecar/launch.py` scope, `users/runs.py`)
|
||
|
||
A guest run gets `--permission-mode dontAsk` with `Edit` allowed only under
|
||
its projects and `/tmp`, and `Read` denied on `DENY_READ` and on the hub's uploads store
|
||
(everyone's attachments); its own attachments are hard-linked into
|
||
`data/guest-uploads/<guest>/`, the one folder outside them it may `Read` (`readDirs`,
|
||
`runs/attachments.py`). It also gets an appended system prompt,
|
||
no remote control, a git author and the shared-skills plugin. What that does
|
||
**not** cover:
|
||
|
||
| gap | evidence | consequence |
|
||
|---|---|---|
|
||
| Bash is unconfined: `GUEST_SANDBOX=0`, and `bwrap`/`socat` are not installed | `which bwrap socat` → nothing | everything below |
|
||
| `DENY_READ` stops the Read tool and plain `cat`, not `python3 -c open(…)`, `cp`, `base64`, `tar` | Claude Code's Bash read check is a command parser, not a boundary | `~/.ssh/id_ed25519` (unencrypted), `~/.config/homelab-gitea*-token`, `~/homelab/.env*`, `~/.claude/.credentials.json` are readable |
|
||
| loopback = owner | see above | `curl 127.0.0.1:8096/api/spawn` → an unscoped bypass-permissions run in `~/homelab` |
|
||
| `/proc/<sidecar>/environ` readable by the same uid | the sidecar strips `SIDECAR_TOKEN` from the run env, but its own process still has it | the token is one `cat` away → `/spawn` on the sidecar directly |
|
||
| the run's env still carries `SSH_AUTH_SOCK`, `DBUS_SESSION_BUS_ADDRESS`, `XDG_RUNTIME_DIR` | sidecar `/proc/…/environ` | the SSH agent, the user's D-Bus and systemd |
|
||
| uid 1000 is in `docker` | `id` | `docker run -v /:/host` = root on the host |
|
||
| inbox sockets accept peers (`crossSessionInbound: accept`) | every sidecar run sets it | one JSON line into an owner's live run's socket = a turn in a bypass-permissions session |
|
||
| a guest's message into a **live owner run** goes through its inbox | `runs/service.py` → sidecar `/message`, before any scope applies | it runs with the owner's permissions until the run relaunches (multi-user.md "Left") |
|
||
| shared skills run with the owner's secrets | `screenshot` logs into Authelia with the `claude` account (`.env.claude`) | a guest can screenshot any `*.lab` page: the admin ai-agent, files, Home Assistant… |
|
||
| the host routes to every docker network | docker bridges | Prometheus, Loki, databases and internal APIs answer without Traefik/Authelia |
|
||
| no per-run spend cap | no `--max-budget-usd`; the budget is checked at spawn only | one runaway run can blow a month's budget |
|
||
|
||
### The owner's own runs
|
||
|
||
`--permission-mode bypassPermissions`, the full host environment, no
|
||
permission rules, and no hook beyond `rtk`. Several scheduled agents read
|
||
untrusted text daily (radar, veille-pharma, lab-digest, mail-secretary,
|
||
container-updates, mail-agent). mail-agent fences the mail and asks before
|
||
acting for non-owners; the others rely on the model alone. Nothing records or
|
||
blocks a destructive or persistence-shaped command, and nothing alerts when one runs.
|
||
|
||
### Visibility
|
||
|
||
There is no security log. Guest logins, link requests, guest spawns, owner-API
|
||
calls from non-browser callers and denied tool calls are only in scattered
|
||
logs and transcripts. There is no kill switch beyond disabling guests one by
|
||
one.
|
||
|
||
## API audit (guest routes)
|
||
|
||
A route-by-route read of every `GUEST_ROUTES` entry and the gate, with live
|
||
probes limited to harmless GETs.
|
||
|
||
| # | finding | severity | status |
|
||
|---|---|---|---|
|
||
| 1 | `Host: claude.lab.gabvdl.xyz.` (trailing dot) matched Traefik's guest router (no Authelia) but not `GUEST_HOSTS`. From Traefik's IP the request was the **owner**, so anyone on the internet could call `/api/spawn`. Confirmed live on :443, :8443 and through raspy2 | **critical** | fixed + deployed 19:46 (`5a778f3`): the host is normalised, and through Traefik only Authelia's `Remote-User` makes the owner. Loki holds the error log back to 10 Oct: no trailing-dot request until the fix (200s aren't logged, so not fully ruled out) |
|
||
| 2 | guest Bash is a shell on the host (see the run table) | high | quick fixes below; boundary = the sandbox |
|
||
| 3 | `diff-blob` served any working-tree file (a project's `.env`) to a view-level guest; without a project `.git` it fell back to the superproject | medium | fixed: guests get images inside their project that git doesn't ignore |
|
||
| 4 | the diff tabs took their repos from the transcript: echoing an owner worktree's name put its live diff in a guest's Changes tab | medium | fixed: granted projects only, never the superproject |
|
||
| 5 | a participant's turns don't count against their budget; a resume without a model kept the session's (maybe not allowed); a fork of a Mac-worker conversation skipped every guest check | low | the last two fixed; budget-per-author left |
|
||
| 6 | `/api/upload-file` checks no ownership (unguessable 48-bit batch id); no upload quota | low | left |
|
||
| 7 | the `aia_session` cookie can be planted from a guest site on `*.gabvdl.xyz` (`Domain=.gabvdl.xyz`) | low | fixed on the admin host (a guest cookie counts only on the guest host or as an impersonation); `__Host-` prefix left |
|
||
| 8 | ~40 concurrent long-polls (`forms/<id>?waitSecs=55`) hold the sync thread pool | low | left |
|
||
| 9 | `request-link`: per-user cooldown only; sessions slide 30 days with no cap; display names with newlines reach the system prompt | low | a global hourly cap (`LINK_MAILS_PER_HOUR`, 30) and one-line names fixed; absolute session cap left |
|
||
| — | a guest's text could carry a forged `<ai-agent-from user="owner"…/>` line | low | fixed: neutralised in a guest's own text |
|
||
|
||
Correctly protected, checked:
|
||
- the conversation reads and lists (ownership on the session id, path
|
||
traversal and symlinks refused);
|
||
- spawn/resume/interrupt/fork pinning;
|
||
- sharing (owner-only, grant-checked);
|
||
- forms, asks and notifications (audience);
|
||
- the SSE filter (unknown types dropped);
|
||
- `ui-state` namespacing and PUT `/api/me` (name and channels only);
|
||
- project assets;
|
||
- the login (256-bit hashed tokens, single-use 15-min links, rotated
|
||
sessions, HttpOnly + Lax + Secure host-only cookies, 4 h impersonation).
|
||
|
||
## Proposals (as analysed — see Built / Left for where each went)
|
||
|
||
Ordered by value for the effort. **S** = hours, **M** = a day, **L** = several.
|
||
|
||
### A. A real boundary for guest runs
|
||
|
||
1. **Sandbox guest Bash** (M): install `bubblewrap` + `socat` and turn on
|
||
`GUEST_SANDBOX`. Then extend the scope's `sandbox` block:
|
||
`filesystem.denyRead` (home minus the granted projects, toolchains and
|
||
caches), `network.allowedDomains` (registries, GitHub, Gitea; no localhost,
|
||
no LAN), and Unix sockets blocked (that is the Linux default). This one change closes
|
||
loopback-as-owner, the SSH key, docker, inbox injection, the sidecar token
|
||
in `/proc` and lateral moves, for guests.
|
||
2. **Deploy and push without the owner's keys** (M): the sandbox removes the
|
||
SSH key and the Gitea token, so guests need a narrow way out.
|
||
- push: the guest's own Gitea account (it exists already) gets a token that
|
||
reaches only their repos, handed to their runs;
|
||
- deploy: a broker in the hub runs `zipgo deploy <project>/dist <host>`
|
||
with the host from the project's registration, never from the guest's
|
||
files, refusing symlinks that leave `dist/`.
|
||
3. **Quick fixes** (S each):
|
||
- a guest message into a live **unscoped** run is not delivered through
|
||
its inbox; it waits for that run to end, or relaunches with the guest's scope;
|
||
- scoped runs lose `SSH_AUTH_SOCK`, `DBUS_SESSION_BUS_ADDRESS`, `XDG_RUNTIME_DIR`;
|
||
- `--max-budget-usd` = what is left of the guest's month, plus a live-runs
|
||
cap per guest;
|
||
- shared skills get a guest mode: `screenshot` never logs into Authelia for
|
||
a guest run.
|
||
|
||
### B. The gate: loopback is not a credential
|
||
|
||
4. **Tokens instead of "came from the host"** (M): every host caller (the
|
||
CLI, skills, HA, the phone) presents a token. The default is a 0600
|
||
`~/.config/ai-agent/token` read by the CLI. Scoped tokens cover the rest
|
||
(answer-only for HA, read-only for the phone). Roll out in **audit mode**: log
|
||
every tokenless loopback mutation for a week, then refuse it.
|
||
5. **Per-run identity** (S, after 4): each run gets its own token (from the
|
||
session id). The hub then knows which conversation called it, and a guest
|
||
run's calls act as the guest.
|
||
|
||
### C. Rogue agents
|
||
|
||
6. **A guard hook on every run** (M): `PreToolUse` on Bash/Edit/Write, with
|
||
curated rules:
|
||
- persistence: `~/.claude/settings*`, hooks, shell rc files, systemd/cron,
|
||
`authorized_keys`, git hooks;
|
||
- destruction: `rm -rf` of the home or a repo root, force-push or delete
|
||
of `main`;
|
||
- exfiltration: a credential path and a network tool in one command;
|
||
- docker escapes: `--privileged`, `-v /:`, the docker socket mounted.
|
||
Blocks for guests and untrusted-input agents, log + push for the owner.
|
||
A pattern list is not a boundary, but it catches accidents and naive
|
||
injected payloads, and it writes the evidence.
|
||
7. **Scoped cron agents** (S, after 1): a `scope:` key in an agent's
|
||
frontmatter gives the guest scope's machinery to radar, veille-pharma,
|
||
lab-digest and mail-secretary. They read the internet and only need
|
||
their data dir and the mail CLI.
|
||
8. **Honeytokens** (S): canary credentials where a thief looks first (a fake
|
||
AWS key, a fake `.env` token). Their use pushes the owner.
|
||
|
||
### D. See and stop
|
||
|
||
9. **Settings → Security** (M): one log (`/data/security-log.jsonl`) covering
|
||
guest logins and link requests (IP, UA), guest spawns, guard-hook hits,
|
||
sandbox denials and tokenless loopback mutations, with filters. Plus
|
||
**Lock guests** (sessions dropped, logins refused, their live runs
|
||
interrupted) and **Stop every run**, also as a push action.
|
||
10. **Guest sessions** (S): their devices, last seen and *revoke*, on their page.
|
||
|
||
## Built (2026-11-01)
|
||
|
||
Gabriel's picks: quick fixes, the guest sandbox, the Security page and the
|
||
guard hook. Owner runs that trip the guard are **allowed but logged and
|
||
pushed**. Guest push uses **their own Gitea token**. Guest deploy goes
|
||
through a **hub broker** with no approval step. Network: an
|
||
**allowlist**, checked against what guest conversations reached.
|
||
|
||
- **Gate** (`core/auth.py`): through Traefik, the owner is whoever Authelia
|
||
vouched for (`Remote-User`), never "came from Traefik". Anything else is
|
||
anonymous and logged as `edge_anonymous`, which pushes by default.
|
||
- **Run isolation** (`runs/service.py`): every launch stamps `meta.runAs`. A
|
||
guest's turn into a live run that wasn't launched for them gets
|
||
`409 run_busy`; it never goes through the inbox with the owner's
|
||
permissions, and never stops the owner's run.
|
||
- **Scoped run env** (sidecar `SCOPED_ENV_STRIP`): no SSH agent, D-Bus or
|
||
`XDG_RUNTIME_DIR`. Each run sets `AIA_GUEST=<id>`, and the shared
|
||
`screenshot` / `page-scrape` skills then refuse Authelia and `*.lab` /
|
||
`*.test` / internal hosts (homelab `0874456`).
|
||
- **Spend**: each guest run on the owner's account is capped at what is left
|
||
of the month (`--max-budget-usd`, scope `maxBudgetUsd`). At most
|
||
`GUEST_MAX_LIVE_RUNS` (3) runs at once.
|
||
- **Git as the guest** (sidecar `guest_git.py`): a scoped run's Gitea
|
||
credential helpers are reset through `GIT_CONFIG_COUNT`, so it never gets
|
||
the owner's token.
|
||
- A `ship`-level run gets the guest's own `write:repository` token.
|
||
It is minted once and kept 0600 on the host
|
||
(`~/.config/ai-agent/guest-gitea/`); the hub never sees it.
|
||
- The guest becomes a write collaborator on shipped repos in the owner's
|
||
namespace.
|
||
- Chat level gets no credential at all, so "commit but don't push" is
|
||
enforced now.
|
||
- **Deploy broker** (the `ship` live plugin since 2026-11-26, in
|
||
`ai-agent-plugins`; hub bridge `ship.run` in `plugins/hubbridge.py`,
|
||
sidecar `ship.py`):
|
||
- a guest's run calls the plugin's `ship-deploy [host]` skill script, which
|
||
runs its `deploy` action (`runAs: "owner"`, the guest in
|
||
`AIA_USER_CONTEXT.requester` — the session id is the one the hub vouched
|
||
for).
|
||
- The plugin needs the guest active with `ship` on the project (`users.read`;
|
||
else a `guard_block` event), and a host from the owner's per-project list
|
||
(the plugin's `deploy-hosts.json`, carried over from
|
||
`/data/deploy-hosts.json`) or one label under the guest's own namespace.
|
||
Any other host asks the owner (an Approvals decision, *Also add host to
|
||
project allowlist* ticked); a guest's deploy never seeds the list from the
|
||
project's own deploy config.
|
||
- The sidecar runs a fixed `zipgo deploy <project>/<dist>/ -d <host>`,
|
||
refusing a tree that links out of the project; the hub writes the
|
||
`ship_deploy` event naming the guest. No guest code runs outside the
|
||
sandbox.
|
||
- With `GUEST_SANDBOX=1` the sandbox can't reach the hub, so the skill script
|
||
(like every plugin skill) needs a bridge before the sandbox goes on.
|
||
- **Guard hook** (sidecar `guard.py`, PreToolUse on every run):
|
||
- rule families: persistence, destructive, exfil, docker escapes, plus the
|
||
guest family on scoped runs;
|
||
- it blocks a guest's hits and reports an owner run's;
|
||
- it also reads sandbox denials after a sandboxed Bash call.
|
||
- Replayed over a week: 10,326 owner commands gave about 5 hits, all worth a
|
||
push. 1,099 guest commands gave 3 blocks: docker, and ssh to raspy2 for
|
||
sherlock's PocketBase.
|
||
- **Security log + Settings → Security** (`backend/security/`):
|
||
- `/data/security-log.jsonl` records guest sign-ins (IP + UA), new devices,
|
||
link requests, guest runs, guard hits, sandbox denials and bursts,
|
||
edge probes, ship deploys and the owner's actions;
|
||
- push picks per kind;
|
||
- **Lock guests** drops every session, refuses sign-in and interrupts their
|
||
runs;
|
||
- **Stop every run** covers the lab and online workers.
|
||
|
||
## The sandbox, probed (2026-11-01, bwrap 0.12)
|
||
|
||
A real `claude -p` run with the guest scope's sandbox block (`sidecar/launch.py`
|
||
`sandbox_settings`) ran a probe script:
|
||
|
||
| from a sandboxed Bash call | result |
|
||
|---|---|
|
||
| `~/.ssh/id_ed25519`, `~/homelab/.env`, `~/.claude/.credentials.json`, another project | **invisible** (`denyRead ~` mounts an empty home; writes there are throwaway) |
|
||
| `/proc/<sidecar pid>/environ` | **invisible** (own pid namespace) |
|
||
| hub `127.0.0.1:8096`, sidecar `172.17.0.1:8790`, a container IP, `*.lab` | **refused** |
|
||
| docker socket, `ssh raspy2` | **refused** |
|
||
| `https://example.com` (not listed) | **refused** (`user denied`) |
|
||
| `git.gabvdl.xyz` (listed) | **refused** — "resolved to one of this host's addresses": the sandbox never lets a command reach this host, allowlist or not |
|
||
| node (mise), `npm i` from registry.npmjs.org, GitHub | **work** (don't map `~/.npm` read-only: npm then fails on its cache) |
|
||
| a hook (the guard) | runs **outside** the sandbox — the way out for brokered actions |
|
||
|
||
Live end-to-end on the deployed hub, as `gabtest` (impersonated, Haiku):
|
||
- `git push --dry-run` went out as gabtest to `gabtest/crew-corner`;
|
||
- `docker ps` was blocked by the guard (`guard_block` logged and pushed);
|
||
- `SSH_AUTH_SOCK` was absent.
|
||
|
||
## Guests' own computers (2026-11-02)
|
||
|
||
A guest can pair a computer of their own as a worker (`users/computers.py`,
|
||
`workers/link.py`, `workers/guests.py`, `claudeproxy/limits.py`; decisions in
|
||
the homelab `data/log/2026-11-02-guest-workers.md`, forms
|
||
`guest-workers-guests-own-computers_q9ztmc`,
|
||
`guests-own-computers-screens-and-flows_9twu29`,
|
||
`guest-computers-security-hardening_0n6okr`). The win: their runs never touch
|
||
this host. The trust shape is two-way — the computer runs whatever the hub
|
||
sends it, and the hub bills the owner's plan for whatever the computer's
|
||
proxy token sends — so each side is held:
|
||
|
||
| threat | held by |
|
||
|---|---|
|
||
| the **proxy token** is an API key on the guest's disk | the owner's default account only; their model families; every call metered into a ledger (`/data/proxy-ledger/<YYYY-MM>.jsonl`) and held to the same monthly budget as their lab runs; paused while the owner's plan is past 80 % (5 h) / 85 % (week); 10 calls in flight per computer, 60 a minute per guest; only `v1/messages` + `count_tokens`, no fast mode, no 1M-context beta; refused at once when the guest is disabled, *Lock guests* is on, the computer is paused or removed; rotated weekly (the old one works an hour) |
|
||
| the **public host** | `/proxy/` there takes guest computers' tokens only (the owner's workers stay on the tailnet); `/worker-link/*` + `/proxy/claude/*` have their own Traefik router with a per-IP rate limit; 20 bad tokens or codes from one address in 10 min lock it for an hour (`ip_locked`) |
|
||
| a **stolen link token** poses as the computer | the hub names the worker (never the machine), so it can't take an owner worker's id; a fake computer only reaches that guest's own sessions; rotated weekly |
|
||
| the **hub running code on the guest's machine** | only the guest's own runs go there — the owner's composer, cron and profiles can't pin it, the owner can't continue or fork those conversations; each run is confined to the start folder (edits there + `/tmp`, `dontAsk`); the guest can **pause** it; the add dialog and the installer say what the hub can see |
|
||
| **hostile transcripts / outbox** | only sessions the hub started there are mirrored (`meta.worker`), never an id the meta store places elsewhere; outbox items must name one of its sessions; 500 MB a month per computer; replies ≤ 64 MB |
|
||
| what **reaches** the machine | lab sync = the guests' shared skills only; no owner agents; nothing in its `~/.claude/settings.json` |
|
||
|
||
Refusals land in the Security log (`guest_proxy_refused`, once per computer
|
||
and kind per 10 min); budget and plan refusals push the owner once a day.
|
||
Left: the guest computer's guard/sandbox events stay on it; terms — guests
|
||
bill the owner's personal Max seat (his call).
|
||
|
||
## A guest's `ai-agent` CLI (2026-11-02)
|
||
|
||
Guests' runs may drive the hub with the CLI, as the guest (`users/cli.py`,
|
||
sidecar `guard.py` broker; form `guests-and-the-ai-agent-cli_a601cw`:
|
||
per-guest switch, default off). The CLI is the owner on loopback, so a
|
||
guest's run never runs it itself:
|
||
|
||
| threat | held by |
|
||
|---|---|
|
||
| the guest's run calls the hub as the owner | the guard runs a plain `ai-agent …` for it, from its argv in a clean env (`cwd /`, `python -I`); every other spelling (`env X=1 ai-agent`, `sh -c '…'`, `ai_agent.py`, a pipe or `&&`) is a `guest.ai-agent` block — a pattern list until the sandbox is on |
|
||
| the broker run is the owner | the CLI then sends `X-AIA-As-Session`; the gate makes it the guest of that session's `meta.runAs`, and refuses an unknown session — it never falls back to the owner. The broker refuses to run without a session id |
|
||
| the header from elsewhere | read only on a call that is already the owner (trusted peer or internal token): naming a session can only lose rights |
|
||
| what the guest reaches | `CLI_ROUTES` (conversations, spawn/resume/fork/interrupt, title/archive of their own, their forms/asks, projects/models/`/api/me`), filtered by the same ownership checks as their browser; the CLI refuses every other command before calling |
|
||
| fan-out and spend | children of the calling run only, the owner's depth/children limits, `GUEST_MAX_LIVE_RUNS`, the usual budget and models; no owner push per child |
|
||
| the broker as a file-read primitive | no file arguments in the guest commands (no `--body-file`, no prompt file); `.env.claude` isn't loaded |
|
||
|
||
## Second pass (2026-11-15)
|
||
|
||
A second audit, two weeks and several surfaces later (the MCP server, the
|
||
tool proxy, guests' computers and their forms, the "No project" chat). Six
|
||
read-only reviews, then the fixes; Gabriel's calls in form
|
||
`ai-agent-security-pass-5-decisions_935s43`. The full findings table, with
|
||
what was reproduced and what was only traced, is in the homelab's
|
||
`data/log/2026-11-15-ai-agent-security-audit.md`.
|
||
|
||
### What was wrong
|
||
|
||
| # | severity | finding | fix |
|
||
|---|---|---|---|
|
||
| G1 | critical | **A page on any `*.gabvdl.xyz` site could act as the owner.** The gate checked `Origin` for guests only. Authelia's cookie is `Domain=lab.gabvdl.xyz; SameSite=Lax`, a guest's site is same-*site* with the admin host, and FastAPI 0.115 read a body with no `Content-Type` as JSON — so `fetch(…/api/spawn, {mode: "no-cors", credentials: "include", body: new Blob([json])})` needed no preflight and started an owner run | the gate refuses every caller's state-changing request from another origin (`Origin`, `Sec-Fetch-Site`), and a browser's body with no `Content-Type`; refusals are the `cross_site` kind in the Security log, pushed by default |
|
||
| G2 | high | **`Host: x?` walked a docker-network peer past the gate**: it matched on `request.url.path`, which Starlette 0.46 rebuilt from the Host header. 76 routes rely on the gate alone | the gate reads the path the router matches (`scope["path"]`); FastAPI 0.163 / Starlette 1.x |
|
||
| G3 | high | the lab browser's websocket (`/api/chrome/ws`) checked neither `Origin` nor the Authelia user | same-origin only, and the owner's Authelia user (since 2026-11-26 the same check guards every plugin websocket, `plugins/sockets.py` — the lab browser became the `lab-chrome` plugin) |
|
||
| G4 | medium | any Authelia user was the owner — the password-only `claude` bot included | `OWNER_USERS` / `READONLY_USERS` (below) |
|
||
| M1 | high | **MCP: a tap on an unsolicited push gave an anonymous caller an owner token** — anyone could park a request named "Claude" with the real callback, ask for the phone approval and poll for the code | number matching (below); per-address caps on registrations, requests and pushes |
|
||
| M2 | high | MCP: `https://evil.example\@claude.ai/cb` was `claude.ai` to Python and `evil.example` to the browser | redirect URIs: no backslash, userinfo, whitespace or upper case, and they must survive a parse round trip |
|
||
| A1 | high | **Web Push endpoints were any `https://` URL**; a 307 from one re-POSTed inside the container to `127.0.0.1:8080`, where the hub is the owner (fire a cron job, sign the owner's Claude out) | push services only (FCM, Mozilla, Apple, Windows), no redirects followed, only a status back |
|
||
| A2 | high | **a guest's computer could plant ask-form records** for any session, with any link; the link was framed in the admin app with `allow-scripts allow-same-origin`, and `javascript:` there ran on the admin origin | a guest computer's forms must belong to its own sessions; links are https with the form's own id; `embedOrigins` from a guest machine is ignored; the frame refuses same-origin and non-http(s) links |
|
||
| A3 | high | `/api/diff-blob` served a project's SVG inline on the app origin | `Content-Security-Policy: sandbox` on every blob |
|
||
| S1 | high | **`3d-render` read any host file** named by a glTF's external `uri` (a texture, or bytes as vertex colours) — reachable with a tools token on the public host | uploads may only carry `data:` URIs |
|
||
| S2 | high | **`Monitor` ran shell commands the guard never saw**: the owner CLI, docker, ssh from a guest's run | `Monitor` goes through the guard like `Bash` |
|
||
| A4 | medium | a form's HTML block could make the app fetch any `/api/…` URL with the viewer's cookies and hand it to the block's script | only the asset routes, only media types |
|
||
| A5 | medium | the "No project" chat gave every guest a run with Bash | a per-guest switch (below) |
|
||
| S3 | medium | video-extract fetched any URL from the lab (loopback, containers, the LAN) | public addresses only |
|
||
| S4 | medium | guest runs: the owner CLI / docker / ssh rules fell to ordinary spellings; the guard failed open on an exception; chat level still had the owner's `gitea.lab` and `github.com` credential helpers | the CLI refuses under `AIA_GUEST`; the guard fails closed (a guard that can't start refuses too); scoped runs get a git config of their own |
|
||
| S5 | medium | a guest project's `.claude/settings.json` and `.mcp.json` loaded in their runs (hooks and env outside any sandbox); the hub's and the sidecar's `git` honoured `core.fsmonitor`, filters and textconv of a guest's repo; the ship broker followed a project `.zipgo.json` | scoped runs ignore project settings (below); git runs with those off; the broker ships a checked copy |
|
||
| M3, M4, A6–A8, S6, P1 | low–medium | MCP approve/collect race and token lifecycle, the public `/openapi.json`, an unbounded `/share`, no ceiling on wrong sign-in codes, unbounded guest bodies, a transcript rewriting a form's link, the lean allowlist missing `&` and `<( )`, tokens in argv | fixed; see the log file |
|
||
|
||
### What it changed
|
||
|
||
- **The gate** (`core/auth.py`, `test_gate.py`). In order: a state-changing
|
||
request a browser sent from another origin is refused whoever it is for;
|
||
a guest session decides the rest; through Traefik the caller is what
|
||
`edge_role` says of its Authelia user — `OWNER_USERS` are the owner,
|
||
`READONLY_USERS` read and never write, anyone else is anonymous (both
|
||
unset: any Authelia user is the owner, as in a standalone install). The
|
||
homelab sets `gabrielvidal` and `claude`. A guest's body is declared and
|
||
≤ 4 MB (an upload batch 500 MB), an anonymous one ≤ 64 KB. Host callers
|
||
(the CLI, hooks, Home Assistant) send no `Origin` and are unchanged —
|
||
loopback is still the owner.
|
||
- **MCP approval by phone is number matching** (`mcpserver/`): the consent
|
||
page shows a two-digit number, the push offers three; only that number
|
||
approves, anything else refuses and closes the request. The access (full /
|
||
read only) is picked on the page. Approving and collecting the code is one
|
||
step under one lock.
|
||
- **"No project" chats** (`users.json` `scratchBash`, Settings → Users →
|
||
<guest> → Access): on by default — Gabriel's call. Off, the run is launched
|
||
without `Bash` and `Monitor` (`scope.noBash`). With it on, a guest with no
|
||
project still has a shell on the lab until the sandbox is.
|
||
- **Scoped lab runs ignore the project's own Claude configuration**
|
||
(`sidecar/launch.py`): `--setting-sources user --strict-mcp-config`, hooks
|
||
started with `python -I`, Edit denied on `.claude/settings*.json` and
|
||
`.mcp.json`. That flag also drops the project's `CLAUDE.md`, so the sidecar
|
||
appends it to the system prompt as plain text (60 KB, no `@` imports).
|
||
Project-level skills and agents no longer load in a guest's lab run. Not on
|
||
a guest's own computer, where the project settings are theirs.
|
||
- **Guest git**: a scoped run's `GIT_CONFIG_GLOBAL` is a sidecar-written file
|
||
with the committer identity only, so no owner credential helper is in
|
||
reach. A guest's push to a `github.com` remote, which used to go out on the
|
||
owner's `gh` login, now fails.
|
||
- **A Content-Security-Policy on the app shell** (`main.py`): `script-src
|
||
'self'` plus the hash of the theme bootstrap, `object-src 'none'`,
|
||
`base-uri 'self'`, `frame-ancestors 'self'`. Local-scheme documents inherit
|
||
their embedder's policy, so sandboxed form HTML no longer travels as
|
||
`srcdoc` / `blob:`: it is written into `/sandbox-frame.html`, a static page
|
||
served with `Content-Security-Policy: sandbox …` that refuses to run unless
|
||
its origin is opaque.
|
||
- **Dependencies**: FastAPI 0.163, Starlette 1.x (startup became a lifespan,
|
||
in the hub and the sidecar), Pillow 12+, `npm audit fix`.
|
||
|
||
### Still open after it
|
||
|
||
- Everything under [Left](#left) that is not struck below — first of all
|
||
the sandbox and loopback = owner. This pass closed the two ways a *hub-side*
|
||
request reached loopback (Web Push, video-extract), not the trust itself.
|
||
- `env -u AIA_GUEST ai-agent …` and reading a token file from Bash still
|
||
work in a guest's run until the sandbox is on; a hook killed by Claude
|
||
Code's own timeout lets its call through.
|
||
- Outside this repo: `3d-render`'s own `read_uri`, `tea-cli` /
|
||
`commit-project` under `AIA_GUEST`, and `chrome.lab.gabvdl.xyz`'s
|
||
websockify (the same hole as G3, behind Authelia, in the homelab).
|
||
- A new MCP connection raises no push unless `mcp_connected` is ticked in
|
||
Settings → Security.
|
||
- The image proxy resolves a host twice (rebinding); two `react-router`
|
||
advisories need the 7.x major.
|
||
|
||
## Left
|
||
|
||
- **Turning the sandbox on** (`GUEST_SANDBOX=1` in the homelab compose).
|
||
The sandbox works, but nothing on this host is reachable from inside it, so
|
||
every lab-side thing a guest run does needs a **bridge through the guard
|
||
hook**, the way the `ai-agent` CLI broker works (and the plugin skills —
|
||
`ship-deploy` included — call `AIA_TOOLS_URL` on the hub, which the sandbox
|
||
refuses):
|
||
- `notify-done` / `notify ask` / `ask-form` (the hub on loopback). Run the
|
||
CLI from the hook on an exact, metacharacter-free command line and hand
|
||
back its output. Don't use Claude Code's `excludedCommands`: whether it
|
||
also lets `notify …; curl …` out unsandboxed is unverified.
|
||
- `git push` / `pull` to Gitea. A governed push from the hook or sidecar,
|
||
with the guest's token:
|
||
- an explicit `https://git.gabvdl.xyz/<owner>/<repo>` URL;
|
||
- `core.hooksPath=/dev/null`, `credential.helper` reset,
|
||
`protocol.allow=never` + `https`, `push.gpgSign=false`;
|
||
- refuse when the repo's local config has `url.*`, `include*`, `http.*`,
|
||
`credential.*`, `core.sshCommand`/`fsmonitor`/`askPass`, or anything
|
||
outside an allowlist (`insteadOf` could send the token elsewhere).
|
||
- `@gabvdl/*` installs from Verdaccio (`127.0.0.1:4873`): an
|
||
`npm ci --ignore-scripts` run outside the sandbox by the hook, or
|
||
projects keep a committed lockfile and installed `node_modules`.
|
||
- `screenshot` of a dev server: the browser gateway is a lab container and
|
||
the dev server lives in the sandbox's own network namespace, so neither
|
||
sees the other. Options: a headless browser inside the sandbox, or the
|
||
hook screenshots a deployed preview instead.
|
||
- PocketBase deploys (sherlock's `deploy:pocketbase` is ssh to raspy2): a
|
||
broker step of their own.
|
||
|
||
Then add the guest's root domain to `sandboxDomains` (today only
|
||
`SIDECAR_SANDBOX_DOMAINS`) and flip `GUEST_SANDBOX`.
|
||
- Loopback ≠ owner: **audit mode since 2026-11-23** — host callers send the
|
||
host token, the ones that don't are logged `loopback_tokenless`; refuse them
|
||
once that list is empty ([permissions.md](permissions.md)). Scoped cron
|
||
agents and honeytokens were not picked.
|
||
- ~~A guest project's own `.claude/settings.json`~~ — closed 2026-11-15
|
||
(verified live then: the project's `env` reached Bash): scoped lab runs
|
||
ignore project settings and the hooks start with `python -I`.
|
||
- Guard and sandbox events from a **Mac worker** stay on that machine
|
||
(hook stderr); the hub doesn't collect them yet.
|
||
- The audit's lows: per-author budget, upload ownership and quota, the
|
||
`__Host-` cookie, long-poll caps, an absolute session lifetime.
|