Skip to content

fix(control): stop reading request bodies once they pass their limit - #360

Merged
kalaspuff merged 4 commits into
fctl/573-device-warningfrom
fctl/573-capped-bodies
Oct 30, 2026
Merged

kalaspuff merged 4 commits into
fctl/573-device-warningfrom
fctl/573-capped-bodies

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

Summary

JSON bodies, GitHub's and Linear's webhook deliveries, avatars, and the files people attach to sessions or agents publish were read whole before anything checked their size, and refused early only when the client said how large the body was (Content-Length). A client that doesn't, sending Transfer-Encoding: chunked, could send a body without end, without signing in: on the standalone server, whose proxy passes bodies on chunked and caps none, a curl -T /dev/zero to the sign-in endpoint would have the Worker keep it all in memory until the instance fell over, with every session socket on it. On Cloudflare the platform's own limits bound it. Bodies are now read as they come (http::read_upto) and refused once they pass their limit, with the same messages as before.

Verified in cargo xtask dev: 200 MB of zeros sent chunked to POST /api/v1/auth/login is refused with "The request body is too large" after about 9 MB had gone out, within a second, and signing in, uploading an avatar and an attachment, an agent's published screenshot and a Linear delegation through the stand-in's webhook all work as before. cargo xtask check --quick passes.

Stacked pull requests

Based on the one before it in this security pass's stack:

fctl session


Note

Medium risk. It changes how every JSON body, webhook delivery, avatar and file upload is read, which all requests go through, though only the reading changes and not what is accepted.

What it does. Adds http::read_upto, which reads a request body chunk by chunk and stops once it holds more than the limit, and uses it for JSON bodies, GitHub and Linear webhooks, avatars, and the file uploads and published screenshots in the files object. Before, a body was read whole before its size was checked, so a chunked request without Content-Length could use up the Worker's memory on the standalone server. The callers' own size checks and messages stay as they were, and docs/security.md describes the behavior.

fctl review's first look at 11b23e0 · 6 files, +36 −8 · Review agent settings

fctl-sh Bot added 2 commits October 30, 2026 21:48
JSON bodies, GitHub's and Linear's webhook deliveries, avatars and the
files a session's people attach or its agent publishes were read whole
before anything checked their size, which was refused early only when
the client said how large the body was. A client that doesn't, with
`Transfer-Encoding: chunked`, could send a body without end: on the
standalone server, whose proxy passes bodies on chunked and caps none,
anyone could do it to the sign-in endpoint and take the instance down
with its memory. Bodies are now read as they come (`http::read_upto`),
and refused once they pass their limit.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/do_files.rs Resolved
fctl-sh Bot added 2 commits October 30, 2026 21:52
Reading a body up to its limit returned the control plane's own error, so
a read the files object failed said "Reading the upload: Something went
wrong on our side" instead of the runtime's reason. `read_upto` now
returns the runtime's error, which each caller turns into its own, as
`req.bytes()` did.
@kalaspuff
kalaspuff added this pull request to stack #361 October 30, 2026 21:59
@kalaspuff
kalaspuff merged commit 1c360b6 into main Oct 30, 2026
12 of 20 checks passed
@kalaspuff
kalaspuff deleted the fctl/573-capped-bodies branch October 30, 2026 22:14
kalaspuff pushed a commit that referenced this pull request Oct 30, 2026
## Summary

What a linked Linear account delegates to fctl, or mentions fctl in,
starts sessions as its fctl person, on their Claude subscription, and
its replies reach their sessions' agents. With a stolen browser session
or token, someone could link their own Linear account to the victim's
fctl account, with nothing to confirm and nothing said to the person,
and go on starting the victim's sessions from Linear, reading what they
do there, long after the stolen token was revoked or the password
changed.

Linking a Linear account is now a sensitive action
(`Sensitive::LinkLinear`), as connecting a Claude subscription became in
#326: where the primary instance owner turned on confirming it's you, it
takes a passkey or a code. The app's "Link your Linear account" buttons
(Settings and a project's Tickets tab) confirm before they go on to
Linear; a link opened elsewhere (Linear's own button in an agent
session, `fctl account linear connect`) goes back to Settings with
"Linking a Linear account takes confirming it's you", where linking
again confirms first. A new link also emails the person when email is
set up, naming the Linear account and saying what it does.

Verified in `cargo xtask dev`: with confirming turned on and an
authenticator app on the account, an unconfirmed session's `GET
/api/v1/linear/link` goes back to `/settings?linear=confirm#linear`, and
after `POST /api/v1/auth/verify` it goes on to Linear's sign-in. The web
tests for the Tickets tab and the outcomes pass, and `cargo xtask check
--quick` passes. The email needs an instance with email, which the dev
stack isn't.

The privacy policy lists the new email since:

- hyperstructure/fctl-site#97

## Worth confirming

- **Decision:** like every sensitive action, this asks only where
confirming it's you is turned on, which is off by default; elsewhere the
email is what tells the person.
- **Decision:** a link from Linear's own button that needs confirming
lands on Settings rather than taking up the agent session that asked for
it; after linking from Settings, fctl still takes up the delegations
that waited for that Linear account.

## Stacked pull requests

The fixes before this one in this security pass are on main; the next
ones build on this one:

- #358
- #359
- #360

[fctl session](https://app.fctl.sh/s/ses_01M677K9YMM5WPZBTAR2KKXMSZ)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Medium risk.** It adds a confirm-it's-you check to linking a Linear
account, which changes an authentication-adjacent flow for everyone who
links one; a mistake could block linking or let a stolen session link an
account.
>
> **What it does.** Linking a Linear account lets Linear delegations
start sessions as the person, so `GET /api/v1/linear/link` now requires
the same sensitive-action confirmation as connecting a Claude
subscription, where the instance asks for it. The web app confirms
before sending people there, and Linear's own button is redirected back
to Settings to confirm. A notice email is also sent when an account is
linked.
>
> **New outcome and email.** Linking now has a `confirm` outcome shown
in Settings and sends a best-effort email to the person;
docs/security.md and docs/architecture.md are updated.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M67D37HF57SP912A3YYJK0WN)'s first
look at
[`393e78c`](393e78c)
· 10 files, +173 −11 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

---------

Co-authored-by: fctl-sh[bot] <343971779+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