Skip to content

fix(host): keep Docker sandboxes apart, and a host's files to its owner - #173

Merged
kalaspuff merged 5 commits into
mainfrom
fctl/105-host-isolation
Oct 21, 2026
Merged

kalaspuff merged 5 commits into
mainfrom
fctl/105-host-isolation

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Hosts run sessions of every workspace their runner serves side by side, and what runs in a sandbox is untrusted. A review of the host found four ways it reached further than it should, beside Lima's mounts (#172).

  • Docker sandboxes reached each other. They ran on Docker's default bridge, where containers reach each other, so a session reached whatever another session on the host served (a dev server, a database), which may be another workspace's. New Docker sandboxes now join fctl-sandboxes, a bridge with inter-container traffic off (com.docker.network.bridge.enable_icc=false) that the host makes the first time. A runtime that can't make it (Podman may not) starts sandboxes as before, and the host's log says so. Existing stopped sandboxes keep their network until they're removed (keep_stopped_hours).
  • Token files were readable by other users for a moment. host-token and the CLI's credentials.toml were written, then restricted to their owner. They're now created that way.
  • A sandbox could exhaust the host's memory. The host read a frame from the agent's link whole before checking its size; a line without an end grew until the host was killed, with every session on the runner. Frames now stop at the largest allowed.
  • fctl host image build used a predictable directory in /tmp. On a machine others use, someone could make /tmp/fctl-image-<pid> first and put sources of their own in it. The sources now go into a new directory with a random name that only the user can open.

docs/security.md now says what each driver keeps apart on the network: Docker Desktop's and OrbStack's containers still reach the host's loopback (host.docker.internal), and Apple's container VMs share its network.

Verification. Unit tests with the stand-in docker CLI: Docker sandboxes are made with --network fctl-sandboxes, the network once, with inter-container traffic off; a runtime that can't make networks still starts sandboxes; Apple's driver passes no network. Token files are 0600 even over a looser leftover; image source directories are new and 0700. cargo clippy and cargo test pass for the workspace. There is no Docker in this sandbox, so the network itself wasn't tried on a real daemon: the commands are Docker's documented ones, and a failure falls back to the old behavior rather than failing sessions.

Other pull requests from the same review: #171 (control plane and web app), #172 (Lima sandboxes), #174 (fctl login and terminal output).

Made in fctl session https://app.fctl.sh/s/ses_01M5FGE9QB2HQVK1S59KEC4TYY

fctl-sh Bot added 5 commits October 21, 2026 16:19
Docker sandboxes ran on Docker's default bridge, where containers reach
each other: a session reached whatever another session on the same host
served, a dev server or a database, and a runner that serves more than
one workspace runs their sessions side by side.

New Docker sandboxes join a network of their own, fctl-sandboxes, a
bridge with inter-container traffic off (enable_icc=false), which the host
makes the first time. A runtime that can't make it, as Podman may not,
starts sandboxes as before and the host's log says so. docs/security.md
says what each driver keeps apart.
The runner token (host-token) and the CLI's credentials.toml were
written first and restricted to their owner after, so for a moment a
file holding a token was readable by every user of the machine, in a
directory anyone could list. The file is now created with no permissions
for others, replacing any leftover temporary one.
The host read each frame from fctl-agent's link whole before checking its
size, and what runs in the sandbox can write to that link: a line with no
end grew in the host's memory until the host was killed, and with it every
session on the runner, other workspaces' too. A frame now stops at the
largest one allowed, and the link breaks there, as it did for one that
ended past it.
…he user's

fctl host image build unpacked hyperstructure/sandbox into
/tmp/fctl-image-<pid>, and took that directory as it found it: on a
machine others use, someone could make it first and put sources of their
own in it, which the build then ran. The sources now go into a new
directory with a random name that only the user can open.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner October 21, 2026 16:25
kalaspuff pushed a commit that referenced this pull request Oct 21, 2026
…171)

A security review of the control plane and the web app found ways into
workspaces and accounts that their rules don't allow. Each commit fixes
one; together they close them.

**Workspaces people left or were never in**

- **Open sockets kept their access.** Session viewer and dashboard feed
WebSockets kept the identity and role they opened with. Someone removed
from a workspace, whose project role or share went, who signed out or
was disabled kept reading a session's transcript live and could still
message and interrupt its agent; their feed kept sending session
summaries and runners. SessionObject now checks a viewer's token and
role again in D1 on its pings (at most once a minute) and before every
message and interrupt, and closes it with 4403 once access is gone;
FleetObject does the same for feeds. A socket that stops pinging closes
after five minutes and reconnects through the Worker. The web app takes
the role from `session` frames, so a changed role shows.
- **Runners that no longer serve a workspace kept its sessions.** A
runner taken out of a workspace, or whose owner left it, was demoted or
disabled, kept running the sessions it had there, with fresh GitHub
tokens and Claude credentials, their messages and files: FleetObject
only checked that the session was assigned to it, which a host that
ignores a stop keeps true. Credential requests, uplinks, file downloads
and screenshot uploads now also take that the runner serves the
session's workspace now (`spec::runner_serves`); FleetObject stops its
sessions in workspaces it no longer serves, closes its uplinks to them
and forgets it as their sandbox's home. Disabling a runner or replacing
its token closes its sessions' uplinks too, and a runner's report that a
session ended counts only for its own sessions.
- **The account export ignored workspaces.** It streamed the transcript
of every session the person had started, including those of workspaces
they had left or been removed from. It now takes the workspaces open to
them, as the API does, and leaves out the IP addresses of other people's
requests that concerned them.
- **Uplinks could put words in people's mouths.** SessionObject stored
people's messages, interrupts and status changes that came over an
uplink, which only the control plane makes; no agent or host ever sent
them. They are now dropped there.
- **Project owners could be demoted by being added again.** `POST
/projects/{id}/members` for an existing member replaced their role
without the checks a role change makes, so a maintainer could demote an
owner, the last one too.

**Ways into an account**

- Linking a Google account, setting a first password and connecting an
invitation's address each add a way to sign in, and any session or
token, however old, could do them. They now take a browser sign-in from
the last 15 minutes, as adding a passkey does. Connecting an address
mattered most: it then gets the account's password reset links, so an
invitation for one's own address, forwarded to someone signed in and
connected with a click, let its sender reset their password. The
invitation page now says whoever has the address can reset the password.
- People are emailed (when email is set up) when a Google account or an
address is connected, when their password changes, when an admin makes a
reset link for them and when a reset link is used: an instance admin's
reset link sets a member's password, and with it reaches their
workspaces, and nothing told the member.
- Sign-in redirects (`?next=`, Google's `return_to`) took
`/\evil.example` and `/<tab>/evil.example` as paths of the app; browsers
read them as other sites (`fctl_domain::validate::is_app_path`,
`appPath` in the web app).
- `POST /auth/logout` cleared the session cookie for anyone, a page of
another site too; it now does only for a signed-in request, which passed
the origin check.
- Only the primary instance owner enables and disables admins, but
adding an allowlist entry re-enabled a disabled admin, and removing one
disabled admins it alone admitted. Both are now the owner's.

**Hardening**

- Attached files keep their type only when the app shows or plays them
(PNG, JPEG, GIF, WebP, MP4, WebM, QuickTime); the rest are served as
`application/octet-stream`, so no upload can pass for a script of the
app's origin.
- A session's Remote Control link is kept only when it is an https page
of claude.ai (or claude.com): `fctl open --claude` handed it to
`open`/`xdg-open`, which on a Mac also start the app or file at a path.

**What a person should decide.** Instance admins see the link of every
instance invitation they make, also when it is emailed, so an admin can
sign up as an invited address that has no account yet and join the
workspaces that invited it. Hiding the link when the email went out
would close that on instances that send email, at the cost of the "you
can also send them this link" option; I left it as it is.
docs/security.md says instance admins don't see inside workspaces they
aren't in, which reset links (now announced to the person) and this
soften.

**Verification.** `cargo xtask check --quick` passes. End to end on
`cargo xtask dev`, with scripts driving the API and sockets as a second
member and as admins: on `main` a removed member's open socket stays up
and their message reaches the agent, their export still holds the
workspace's transcripts, a disabled member's feed stays open, a session
keeps running on a runner taken out of its workspace, a maintainer
demotes an owner by adding them again and an admin brings back an admin
the owner disabled; on this branch each of those is refused or closed
(4403 on the sockets within a minute, at once on a message), the session
stops with "Its runner no longer runs this workspace's sessions" and
resumes once the runner is back. Unit tests cover the app path check
(Rust and web).

## Screenshots

At 579b52b, light theme, 1280 px wide, with the dev stack's data. The
invitation page, signed in, when the invitation's address can be
connected: it now says what connecting gives whoever has the address.
The settings page after a Google link that didn't come from a recent
sign-in, which `main` answers with a generic error.

| Before | After |
|---|---|
| ![Before: the invitation page's connect
card](https://app.fctl.sh/api/v1/published/0ART3A5A1xqQKwynGmJO87fayE9PiDEVha1KcLiuCgc/before-invite.png)
| ![After: the connect card says whoever has the address can reset the
account's
password](https://app.fctl.sh/api/v1/published/Fj4C8RWJdTZSzQ91Bl70S8roKzfPUWjwqnNIa7luyrh/after-invite.png)
|
| ![Before: settings say "That did not work. Try
again."](https://app.fctl.sh/api/v1/published/5diT6CF6ZBbuP5wrkuy7bXf4r5xi9HRSyQl138Ht86r/before-google.png)
| ![After: settings say linking Google takes a sign-in from the last 15
minutes](https://app.fctl.sh/api/v1/published/3EYKcZnqms0FnqaXcKAbMqJIAGQ1zx169GKck0vk9D7/after-google.png)
|

Other pull requests from the same review: #172 (Lima sandboxes saw the
host's home directory), #173 (Docker sandboxes reached each other; host
files), #174 (fctl login and terminal output).

app.fctl.sh's privacy policy changes with it (the new emails, and what
the export holds): hyperstructure/fctl-site#35.

Made in fctl session
https://app.fctl.sh/s/ses_01M5FGE9QB2HQVK1S59KEC4TYY

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Oct 21, 2026
Lima's templates give every VM the home directory of whoever runs
`limactl`, read only, and a `/tmp/lima` that every VM writes to, and
forward a VM's ports to the host's loopback. fctl made its `fctl-base`
VM from `template://debian-12` and cloned each session's VM from it
without changing any of that. So anything a session ran (an agent that a
web page talked into it, a dependency's install script) could read
`~/.config/fctl/host-token`, the runner token, which gets the
credentials of every session of every workspace the runner serves, the
CLI's token in `credentials.toml`, SSH keys, and the disks of other
sessions' VMs, and could reach services other sessions ran.

- The base VM and every session's VM now get no mounts and no port
forwards (`ISOLATED` in `crates/fctl-host/src/driver/lima.rs`, the rule
Lima's own template documents for forwarding nothing). The agent comes
in with `limactl copy` and runs through `limactl shell`, over SSH, which
these don't touch.
- A stopped VM cloned by an earlier version loses its mounts (`limactl
edit --set`) before it boots again for a resume; if that fails, the host
replaces it with a new clone, and the session starts a new conversation
on its branch, as when its sandbox is gone.
- `limactl` takes only the last `--set` it is given (cobra's string
flag), so the VM's size, which came in two, now comes in one expression
with the rest: the CPU limit of Lima sandboxes never applied before.
- docs/security.md says what owners of Lima hosts that ran 0.14.1 or
earlier should do: remove the runner and install the host again, sign
the CLI in again and revoke its old tokens, and replace other keys kept
in that home directory.

**Verification.** With Lima 1.2.1's `limactl` (in a scratch `LIMA_HOME`;
this sandbox runs no VMs), on the configurations it writes: a stock
`template://debian-12` instance mounts the home directory and
`/tmp/lima`; `create --set`, `clone --set` and `edit --set` with this
expression leave no mounts and an ignore-all port forward rule, and
`clone` applies the CPUs and memory too, which two `--set` flags didn't
(only the last applied). A unit test pins the expression. `cargo clippy`
and `cargo test` pass for the workspace. Booting a VM wasn't possible
here, so the first Lima session after this deserves a look.

Other pull requests from the same review: #171 (control plane and web
app), #173 (Docker sandboxes and host files), #174 (fctl login and
terminal output).

Made in fctl session
https://app.fctl.sh/s/ses_01M5FGE9QB2HQVK1S59KEC4TYY

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
@kalaspuff
kalaspuff merged commit f01acf8 into main Oct 21, 2026
5 of 6 checks passed
@kalaspuff
kalaspuff deleted the fctl/105-host-isolation branch October 21, 2026 16:53
kalaspuff pushed a commit that referenced this pull request Oct 21, 2026
…ely (#174)

Two things the CLI took on trust, from a review of fctl:

- **`fctl login` opened whatever sign-in link the server sent.** A
server someone was talked into signing in to could start a device
sign-in at another instance, app.fctl.sh say, and send them that
instance's link, with the code filled in and their machine's name on it;
one click on Approve there gave that server a token for their account.
`fctl login` now stops when the link is on another site than the server
it signs in to (loopback addresses count as one site, for the dev stack,
whose web app and API use different ports) and says how to sign in there
instead:

  ```
error: http://127.0.0.1:9999 asks you to approve this sign-in on another
site (https://app.fctl.sh), which would sign you in there for it. To
sign in to https://app.fctl.sh, run `fctl login https://app.fctl.sh`.
  ```

- **Session output reached the terminal as it came.** `fctl attach`,
`fctl logs` and `fctl show` printed agents' text, setup scripts' and
dependencies' output and pull request links with any escape sequences in
them, which could move the cursor to rewrite what was on screen, set the
title or, in some terminals, the clipboard. They now print without the
control characters terminals act on, save newlines, tabs and color
codes.

**Verification.** Unit tests for both (`same_site`, `terminal_safe`).
Against `cargo xtask dev`, `fctl login http://127.0.0.1:8787` still
signs in through the device page on `localhost`, and against a stand-in
server that relays app.fctl.sh's link it stops with the error above.
`fctl logs` prints transcripts with their colors as before. `cargo
clippy` and `cargo test` pass for the workspace.

Other pull requests from the same review: #171 (control plane and web
app), #172 (Lima sandboxes), #173 (Docker sandboxes and host files).

Made in fctl session
https://app.fctl.sh/s/ses_01M5FGE9QB2HQVK1S59KEC4TYY

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Oct 21, 2026
…ge (#168)

[hyperstructure/sandbox#8](hyperstructure/sandbox#8)
moves the sandbox image to Debian 13 (trixie), Node.js 26, uv 0.13.4 and
Rust 1.99.1, and checks on its pull requests that fctl's own development
works in it. fctl follows it:

- **Lima sandboxes on Debian 13.** `fctl host image build --driver lima`
prepares the `fctl-base` VM from Lima's `debian-13` template instead of
`debian-12`, so Lima sessions get the image's Debian. Lima added that
template in 2.0 (November 2025): with an older Lima, the VM gets Debian
12 as before, and the command says so and to upgrade Lima (`brew upgrade
lima`). The image's `provision.sh` works on both. A `fctl-base` VM that
is already there stays as it is until it is built again.
- **Rust 1.99.1**, the image's: the two move together, so that sessions
working on fctl have nothing to download. It fixes regressions in 1.99.0
([announcement](https://blog.rust-lang.org/2026/10/15/Rust-1.99.1/)):
missing `wcslen` symbols on some targets, a miscompilation of `bool`
returned through FFI on x86_64, and rust-lld failing to load on macOS.
`rust-version` in Cargo.toml stays `1.99`, and the standalone image
builds its Worker in `rust:1.99.1-slim-bookworm`, which `main` now pins
to the toolchain (a test in `xtask/src/serve.rs` checks that they
match).
- **package-lock.json, refreshed with npm 11.** Node.js 26 comes with
npm 11, which drops two entries npm 10 keeps: the `site` workspace,
which moved to hyperstructure/fctl-site, and `@cloudflare/workers-types`
as an optional peer that nothing installs. Without this, the first `npm
install` in a session rewrites the lockfile. npm 10 keeps the refreshed
one as it is, so CI's Node.js 22 and sessions' Node.js 26 agree on it.
- **The Sandbox images page** says the image is Debian 13 with Node.js
26, and that the Lima VM is Debian 13 unless Lima is older than 2.0. Its
.NET example installs Debian 13's ICU (`libicu76`; Debian 13 has no
`libicu72`), and its examples start from the `0.14` tag, which
sandbox#8's merge rebuilds on Debian 13, instead of `0.5`, which stays
on Debian 12.

fctl's own Node.js doesn't change (CI, the standalone image, "Node.js 22
or newer"): CI keeps checking the oldest Node.js fctl supports, and
sandbox#8's Develop fctl workflow runs fctl's checks and sessions on
Node.js 26 in the image. Release builds (`cargo xtask dist`, with zig)
and deploys stay with the Release and CI workflows.

hyperstructure/sandbox#8 is merged, and its image is published:
`0.14.1`, `0.14` and `latest` are Debian 13 now (2.25 GB unpacked on
amd64, 58 MB more than before; 2.12 GB on arm64, 43 MB more), so the
docs' example works and this can merge.

**Verification**

- CI: `cargo xtask check` and `cargo xtask dev --smoke` pass on Node.js
22 and npm 10 with the refreshed lockfile, and the Standalone image
workflow builds the standalone image with Rust 1.99.1 and runs a session
through it.
- Merged with `main` (#169 to #176): `image.rs` keeps #172's isolated
base VM (`--set` with no mounts and no port forwards) and #173's private
download directory, with the Debian 13 template. Lima 2.2.1 merges its
templates' bases, the home directory mount of `_default/mounts`
included, before it applies `--set`, so `debian-13` gets no mounts
either. The lockfile keeps #176's `@hyperstructure/design` 0.6.0, and
npm 10 and 11 leave it as it is. `cargo xtask check --quick` passes on
the merge.
- A unit test covers the template: Lima 2.x gets Debian 13, 1.x Debian
12, and a version it can't read Debian 13.
- In sandbox#8's Debian 13 image, its Develop fctl workflow runs this
branch (4fcc7ff) as a session would and passes on amd64 and arm64
([run](https://github.com/hyperstructure/sandbox/actions/runs/39635043177)):
`cargo xtask check`, a session through `cargo xtask dev` and one through
`cargo xtask serve`, an `npm install` that leaves the lockfile as it is,
and Playwright screenshots of the signed-in home page, which install
Chromium's libraries from Debian 13.
- In the session (arm64, Debian 12, Node.js 26.12.1 first on the PATH),
the same `check-fctl.sh` passes on this branch in 8 minutes.
- npm 10.9.9 and 11.20.0 both leave the refreshed lockfile as it is
(`npm install --package-lock-only`).
- Lima itself isn't run here: sessions have no VMs. Lima's `debian-13`
template is in its releases from v2.0.0 on, and `debian-12` is still in
them.

Made in fctl session
https://app.fctl.sh/s/ses_01M5FGH6RENBJVF1MS02X2MB51

---------

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant