Repository navigation
Description
Summary
The bb server authenticates host daemons on /internal/*, and since #1536 it rejects browser requests to /api/v1/* whose Origin is not trusted. Nothing else is checked. A request to /api/v1 or /ws that carries no Origin header, or one that arrives from a public hostname rebound to 127.0.0.1, is accepted with no credential at all. That means any process running as any user on the same machine, and any web page that can make a rebound request look like a local process (#1530 documented that these are header-indistinguishable), can list threads, read transcripts, send messages, and start terminals.
I would like the server to mint a per-install secret and require it on /api/v1, the SPA shell, and the /ws upgrades, while keeping the browser and CLI flows seamless. I have a working design on my fork and am offering to upstream it once the shape is agreed.
Versions and environment
- bb from source,
upstream/mainat33c1564e5e49499f3baef7da5dbf112b876d153f; also reproduced on the 0.43.1 desktop app - macOS 26.6, Node 22 / 26
- Loopback bind (the default since Bind the bb server to loopback by default #1125)
Steps to reproduce
-
Start bb normally (desktop app or
npx bb-app). It listens on127.0.0.1:38886. -
From any shell on the same machine, as any user:
curl -s http://127.0.0.1:38886/api/v1/threads | head -c 300 -
Observe the thread list. No header, cookie, or token was sent.
POSTroutes behave the same way; I stopped at read-only requests for this report.
Expected vs actual
Expected: 401 until a credential is presented.
Actual: 200 with the thread list. The Origin guard does not apply because curl sends no Origin.
Evidence
- Daemon-only auth in
apps/server/src/server.ts:Lines 565 to 575 in 33c1564
const daemon = await verifyAuthenticatedDaemon( deps, context.req.header("authorization"), ); setAuthenticatedDaemon(context, daemon); } catch { return unauthorizedResponse(); } return next(); }); const pluginService = createPluginService({ - Origin guard, which only fires when a browser
Originis present:Lines 655 to 660 in 33c1564
return next(); } const problem = browserRequestProblem(context, deps); if (problem !== null) { throw new ApiError(problem.status, "forbidden_origin", problem.error); } - Rebound public hostnames are header-indistinguishable from local processes #1530 (closed in the Aug 13 sweep) records that a rebound public hostname sends neither
OriginnorSec-Fetch-*, so header-based guards cannot see it.
What I ruled out
- Not Unauthenticated RCE: server binds all interfaces and /api/v1 has no auth #1124: that was the all-interfaces bind, fixed by Bind the bb server to loopback by default #1125. This report is about loopback clients.
- Not Loopback services with no browser-origin guard: /api/v1, second bb server, mock CLI traffic proxy #1531 / Guard bb's local HTTP services against foreign browser origins #1536: those added the browser
Originguard. This report is about requests with noOrigin. - Not Rebound public hostnames are header-indistinguishable from local processes #1530: that describes why header checks are insufficient and was closed without a fix; this proposes the fix.
- A host firewall does not help, since the caller is already on the machine.
Proposed design
Implemented on my fork as benwaffle@4709172, with one follow-up rule from benwaffle@6716c05:
- On first start the server writes a random token to
<dataDir>/api-token(mode 0600). The log records only the path. - Every
/api/v1request, the SPA shell, and/wsupgrades must present it either asAuthorization: Beareror as anHttpOnly; SameSite=Strictcookie.GET /auth/session?token=…installs the cookie and redirects to the app, so the launcher prints that session link as the app URL and the desktop main process installs the cookie before loading the window. - Loopback-bound servers also reject foreign
Hostheaders, which closes the rebound-hostname path on its own. - The CLI and Node SDK read
BB_API_TOKENor the token file. The in-process plugin SDK receives the token from the server. The host daemon receives it in the session-open response and layers it onto the agent shell environment asBB_API_TOKEN, sobbinside an agent shell keeps working, including on other enrolled machines that never see the token file. This is aHOST_DAEMON_PROTOCOL_VERSIONbump. - Bearer-authenticated requests skip the browser
Originguard: the guard exists to stop cross-origin pages from riding the cookie, and a caller that presents the secret itself has already proven possession. Cookie-authenticated requests keep theOriginrequirement.
Open questions I expect reviewers to raise: mobile and Connect relay clients (a ServerAccessGrant header fits), nested servers using the Account Pooler parent URL (#3654), and upgrade ordering for enrolled remote daemons.
Tests on the fork: apps/server/test/security/api-token-auth.test.ts, apps/server/test/security/api-origin-guard.test.ts, apps/host-daemon/src/app.test.ts.
Suggested priority and effort
High priority: it affects every install, there is no workaround short of not running other software on the machine, and the exposed operations include command execution through terminals. Effort is medium-to-large because of the client plumbing, but the fork commit shows the full scope (29 files).
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 15, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotApplied and verified Type: Feature, Priority: Urgent, Effort: High, label:
security. No existing classification values were present.Trusted main explicitly tests acceptance of callers without Origin. Requiring local credentials adds an authentication contract; Urgent reflects the reported security exposure, and High reflects the cross-client design work.
Final Type is Feature, so reproduction report and fix steps were skipped. No PR opened because authentication and security-boundary changes are outside the simple-fix rules.
BartSoj commentedon Sep 25, 2026
A consumer to keep in the design: plugins that serve sandboxed documents (
sandboxwithoutallow-same-origin). Such a frame has an opaque origin: it sendsOrigin: null, and itsrequests are cross-site — measured live on bb Connect 2026-09-25: Chrome 146 attaches the
SameSite=Laxcookie to none of them; iPhone Safari 26.6 attaches it to an
<img>, while afetch()from the frame isrefused and a
<video>still fails. So what reaches the server already differs by browser. Today on loopback it can still loadits own files because the local API asks for nothing; with a required secret it will not, exactly
as already happens over bb Connect (#3617).
Not asking to weaken the proposal — only that its credential have a path-scoped, GET-only,
short-lived form a plugin can hand to a document it serves (the same shape proposed in #3617), so
both surfaces get one mechanism rather than two.
nateberkopec commentedon Sep 28, 2026
Not agent but I agree with this. I'd like individual threads to be pretty well insulated from other threads, right now you can you just ping
/api/v1and potentially read/modify everything else that's going on.vipanait commentedon Oct 9, 2026
We'd like to see this land as well. We're evaluating bb as a locally-run tool for a team of developers, and an unauthenticated
/api/v1//wson loopback (with terminal and command execution behind it) is the first thing we'd need closed before recommending it internally. The design described here — per-install token file at 0600, Bearer orHttpOnly; SameSite=Strictcookie via/auth/session,BB_API_TOKENpassed into the agent shell, and theHostauthority check on loopback — matches what we'd have built ourselves. Is there a maintainer view on the shape?SawyerHood commentedon Oct 19, 2026
Consolidated unauthenticated-loopback report and sender-provenance requirements
Consolidating #4529 into this canonical tracker at the maintainer's request following the open-issue duplicate sweep.
#4529 supplies a concrete bb 0.44.0 Linux reproduction: an unauthenticated loopback request succeeds, and a CLI send with no BB_THREAD_ID is recorded as initiator=user / senderThreadId=null. Setting another thread's BB_THREAD_ID can spoof that sender. The original commands and observed event shape remain in #4529.
The authentication portion belongs here. Preserve these additional requirements explicitly:
A single shared API token does not automatically solve sender attribution. Coordinate the provenance work with #3621 and host-verified authorization in #1541; if delivered separately, keep it linked and outstanding rather than closing it with the basic authentication fix.
#4529 is being closed for consolidation, not because the exposure is resolved or all of its scope is an exact duplicate.
ShiawasenaHoshi commentedon Nov 23, 2026
On the first checklist item (scoped agent credentials), two concrete points from a setup where agents already run as a separate OS user (bb 0.49.0; code references checked against current
main):POST /api/v1/threads/:id/interactions/:interactionId/resolve), install or enable plugins, and change settings, providers and skills. A thread-scoped credential that gets403on exactly these routes would close that and keep every normal agent workflow working.plugin-rpc-caller.tsalready mints per-caller tokens, butresolve(undefined)returnsclient, so a request with no token is not treated as an agent.POST /internal/hosts/enroll-keyis exempt from daemon auth and only asserts a loopback peer (apps/server/src/internal/hosts.ts), so by my reading of the code any local process can mint an enrollment key and then enroll as a host daemon. The design described above covers/api/v1, the SPA shell and/ws, so this route would stay as it is.Happy to prototype (1) and (2) with tests on top of the proposed design, if that's useful.
feat(bb): install bb and reach it over Tailscale through an identity …