Repository navigation
Description
The workflow
I maintain a bb plugin that gives each session an HTML page the reader opens on their phone. The
page is a directory in thread storage: index.html plus its own stylesheet, scripts and data
files, referenced relatively, exactly as a static site would.
- An agent writes
index.htmlanddata.jsbeside it into its session's storage. - The reader opens the page. The plugin serves
index.htmlinto an iframe with
sandbox="allow-scripts allow-forms", because the document is agent-authored and must hold no
host authority. - The document requests
data.js.
On loopback, step 3 works. Over bb Connect it does not, and nothing errors: the page shell,
the chrome and every capability call work, and only the page's own content is missing. A reader saw
a fully functional interface reporting that a 300-row dataset was empty. The developer cannot see
this from their own machine, because a local bb requires no credential and a remote one does.
What happens today
Unauthenticated GETs, no cookie, from one machine on 2026-09-09 (bb 0.42.1):
| Path | loopback 127.0.0.1:38886 |
<handle>.getbb.app |
|---|---|---|
/api/v1/plugins/<plugin>/http/page?session=… |
200 | 401 |
/api/v1/threads/<id>/thread-storage/files/index.html |
200 | 401 |
/api/v1/health (does not exist) |
404 | 401 |
/api/v1/plugins/nonexistent-xyz/http/page |
404 | 401 |
The last row is the one that identifies the layer: a plugin that does not exist returns bb's own
404 locally and a 401 remotely. The remote responses carry server: cloudflare and a cf-ray,
and their body is the Connect sign-in gate — so the refusal happens at the edge, before bb is
reached at all. Re-checked 2026-09-13: a Connect port share (<handle>--<port>.getbb.app) answers
the same 401 to a cookieless request, including the CORS preflight.
Observed (above). What I think the cause is, labelled as inference:
- The gate is the end of the worker's credential ladder — no session cookie and no desktop cookie
⇒signInPage(...):
Lines 383 to 402 in 9e16411
const cookieHeader = request.headers.get("cookie"); const cookie = parseCookie(cookieHeader, runtime.sessionCookieName); const desktopCookie = parseCookie( cookieHeader, runtime.desktopSessionCookieName, ); const appUrl = runtime.accountAppUrl; if (!cookie && !desktopCookie) return signInPage(label, appUrl, url.toString()); const verifiedSession = cookie ? await verifySessionCookieDetails(cookie, env.BETTER_AUTH_SECRET, db) : null; const sessionUserId = verifiedSession?.userId ?? null; const desktopUserId = desktopCookie ? await verifyDesktopSessionCookie(desktopCookie, env.BETTER_AUTH_SECRET) : null; if (!sessionUserId && !desktopUserId) { return signInPage(label, appUrl, url.toString()); } - The sandboxed frame has an opaque origin. Its document request is issued by the trusted
parent, whose site-for-cookies is the Connect host, so theSameSite=Laxcookie is attached and
the document loads. Every subresource request issued from inside that frame has an opaque
origin in its ancestor chain, so its site-for-cookies is null, the request counts as cross-site,
and a Lax cookie is not attached. - Both Connect cookies are Lax:
bb/apps/desktop/src/connect-desktop-session.ts
Lines 155 to 165 in 9e16411
await args.cookieStore.set({ domain: cookie.domain, expirationDate: cookie.expiresAt / 1000, httpOnly: true, name: cookie.name, path: "/", sameSite: "lax", secure: remoteOrigin.startsWith("https://"), url: remoteOrigin, value: cookie.value, });
I could not instrument the last point directly — that needs devtools on the authenticated remote
origin, which I do not have. It is the only account consistent with the measurements above, but I
am marking it inference rather than presenting it as fact.
This is not specific to my plugin. It applies to any plugin serving sandboxed content over
Connect, which is the shape the plugin HTTP surface invites.
What I would expect
A page's own files reach it on every origin the page itself reaches.
Concretely: a fourth rung on the worker's credential ladder — a short-lived, signed, GET-only
grant, scoped to one user, one handle and one plugin, that the worker verifies and strips before
forwarding.
It has to ride in the URL path, not a query parameter: relative URL resolution drops the query,
so a query parameter never reaches a subresource, which is the entire problem. Shape:
/api/v1/plugins/<pluginId>/http/__grant/<token>/<rest...>
A document served under that prefix resolves style.css to the same prefix automatically.
Prototype: https://github.com/BartSoj/bb/tree/feat/connect-page-grant — one commit on 9e16411.
Mint endpoint beside the other /api/connect/* handlers, authenticated by the existing cookie
ladder; verification rung between the machine-credential rung and the cookie check; token is the
same HMAC payload scheme as the desktop session cookie (extracted to a shared module, existing
caller rewired, its tests unchanged); 1 hour TTL, matching DESKTOP_SESSION_TTL_MS. Refused:
non-GET/HEAD, a different user, handle or plugin, a --<port> share target, /internal, a
non-plugin path, percent-encoded traversal, a tampered signature. It bypasses serveWithCache so
the token never becomes an edge cache key, and it forwards through requestForTunnelDo, so the
same inbound headers are stripped as on every other rung, the machine-id header included.
pnpm exec turbo run test --filter=@bb/connect: 6 files, 133 tests pass; typecheck passes; the
rung was mutation-checked.
Heads-up: the unmerged branch bb/mobile-perf/connect-tunnel (last commit 2026-08-19)
rewrites the cookie check exactly where this rung sits. If that lands first, the rung moves with
it.
This depends on #1632. A path-segment grant is only serveable once a plugin can match a path
prefix; today plugin routes match exactly. See my comment there.
Context and alternatives
SameSite=Noneon the Connect cookies. Two lines and it would work. Rejected: it attaches
the cookie to every cross-site request to the Connect domain, including subresource GETs that
carry noOriginheader for bb's own origin checks to reject. That is a CSRF widening across
the product to fix one feature.Partitioned(CHIPS) would mitigate it, but I cannot test
browser support here, and it is a change to the whole auth system rather than to this feature.- Serving the files from a plugin prefix route with
auth: "none". Does not help on its own —
the edge 401s it before bb sees the route's auth mode. I believed this was the fix until the
fourth row of the table above; recording it so nobody else spends the time. - What I ship, and am keeping: the plugin resolves each relative reference when it serves the
document and rewrites it to adata:URL, so the entry document carries its own files. It works
on every origin. So this does not block my plugin — but every plugin that serves sandboxed
content over Connect has to discover the problem and build something like that resolver, it
costs document size (plus a third for base64), and page script still cannotfetch()its own
files. The grant would make the ordinary static-site shape just work. - Not a duplicate: searched open and closed issues for "connect", "cookie", "sandbox",
"subresource" and "getbb.app" in titles. Tolerate event-loop starvation in the connect tunnel heartbeat #2718, Evaluate safe retries for retryable Connect Durable Object dispatch failures #2065, Feature: connect Codex via device login from the BB UI #1683 and Codex provider does not expose account-backed Apps/connectors in BB threads #2429 are unrelated. Nothing on
mainup to9e16411adds a grant or changes the Connect cookies' SameSite.
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 13, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassification: Bug · Priority: Medium · Effort: High. Added
remote,plugins,connect, andpartial-repro; no existing classifications were replaced.Reproduction report: PARTIALLY REPRODUCED · confidence: medium. Five worker-level assertions passed in each of two clean checkouts of trusted
origin/main. Cookieless plugin requests and port-share GET/OPTIONS receive the 401 sign-in gate before host routing; a valid synthetic owner cookie passes authentication. Actual sandbox-driven browser cookie omission remains unverified.No PR: a complete remedy requires an authentication/security-boundary decision, outside this rule’s simple-fix criteria.
BartSoj commentedon Sep 25, 2026
Following up with the browser half the triage report could not run, a correction to my own
prototype, and the decision stated as options.
Live, on the real edge (bb 0.43.4, a signed-in
<handle>.getbb.apptab, Chrome 146 macOS).The same stored image and video, same tab, same session:
self.originhttps://<handle>.getbb.app<iframe sandbox="allow-scripts">null<iframe sandbox="allow-scripts allow-same-origin">https://<handle>.getbb.app<iframe>(no sandbox)https://<handle>.getbb.appOnly the opaque-origin frame fails; a cookieless request to the same URL is the
401sign-in pagefrom
cloudflare. The same result through a real plugin page (a Thread Pages page frame,sandbox="allow-scripts allow-forms"). iPhone Safari 26.6 behaves differently, through the same plugin page: the imageloads from the sandboxed frame (WebKit attaches the Lax cookie to element subresources), while a
fetch()from the frame is refused and the video still fails with error 4. Playwright's WebKitagreed on the image. So today a sandboxed page's own files half-work on iPhone and not at all in
Chrome — which makes the bug harder to see, not smaller: an author testing on an iPhone sees
images and nothing else.
To reproduce in one minute on any signed-in Connect tab (replace the path with any stored image):
A correction to the prototype. The issue says the grant token "is the same HMAC payload scheme
as the desktop session cookie". That was a bug: the desktop-cookie check only needs
userIdandexpiresAt, which a grant also carries, so a grant — a token that travels in URLs — could bereplayed as the desktop session cookie and pass as an account-wide session for its hour. The
branch is fixed: grants now carry their own
bbpg_prefix and are signed with a key derived byHKDF from the secret (the construction #4227 used for tunnel tickets); the desktop cookie's format
is byte-for-byte unchanged. A test pins the separation. Rebased onto
9c8112e, forwarding throughthe replaying tunnel helper from #4313;
@bb/connect157 tests (main 143). A Miniflare run of thereal worker with Playwright shows a sandboxed frame's image, script and
fetch()loading throughthe grant in Chromium, Firefox and WebKit, and a grant presented as a cookie refused.
https://github.com/BartSoj/bb/tree/feat/connect-page-grant
The decision, as options — any of them unblocks us; I would build 1:
one plugin, carried in the path so relative URLs inherit it; its own key.
SameSite=None; Partitionedon the Connect cookie. Two lines; widens every cross-siterequest's credentials, so CSRF on bb's routes would rest entirely on the Origin checks.
authenticates another domain.
the next author the discovery.
Related: #4339 (thread-storage files ignore
Range, so video can't seek and Safari won't play iteven with a cookie), #1632 (prefix routes, which option 1 needs), and #3708 (a required local
secret would bring the same case to loopback; see my comment there).
Embed inline-vis sibling files so remote previews show them (early ad…