Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: require host control to drive the signed-in managed browser and read its downloads (#12488)

[._.]/ Adam Eivyf6a71ae0b44d
diff --git a/client/src/pages/Browser.jsx b/client/src/pages/Browser.jsx
index 2daba031fa..df807d7108 100644
--- a/client/src/pages/Browser.jsx
+++ b/client/src/pages/Browser.jsx
@@ -20,6 +20,9 @@ import { formatBytes, formatDateTime, formatDurationMs } from '../utils/formatte
import { pluralize } from '../lib/textUtils';
const STATUS_EVENTS = ['browser:changed'];
+// Mirrors HOST_CONTROL_FORBIDDEN_MESSAGE; the status read stays open but omits
+// page and download listings for a caller without host control (#12488).
+const HOST_CONTROL_NOTE = 'Open pages and downloads need an operator session, or a local connection when no password is set. Set an instance password to use them remotely.';
const readStatus = () => getBrowserStatus({ silent: true });
function deriveMacAppBundle(chromePath) {
@@ -543,7 +546,9 @@ export default function BrowserPage() {
</button>
{showPages && (
<div className="border-t border-port-border">
- {!status?.pages || status.pages.length === 0 ? (
+ {status?.contentRedacted ? (
+ <div className="p-4 text-sm text-gray-500">{HOST_CONTROL_NOTE}</div>
+ ) : !status?.pages || status.pages.length === 0 ? (
<div className="p-4 text-sm text-gray-500">
{isConnected ? 'No pages open' : 'Browser not connected'}
</div>
@@ -597,7 +602,9 @@ export default function BrowserPage() {
<span className="font-mono truncate">{status.downloads.downloadDir}</span>
</div>
)}
- {!status?.downloads?.files || status.downloads.files.length === 0 ? (
+ {status?.contentRedacted ? (
+ <div className="p-4 text-sm text-gray-500">{HOST_CONTROL_NOTE}</div>
+ ) : !status?.downloads?.files || status.downloads.files.length === 0 ? (
<div className="p-4 text-sm text-gray-500">No downloads</div>
) : (
<div className="divide-y divide-port-border">
diff --git a/docs/API.md b/docs/API.md
index 7ce8d2f498..b4eaa295e8 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -656,16 +656,16 @@ return an `{ items, total }` envelope.
| Method | Endpoint | Description |
|--------|----------|-------------|
-| GET | `/browser` | Get browser status |
+| GET | `/browser` | Get browser status. Callers without host control get `contentRedacted: true` with empty `pages` and download `files` (host control also gates `/browser/downloads` and `/browser/downloads/:name`) |
| GET | `/browser/config` | Get browser configuration |
| PUT | `/browser/config` | Update browser configuration |
| POST | `/browser/launch` | Launch browser instance |
| POST | `/browser/stop` | Stop browser instance |
| POST | `/browser/restart` | Restart browser instance |
-| POST | `/browser/navigate` | Navigate browser to URL |
+| POST | `/browser/navigate` | Navigate browser to URL (host control: the profile carries the operator's signed-in sessions) |
| GET | `/browser/health` | Get browser health status |
| GET | `/browser/process` | Get browser process info |
-| GET | `/browser/pages` | Get open browser pages |
+| GET | `/browser/pages` | Get open browser pages (host control) |
| GET | `/browser/version` | Get browser version info |
| GET | `/browser/logs` | Get browser logs |
diff --git a/server/lib/hostControlRoutes.js b/server/lib/hostControlRoutes.js
index c557976acf..28ca48585d 100644
--- a/server/lib/hostControlRoutes.js
+++ b/server/lib/hostControlRoutes.js
@@ -118,8 +118,13 @@
* the path-based Gmail mbox import. Rename/notes/mode PATCHes, bucket
* export into an operator-chosen bucket, and the upload-based importers
* stay open: they name no host path.
- * - browser: navigate uses the configured browser with its URL/IP guards;
- * downloads DELETE removes data. Harness models/refresh re-reads the
+ * - browser (#12488): the managed profile carries the operator's signed-in
+ * sessions and saves downloads silently, so navigate, the page list and
+ * the downloads list/file reads are gated (steering it or reading what it
+ * saved is operator work; the URL/IP guards only stop private-network
+ * targets). `GET /api/browser` stays open but omits page and download
+ * listings for a caller without host control. Downloads DELETE only
+ * removes data. Harness models/refresh re-reads the
* configured harness catalog; neither selects or installs an executable.
* - local-llm (#8798): install/delete/migrate and llama-server download-model
* (including cancel/remove), mtplx models/pull/remove and slotstream
@@ -700,6 +705,10 @@ export const HOST_CONTROL_ROUTES = Object.freeze([
'POST /api/browser/launch',
'POST /api/browser/restart',
'POST /api/browser/stop',
+ 'POST /api/browser/navigate',
+ 'GET /api/browser/pages',
+ 'GET /api/browser/downloads',
+ 'GET /api/browser/downloads/:name',
'POST /api/harnesses/action',
'POST /api/local-llm/laya-mlx/install',
'POST /api/local-llm/security-guard/install',
diff --git a/server/lib/hostControlRoutes.test.js b/server/lib/hostControlRoutes.test.js
index 385acb651a..7565b3e880 100644
--- a/server/lib/hostControlRoutes.test.js
+++ b/server/lib/hostControlRoutes.test.js
@@ -224,7 +224,6 @@ describe('X (Twitter) review and browser automation policy', () => {
// of silently falling through the inventory's one-way "listed routes exist" check.
describe('browser/runtime/database mutation inventory (#8798, #8897)', () => {
const dataOrInference = [
- 'POST /api/browser/navigate',
'DELETE /api/browser/downloads/:name',
'POST /api/harnesses/models/refresh',
...[
diff --git a/server/routes/browser.js b/server/routes/browser.js
index 30dd21c1cd..4a1daa54ea 100644
--- a/server/routes/browser.js
+++ b/server/routes/browser.js
@@ -6,6 +6,7 @@ import { validateChromePath, validateMacAppBundle } from '../lib/browserConfig.j
import { isSafeIngestUrl, isBlockedIngestHost } from '../lib/catalogValidation.js';
import { assertPublicHttpUrl } from '../lib/safeUrlFetch.js';
import { getBrowserStatusSnapshot } from '../services/browserStatus.js';
+import { requestHasHostControl } from '../services/authGate.js';
import * as browserService from '../services/browserService.js';
const router = express.Router();
@@ -83,7 +84,15 @@ const updateConfigSchema = z.object({
// GET /api/browser - Full browser status
router.get('/', asyncHandler(async (req, res) => {
const status = await getBrowserStatusSnapshot();
- res.json(status);
+ // Page titles/URLs and saved filenames come from the signed-in profile; only
+ // a caller who may drive that profile (see HOST_CONTROL_ROUTES) sees them.
+ if (requestHasHostControl(req)) return res.json(status);
+ res.json({
+ ...status,
+ pages: [],
+ downloads: { ...status.downloads, files: [] },
+ contentRedacted: true,
+ });
}));
// GET /api/browser/config - Get browser config
diff --git a/server/routes/hostControlBrowser.test.js b/server/routes/hostControlBrowser.test.js
new file mode 100644
index 0000000000..f429e49e90
--- /dev/null
+++ b/server/routes/hostControlBrowser.test.js
@@ -0,0 +1,124 @@
+import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { EventEmitter } from 'node:events';
+import express from 'express';
+import { request } from '../lib/testHelper.js';
+import { errorMiddleware } from '../lib/errorHandler.js';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js';
+import { derivePeerAuthToken, PEER_AUTH_HEADER, PEER_INSTANCE_HEADER } from '../lib/peerHttpClient.js';
+
+vi.mock('../lib/fileUtils.js', async (importOriginal) =>
+ makePathsProxy(await importOriginal(), { dataRoot: () => lazyTempDataRoot('portos-browser-authority-') }));
+afterAll(cleanupTempDataRoots);
+
+const auth = vi.hoisted(() => ({ enabled: false }));
+vi.mock('../services/auth.js', async (importOriginal) => ({
+ ...await importOriginal(),
+ isAuthEnabled: vi.fn(async () => auth.enabled),
+}));
+
+vi.mock('../services/settings.js', () => ({
+ settingsEvents: new EventEmitter(),
+ getSettings: vi.fn(async () => ({})),
+}));
+
+vi.mock('../services/instanceIdentity.js', () => ({
+ loadData: vi.fn(async () => ({ peers: [{
+ id: 'example-peer', instanceId: 'example-instance', enabled: true, syncSecret: 'a'.repeat(32),
+ }] })),
+}));
+
+const svc = vi.hoisted(() => ({
+ navigateToUrlPinned: vi.fn(async (url) => ({ id: 'tab-1', url })),
+ getOpenPages: vi.fn(async () => [{ id: 'p1', title: 'Inbox', url: 'https://example.com/inbox' }]),
+ getDownloads: vi.fn(async () => ({ downloadDir: '/d', files: [{ name: 'secret.json' }] })),
+ resolveDownload: vi.fn(async () => null),
+}));
+vi.mock('../services/browserService.js', () => ({ browserEvents: new EventEmitter(), ...svc }));
+
+const snapshot = {
+ connected: true,
+ pages: [{ id: 'p1', title: 'Inbox', url: 'https://example.com/inbox' }],
+ pageCount: 1,
+ downloads: { downloadDir: '/d', files: [{ name: 'secret.json' }] },
+};
+vi.mock('../services/browserStatus.js', () => ({ getBrowserStatusSnapshot: vi.fn(async () => snapshot) }));
+
+vi.mock('../lib/safeUrlFetch.js', () => ({ assertPublicHttpUrl: vi.fn(async () => {}) }));
+
+import { authGate, hostControlRouteGate } from '../services/authGate.js';
+import { createSession } from '../services/auth.js';
+import browserRoutes from './browser.js';
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ auth.enabled = false;
+});
+
+const appFor = (address) => {
+ const app = express();
+ app.use((req, _res, next) => {
+ Object.defineProperty(req.socket, 'remoteAddress', { value: address });
+ next();
+ });
+ app.use(authGate, hostControlRouteGate, express.json());
+ app.use('/api/browser', browserRoutes);
+ app.use(errorMiddleware);
+ return app;
+};
+
+const withHeaders = (pending, headers) => {
+ for (const [name, value] of Object.entries(headers)) pending.set(name, value);
+ return pending;
+};
+
+const calls = (app, headers) => [
+ ['navigate', () => withHeaders(request(app).post('/api/browser/navigate'), headers).send({ url: 'https://example.com/' })],
+ ['pages', () => withHeaders(request(app).get('/api/browser/pages'), headers)],
+ ['downloads list', () => withHeaders(request(app).get('/api/browser/downloads'), headers)],
+ ['download file', () => withHeaders(request(app).get('/api/browser/downloads/secret.json'), headers)],
+];
+
+describe('managed browser profile authority (#12488)', () => {
+ it.each([
+ ['remote without auth', false, {}, 403, 'HOST_CONTROL_FORBIDDEN'],
+ ['scoped peer', true, {
+ [PEER_AUTH_HEADER]: derivePeerAuthToken('a'.repeat(32), 'example-instance'), [PEER_INSTANCE_HEADER]: 'example-instance',
+ }, 403, 'PEER_SCOPE_FORBIDDEN'],
+ ])('refuses %s and never touches the browser', async (_name, enabled, headers, status, code) => {
+ auth.enabled = enabled;
+ const app = appFor('192.0.2.10');
+ for (const [label, send] of calls(app, headers)) {
+ const res = await send();
+ expect(res.status, label).toBe(status);
+ expect(res.body.code, label).toBe(code);
+ }
+ expect(svc.navigateToUrlPinned).not.toHaveBeenCalled();
+ expect(svc.getOpenPages).not.toHaveBeenCalled();
+ expect(svc.getDownloads).not.toHaveBeenCalled();
+ expect(svc.resolveDownload).not.toHaveBeenCalled();
+ });
+
+ it('keeps the routes for a local caller and an operator session', async () => {
+ const local = appFor('127.0.0.1');
+ expect((await request(local).post('/api/browser/navigate').send({ url: 'https://example.com/' })).status).toBe(200);
+ expect((await request(local).get('/api/browser/pages')).status).toBe(200);
+
+ const session = await createSession({ label: 'operator' });
+ auth.enabled = true;
+ const remote = appFor('192.0.2.10');
+ const headers = { Cookie: `portos_auth=${session.token}` };
+ expect((await withHeaders(request(remote).get('/api/browser/downloads'), headers)).status).toBe(200);
+ expect((await withHeaders(request(remote).get('/api/browser/downloads/secret.json'), headers)).status).toBe(404);
+ });
+
+ it('status read stays open but omits page and download listings without host control', async () => {
+ const remote = await request(appFor('192.0.2.10')).get('/api/browser');
+ expect(remote.status).toBe(200);
+ expect(remote.body).toMatchObject({ pages: [], pageCount: 1, contentRedacted: true, downloads: { files: [] } });
+
+ const local = await request(appFor('127.0.0.1')).get('/api/browser');
+ expect(local.body.pages).toHaveLength(1);
+ expect(local.body.downloads.files).toHaveLength(1);
+ expect(local.body.contentRedacted).toBeUndefined();
+ });
+});