Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser-extension): unverified official-id claimants cannot pair browsers; bound plugin relay answers
Dash5ea23c6abdd2
diff --git a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.tsindex 81e9bd4fe6..6c6ffe3aa4 100644--- a/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts+++ b/apps/desktop/src/main/browser-extension/__tests__/bridge.test.ts@@ -493,6 +493,18 @@ describe('bridge · 作业生命周期', () => {expect((await clicked).ok).toBe(true);});+ // Review 2026-10-30 (Codex P1): a relayed answer from a plugin is bounded before it is held.+ it('插件返回的转交结果过大时改为结构化失败', async () => {+ const { bridge, ready } = await fixture();+ const c = await ready();+ const job = { id: crypto.randomUUID(), request: { op: 'translate', text: 'hello', source: { url: 'https://example.test/' } } };+ expect((await c.signed('/learning/start', job)).ok).toBe(true);+ expect(bridge.relayResult(job.id, { ok: true, translations: ['x'.repeat(9_000_000)] })).toEqual({ ok: true });+ const answer = await c.signed('/learning/result', { id: job.id });+ expect(answer.done).toBe(true);+ expect(answer.result).toMatchObject({ ok: false, error: 'RESULT_TOO_LARGE' });+ });+// Review 2026-10-30 (Codex P1): debugger events are [method, params] tuples and must stay arrays.it('cdp 事件列表保留元组形状并按数量封顶', async () => {const { bridge, ready } = await fixture();diff --git a/apps/desktop/src/main/browser-extension/bridge.ts b/apps/desktop/src/main/browser-extension/bridge.tsindex 2a8300ca60..bf3d9aa155 100644--- a/apps/desktop/src/main/browser-extension/bridge.ts+++ b/apps/desktop/src/main/browser-extension/bridge.ts@@ -208,6 +208,8 @@ const LIST_ENTRY_CAPS: ReadonlyArray<readonly [string, number]> = [['events', 5000],];const ENTRY_STRING_MAX = 8192;+/** Largest plugin answer to a relayed extension request (translations and subtitles included). */+const RELAY_RESULT_MAX_CHARS = 8_000_000;const TEXT_RESULT_MAX = 400_000;export class BrowserExtensionBridge {@@ -1123,6 +1125,16 @@ export class BrowserExtensionBridge {const found = this.relayItem(id);if (!found || !found.valid) return failure('REQUEST_CANCELLED', 'Request no longer active.');if (!found.item.result) {+ // The plugin's answer is held for minutes and serialized again for each poll; bound its size so a+ // faulty or hostile plugin cannot fill Main's memory. Over the bound it becomes a structured failure.+ let size = Number.POSITIVE_INFINITY;+ try {+ size = JSON.stringify(result)?.length ?? 0;+ } catch {+ // Not serializable: treated as too large.+ }+ if (size > RELAY_RESULT_MAX_CHARS)+ result = { ok: false, error: 'RESULT_TOO_LARGE', message: 'The plugin result is too large.' };found.item.result = result;found.item.expiresAt = this.now() + RELAY_TIMING.resultRetention;this.options.log?.info('browser extension relay answered', {diff --git a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.tsindex 797a91221e..cf95354650 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/browserExtensionSlot.test.ts@@ -433,6 +433,25 @@ describe('browserExtensionSlot · 管子上行', () => {expect(await slot.handleRequest('_root__my-browser', { kind: 'status' })).toMatchObject({ ok: true });});+ // Review 2026-10-30 (Codex P1): a package that only claims the official id cannot pair browsers.+ it('只自称官方 id 的未核验包不能保存配对', async () => {+ const clients = [{ id: 'c1', origin: 'chrome-extension://' + CHROME_ID, extensionId: CHROME_ID, publicKey: 'k' }];+ const { slot, bridges, settle, ghosts } = await makeSlot({ isVerifiedOfficial: () => false });+ slot.reconcile(ghosts);+ await settle();+ expect(await slot.handleRequest('_root__my-browser', { kind: 'setTrustedClients', clients })).toMatchObject({+ ok: false,+ errorCode: 'PERMISSION_DENIED',+ });+ expect(bridges[0].calls.some(([name]) => name === 'setTrustedClients')).toBe(false);+ // Another plugin id is not an official claimant: its pairings work as before.+ const other = [extGhost({ id: 'other-browser', nativeHost: false })];+ const b = await makeSlot({ isVerifiedOfficial: () => false }, other);+ b.slot.reconcile(other);+ await b.settle();+ expect(await b.slot.handleRequest('_root__other-browser', { kind: 'setTrustedClients', clients: [] })).toEqual({ ok: true });+ });+// Review 2026-10-30 (Codex P1): raw DevTools commands from a plugin that is not the verified official one.it('非官方插件不能经管子发原始 DevTools 命令', async () => {const payload = { kind: 'act', action: 'cdp', payload: { url: 'https://example.test', tabId: 1, op: 'command', method: 'DOM.setFileInputFiles', params: { files: ['/etc/hosts'] } } };diff --git a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.tsindex 7327dd2e25..2164276cd7 100644--- a/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts+++ b/apps/desktop/src/main/cindy-brain/browserExtensionSlot.ts@@ -60,6 +60,11 @@ const OFFICIAL_NATIVE_HOSTS: ReadonlyMap<string, string> = new Map([['my-browser', 'com.makecindy.browser'],]);+/** A package that claims an official id without verified source gets no trust of any kind. */+function claimsUnverifiedOfficialId(ghost: InstalledGhost, verified: boolean): boolean {+ return !verified && OFFICIAL_NATIVE_HOSTS.has(ghost.manifest.id);+}+export function mayInstallNativeHost(ghost: InstalledGhost, verified = true): boolean {const name = ghost.manifest.browserExtension?.nativeHost?.name;return (@@ -432,6 +437,11 @@ export class GhostBrowserExtensionSlot {case 'setPolicy':return entry.bridge.setPolicy() as GhostPipeBrowserExtensionResult;case 'setTrustedClients': {+ // A package that only claims the official id could read an unpaired client's key through+ // status and pin it back; it gets no pairings at all (native binding is its only way in, and+ // it has none).+ if (claimsUnverifiedOfficialId(entry.ghost, this.deps.isVerifiedOfficial(entry.ghost)))+ return fail('PERMISSION_DENIED', '未核验来源的插件不能保存浏览器配对');let applied: { ok: true };try {applied = entry.bridge.setTrustedClients(req.clients);