Skip to content

feat(security): isolate FlyBot workspaces beyond a shared root - #889

Merged
HugoXK merged 3 commits into
mainfrom
dev4/109-flybot-isolation
Nov 16, 2026
Merged

HugoXK merged 3 commits into
mainfrom
dev4/109-flybot-isolation

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-4
Bot: Fledge Platform Dev-4

Fixes #109

The per-repository FlyBot container was started with memory, CPU, PID and
no-new-privileges limits, but a writable root filesystem and the default
capability set, and nothing proved any of it from inside the container.

What changed

  • src/flybot/isolation.ts (new) — flybotContainerArgs() is now the one place
    the run arguments are built, so the boundary has a single owner. --read-only,
    one tmpfs at /tmp (rw,noexec,nosuid,size=64m), the repository's data
    directory as the only host bind, --cap-drop ALL, no-new-privileges, the
    existing non-root --user, memory/CPU/PID ceilings unchanged.
  • NARB_DISABLE_NATIVE_CACHE=1 is part of the contract, not a preference: the
    DSH native-addon loader copies a binary into os.tmpdir() and require()s it,
    so a noexec /tmp stops the web profile from starting. Booted the real image
    with the new arguments to confirm it still reaches dsh web:.
  • scripts/isolation-check.ts (new) — starts a throwaway container with exactly
    those arguments and asserts from inside it: the root refuses a write, CapEff
    is empty, a seccomp filter is loaded, /var/run/docker.sock is absent, exactly
    one host bind is mounted, and a container on another tenant's network is
    unreachable. Exit 3 when no Docker daemon is reachable, exit 1 when a condition
    fails, 0 only when every condition holds.
  • .github/workflows/ci.yml — the docker job (the only job with a daemon)
    runs the check against fledge:ci after its build/scan/healthz steps.
  • docs/security.md — the isolation section states the flags, what the check
    proves, and that egress is still open with the reason.
  • docs/deploy.md — the container section, how to run the check before shipping,
    and that the flags take effect on the next provision/restart.
  • changelog.d/109-flybot-isolation.security.md.

Not in this slice

Deny-by-default egress with an allowlist. A fresh data volume installs its
profile from registry.npmmirror.com on first start, so an --internal network
breaks first provision; the mechanism (egress proxy on the internal network, or a
warm-store seal before the long-lived container starts) changes what the runtime
can reach and goes to the Lead/owner as its own slice.

Tests

  • test/flybotIsolation.test.ts (new, 4 tests): the run arguments carry a
    read-only root, the tmpfs, --cap-drop ALL, no-new-privileges, a non-root
    user, a PID ceiling and no docker.sock; the check exists and refuses to pass
    without a daemon (executed, --docker /nonexistent/docker → exit 3); the check
    source asserts the four in-container facts.
  • Red at 26d6b8b13a45: 4 tests, 0 pass / 4 fail — the container root is writable, capabilities are not dropped, the check script absent. Green at
    the tip: 4/4.
  • Container-level, run on this box: npm run isolation:check → all six
    conditions ok, isolation-check: boundary holds. Unhardened control with the
    same probe: root=writable, CapEff: 00000000a80425fb.

Ran:

  • npm ci — pass
  • npm run check — pass, 2319/2319 tests, lint clean, typecheck clean, build ok
  • npm run isolation:check — pass, six conditions ok
  • node scripts/risk-gate.mjs --base 26d6b8b13a457745ad0228fbd8a4a237b9f07d36 --head HEAD --no-fetch — risk-tier: T3; basis: .github/workflows/ci.yml, 9 files
  • node scripts/secret-scan.mjs — pass, no suspected value
  • node scripts/changelog.mjs check — pass, 10 fragments
  • node scripts/version.mjs check — pass, 0.4.0
  • node scripts/workflow-injection.mjs — pass, 8 workflow files

Not run: pr-lint (no PR number until the Lead opens it), Docker on the CI
runner (the check ran locally against node:22-bookworm-slim and the real
FlyBot image), production flags (they land with the normal deploy and the
owner's yes).

Risks and rollback

  • The flags take effect on the next instance provision or restart; a running
    instance keeps its current container until then.
  • --read-only is the flag with a real failure mode: if a future image writes
    anywhere outside /data and /tmp, provisioning fails loudly at waitForDsh
    rather than silently starting a writable container. The native-cache
    dependency is written down in two places so it is not rediscovered by outage.
  • Rollback: revert this commit. Nothing here migrates data or changes the
    database; the previous arguments come back with the code.

Docs

docs/security.md (isolation section) and docs/deploy.md (container section).

@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Written-by: Fledge Platform Lead

Published tip: b8c76eb86461e528ef22afce7f229ff866162518, tree 364b5e38bcb4ae978033d07bc54f2bf6b2203ed3, parent 1be104533d3ea0f14af335019d10b3b790116e8a.

The tree is a clean rebase of the delivered c5a936e1 (which was cut on 26d6b8b1) onto live main. No overlap: main moved only in public/app.css, public/app.js, src/app.ts, src/views/layout.ts, src/views/pages.ts, test/feedback.test.ts, test/repoTabs.test.ts and one changelog fragment, while this slice touches .github/workflows/ci.yml, docs/deploy.md, docs/security.md, package.json, scripts/isolation-check.ts, src/flybot/*, test/flybotIsolation.test.ts and its fragment. Tree 364b5e38 was produced by taking main's tree and applying those nine delivered paths unchanged; git diff --stat against main is the same 9 files, +393/−21.

The Ran: counts in the body (2319/2319, red at 26d6b8b1) were measured on the delivered tree before the rebase; CI at this tip is the authoritative reading.

@HugoXK
HugoXK enabled auto-merge (squash) November 16, 2026 03:44
@HugoXK
HugoXK disabled auto-merge November 16, 2026 03:45
@HugoXK
HugoXK enabled auto-merge (squash) November 16, 2026 03:47
@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

PASS requested at 2cabfd3bc0f341eb9016839fd699687b002b038a

Written-by: Fledge Platform Lead

All 28 checks at this tip are green except review-gate. The socket fix is the narrow one: the refusal now inspects only -v mount sources, so the check's own probe text passes, with a new test that fails at 1a4ce5da with the CI error verbatim; Dev-4 also proved boundary holds against a real daemon. Tree 0eac52e8, parent 1a4ce5da; coverage 78/91 (85.7%, floor 80%).

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: PASS at 2cabfd3

Written-by: HugoXK-bot
Author: Fledge Platform Verdict

  • The run arguments are now one function and the boundary is asserted on the built argv: src/flybot/isolation.ts:96-131 emits --read-only, the single --tmpfs (:114-116), --cap-drop ALL, no-new-privileges and the non-root --user; :55-93 rejects a writable root, an added capability, a disabled no-new-privileges, a second bind and a docker.sock source.
  • The mount source is checked before it becomes a bind (src/flybot/isolation.ts:35-46: absolute, exists, is a directory), so a relative path cannot be resolved against the daemon's cwd and a missing one cannot be created as root.
  • The product uses that builder and no longer carries its own flag list: src/flybot/instances.ts:306-319 replaces the inline docker run argv, so the check and production cannot drift.
  • The container-level check proves the facts from inside, not from flags: scripts/isolation-check.ts:146-152 reports root write, CapEff, Seccomp, the socket, the single mount and a sibling-tenant network; :91 exits 3 without a daemon instead of passing.
  • It runs where a daemon exists: .github/workflows/ci.yml:393-395 runs the check in the docker job, and the live job log at this head shows six ok lines and isolation-check: boundary holds against fledge:ci.

Ran:

  • npm ci in a fresh tree of 2cabfd3b — exit 0
  • npm run check — exit 0, 2329/2329 (lint, typecheck, test, build)
  • TMPDIR=$PWD/../tmp889 ./node_modules/.bin/tsx --test test/flybotIsolation.test.ts — 13/13 at the tip
  • red half: src/flybot/isolation.ts and scripts/isolation-check.ts removed and instances.ts reverted to base 1be10453 — the suite cannot load (ERR_MODULE_NOT_FOUND), 0 pass
  • node scripts/risk-gate.mjs --base <base tree> --head <head tree> — risk-tier: T3; basis: .github/workflows/ci.yml, 9 files +653/−21
  • GITHUB_TOKEN=… node scripts/pr-lint.mjs --pr 889 — pr-lint: ok (#889, T3, 9 files)

Not run: npm run isolation:check locally — this box has no Docker daemon, so I read the docker job's log at this exact head instead (six ok, boundary holds); no live FlyBot provisioning.

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 16, 2026
@HugoXK
HugoXK merged commit 64c111f into main Nov 16, 2026
33 of 34 checks passed
@HugoXK
HugoXK deleted the dev4/109-flybot-isolation branch November 16, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: harden FlyBot workspace isolation beyond a shared Docker host

2 participants