Skip to content

fix: close access gaps found in a security pass - #239

Merged
kalaspuff merged 12 commits into
mainfrom
fctl/184-run-a-thorough-full-security-pass-of-the
Oct 23, 2026
Merged

kalaspuff merged 12 commits into
mainfrom
fctl/184-run-a-thorough-full-security-pass-of-the

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

A security pass over fctl: the control plane (sign-in, permissions, Durable Objects, runners, the GitHub integration), the host, the in-sandbox agent, the CLI, the standalone server and the web app. Six reviews ran in parallel, one per area. I checked each finding in the code before changing anything, and reproduced the main ones against cargo xtask dev. Nothing critical turned up: the sign-in, token, passkey, webhook and token-minting paths held. What follows is what didn't.

Fixed, most severe first

  • Demoted members kept running their old sessions, on their own runners. A session's Claude connection ran it as long as its person was still in the workspace (spec::credential_serves). So someone made a viewer of a project, or taken out of it, still had their sessions there run on their subscription when anyone messaged them or a follow-up woke them, and on their own runner, which got the project's secrets and fresh GitHub tokens. Changing a project role stopped nothing. Now a credential runs a session only while its person may still message it, for GitHub token refreshes too. FleetDO also stops such sessions as soon as someone's access changes (/workspaces-changed, which removing a share now calls too).
  • A password alone got a runner token, around a workspace's two-factor requirement. POST /api/v1/runners/{id}/token only checked that the caller registered the runner. Someone holding the password of an admin without a second factor got a token for every session the runner ran, in a workspace that requires two-factor sign-in. Replacing the token is now refused while a workspace the runner serves is closed to its owner.
  • Registering a runner skipped "confirm it's you". Adding a runner to a workspace is a sensitive action, but registering a new one for a workspace (POST /api/v1/workspaces/{id}/runners, POST /api/v1/runners) and replacing a runner's token weren't, so a stolen session did those instead. Both now ask, and the CLI asks in the terminal during fctl host install (ADR 0046 records the change to ADR 0039).
  • Review agents ran on anyone's pull request. Every pull request, forks included, started a review on the operator's Claude subscription, with their token in the sandbox and Claude acting on what the pull request says. Only the prompt told the agent not to run the code or follow its text, so anyone who could open a pull request on a public repository could try to have it hand the token over. GitHub's deliveries now start reviews only for authors who may write to the repository, and for fctl's own agents. People in the project ask for the others' reviews ("Review a pull request", fctl review start) once they've looked at them. This changes what ADR 0040 decided, so it is yours to accept or reject: it is its own commit (8f35482), recorded in ADR 0047.
  • Instance admins could add admins and take over workspaces. Any instance admin could promote a member to admin (PATCH /api/v1/admin/users/{id}), though only the primary owner may invite or allowlist admins, and the web app already greyed the option out. Only the primary owner does that now. And when an instance admin deleted a workspace's primary admin, or removed the allowlist entry that admitted them, the role passed to the longest-standing member, which could be that same instance admin. Instance admins can't give themselves that role directly (check_assign_primary). It no longer passes to them unless they are an admin of the workspace already, and a workspace with no one else waits for one (needs_primary).
  • Forged notices and links from a sandbox. Notices arriving over a session's uplink could carry a follow-up, which only the control plane makes and which shows people's GitHub comments in their names, and a review notice could link anywhere ("View on GitHub"). Uplink notices now lose follow_up, and a review's link is kept only as GitHub's own link to the pull request or a comment on it (fctl_domain::reviews::posted_link). The web app opens those links only on GitHub too.
  • Pictures and avatars made other people's browsers act for them. Pictures in GitHub comments, shown as links, skipped textLink, so a comment could put the device approval page with an attacker's code behind a picture. They now go through it. Pictures in agents' answers loaded from the app's own address, and so did avatars: each viewer's browser sent its cookies there, which ran their export or used up their device codes. Pictures now load from the app's address only as published screenshots, and avatars must come from another host (validate::avatar_url), with the web app skipping stored ones that don't.
  • Lower:
    • GET /api/v1/github/repos, which lists every repository of a workspace's GitHub accounts, private ones included, is now for the workspace's admins and maintainers of one of its projects, not every member.
    • A workspace's audit log keeps only the caller's own IP addresses, as the web app already showed it.
    • The export's notes, schedules and followed sessions come only from projects and sessions the person still sees.
    • Without email, an admin's password reset link comes back to the admin and signs in as the person, so it now takes confirming it's you.
    • Names drop control characters and the ones that reverse text, which let a device name read as another on the approval page.
    • Review findings go to sessions by GitHub account id, as comments and checks already did, not by login.
    • A viewer socket that stops pinging closes after two minutes instead of five.
    • The CSP says object-src 'none'.
    • The device approval page warns against approving a sign-in someone else started, and shows the client's user agent.

Not changed: for you to decide

  • Whoever can message a session's agent can read its person's Claude token. It is in the sandbox, so a project editor can have someone else's session hand it over: hours for a full login, a year for claude setup-token. Only the sandbox model can change that; docs/security.md now says it plainly.
  • fctl self update, the host's agent download and the installer check a SHA-256 fetched from the same server as the binary, with no signature.
  • Hosts report plan usage for the sessions they run, which decides when schedules skip runs. Such a runner holds those tokens anyway.
  • A workspace admin who is demoted keeps the explicit owner role in projects they created. It shows in the project's members.
  • Project and workspace slugs are unique across the instance, so creating one tells whether a name exists in another workspace.
  • Reviews someone asks for have no hourly limit, unlike schedule runs.
  • On a self-hosted app.<domain>, the app suggests curl https://<domain>/install | sh.
  • connect-src allows WebSockets to any host.

Verified

  • cargo xtask check passes. There are new unit tests for review links, avatar addresses, names and instance roles, and web tests for Markdown pictures and GitHub links.
  • End to end against cargo xtask dev, with scripts against the API:
    • A member's running session stopped when the workspace's base role became viewer, and a message afterwards failed with the new reason instead of running on her subscription.
    • With the workspace requiring two-factor, her password-only session got 403 replacing her runner's token, and 200 once it no longer required it.
    • With confirmation on, an unconfirmed token got verification_required registering a runner (both routes), replacing a runner's token and making a reset link, and succeeded after POST /auth/verify.
    • An admin who isn't the primary owner got 403 making someone an admin.
    • An admin who deleted the primary admin of a workspace they were a member of left it needs_primary, with themselves still a member.
    • A member got 403 listing the workspace's repositories, and a maintainer got past the check.
    • The workspace audit log showed only the reader's own addresses, the export dropped a session once its person lost the project, names lost their bidi characters, and avatars on the app's host were refused.
  • I didn't run the review agent and forged-notice changes end to end: that needs a GitHub stand-in and a forged uplink. They rest on rv::trusted and posted_link, which have unit tests.

Screenshots

At 18b9209, from cargo xtask dev, 900 px wide.

The device approval page, which a link can open with someone else's code filled in. It now warns against approving a sign-in you didn't start, and shows the client's user agent:

Before After
Before: the device approval page, light After: the device approval page with the warning and the user agent, light
Before: the device approval page, dark After: the device approval page with the warning and the user agent, dark

At a phone width, dark: After: the device approval page at 390 px, dark

A project's Reviews tab before review agents are on, which now says that outsiders' pull requests wait for someone to ask:

Before After
Before: the Reviews tab's introduction After: the Reviews tab's introduction with the new sentence

hyperstructure/fctl-site#49 updates the privacy policy to match: who gets reviews of outsiders' pull requests, and the addresses workspace admins see in their audit log.

Session: https://app.fctl.sh/s/ses_01M5MHK862G56BT579VMMJHQVZ

fctl-sh Bot added 10 commits October 23, 2026 14:48
- A session's Claude credential runs it only while its person may still
  run it: message it as a project editor, or through a share
  (`spec::credential_serves`). Before, a member demoted to viewer, or
  taken out of a project, still had their old sessions there run on their
  subscription and on their own runners, which got the project's secrets
  and fresh GitHub tokens. GitHub token refreshes check it too, and
  FleetDO stops such sessions when someone's access changes.
- Replacing a runner's token is refused while a workspace it serves is
  closed to its owner by that workspace's two-factor requirement, so a
  password alone no longer gets a runner token for everyone's sessions.
- Registering a runner for a workspace and replacing a runner's token
  take confirming it's you, as adding a runner to a workspace does:
  otherwise a stolen session registered a new runner instead.
- Deleting or disallowing a workspace's primary admin no longer passes
  the role to the instance admin who did it, unless they are one of the
  workspace's admins already.
- Only the primary instance owner makes someone an instance admin, as
  only they invite or allow addresses as admins.
A review runs on its operator's Claude subscription with their token in
the sandbox, and Claude acts on what the pull request says. Every pull
request started one, so text in anyone's pull request on a public
repository could have the review agent hand the operator's token over,
with nobody in the project having looked at it. GitHub's deliveries now
start reviews only of pull requests whose authors may write to the
repository, and of fctl's own agents'; people in the project ask for the
others' (the Reviews tab, `fctl review start`). ADR 0046 records it, and
ADR 0045 the runner confirmation of the previous commit.
…belong

- Notices from a session's uplink no longer carry what became of pull
  requests (`follow_up`), which only the control plane tells, with
  people's comments: what runs in a sandbox can pose as the agent, and
  could put a comment in someone's name. A posted review's link is kept
  only as GitHub's own link to the pull request, or a comment or review
  on it (`fctl_domain::reviews::posted_link`); the web app opens such
  links only on GitHub too.
- Pictures in GitHub comments, shown as links, go through `textLink`
  like any link, so a comment can't link to the app's device approval
  page or API in a picture's place.
- Pictures in agents' answers load from the app's own address only as
  published screenshots, and avatars come from other sites: the browser
  sends the reader's cookies to the app, so such a picture acted for
  everyone who saw it (ran their export, used up their device codes).
- `GET /api/v1/github/repos` lists a workspace's repositories, private
  ones too, to its admins and to maintainers of one of its projects, who
  choose them, not to every member.
- A workspace's audit log keeps the IP addresses of the caller's own
  actions only, as the web app shows it: its admins see who did what
  there, not where its members were.
- The export's notes, schedules and followed sessions come from the
  projects and sessions the person still sees: others keep them up to
  date, and they were taken out of the others.
- Where the instance sends no email, an admin's password reset link for
  someone comes back to the admin and signs in as them: it takes
  confirming it's you, as deleting their account does.
- Names leave out control characters and the ones that turn text around,
  which made a device asking to sign in read as another.
A review's findings went to a session listing the pull request in any
workspace connected to a GitHub login of that name, where comments,
checks and merges go only to workspaces connected to the same account by
GitHub's id. A workspace whose connection is to a login that changed
hands since (renamed, then taken by someone else) could get the findings
of the new account's pull requests. They now follow the same rule: the
account the review's own workspace connected, by its id.
…e app

- A session's viewer socket whose access wasn't checked for two minutes
  (it stopped pinging, which the apps do every 25 seconds) closes at the
  next broadcast, rather than after five: a client that stops pinging
  once its person lost access hears little more of the session.
- The web app's Content-Security-Policy says `object-src 'none'`: it
  embeds no plugins, and otherwise `<object>` fell back to `'self'`.
The device approval page signs a CLI in as you with one click, and a
link can fill in its code: whoever sends you `/device?code=…` gets your
account if you approve. It now says to approve only a sign-in you
started yourself, just now, and shows the client's user agent beside
where it asked from, which the API already returned.

docs/security.md also says plainly what the sandbox model implies:
whoever can message a session's agent can have it hand over the Claude
token of the person it runs as.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner October 23, 2026 16:44
@fctl-sh

This comment has been minimized.

Comment thread crates/fctl-control/src/api/auth.rs Resolved
The settings form sends the avatar with every save, so someone whose
stored avatar is on the app's host, from before avatars had to come from
another one, couldn't save anything else until they cleared it. Such an
avatar now stays as it is, which the web app doesn't load; changing it
still takes another host.
kalaspuff
kalaspuff previously approved these changes Oct 23, 2026
…gh-full-security-pass-of-the

# Conflicts:
#	docs/adr/README.md
#	web/src/components/session/follow-up.tsx
@kalaspuff
kalaspuff merged commit a86726e into main Oct 23, 2026
11 checks passed
@kalaspuff
kalaspuff deleted the fctl/184-run-a-thorough-full-security-pass-of-the branch October 23, 2026 17:35
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