Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): block credential-path reads even under full access
Chris560be76751f0
diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.tsindex 28eac59bcd..c8c9c56be8 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts@@ -788,7 +788,7 @@ describe.skipIf(!piAvailable)('PiAgent integration (real pi binary + fake gatewaasync function runPermissionTurn(opts: {sessionId: string;workingDir: string;- permissionMode: 'ask' | 'auto';+ permissionMode: 'ask' | 'auto' | 'bypassPermissions';resolverBehavior: 'allow' | 'deny';}): Promise<{ resolverTools: string[]; finalText: string }> {const agent = new PiAgent(buildDeps());@@ -959,6 +959,38 @@ describe.skipIf(!piAvailable)('PiAgent integration (real pi binary + fake gatewa},);+ it(+ 'full access still blocks credential reads (parent env holds the proxy session token)',+ { timeout: 60_000 },+ async () => {+ // greptile 回归:bypassPermissions 提前返回不得跳过凭证路径检查,否则内置 read+ // 可读 /proc/self/environ 之类路径拿到父进程里的代理 token,绕过审批盗刷额度。+ const workingDir = mkdtempSync(path.join(tmpdir(), 'pi-perm-bypass-cred-'));+ try {+ scriptedResponses.length = 0;+ scriptedResponses.push(+ anthropicToolUseBody('read', { path: '/proc/self/environ' }),+ anthropicStreamBody('bypass cred turn finished'),+ );+ const reqBefore = seenRequests.length;+ const { resolverTools } = await runPermissionTurn({+ sessionId: 'perm-bypass-cred',+ workingDir,+ permissionMode: 'bypassPermissions',+ resolverBehavior: 'allow', // 若误弹窗且被 allow,下面的 block 理由断言就会失败+ });+ // Full access 不弹窗,直接硬拦+ expect(resolverTools).toEqual([]);+ const followUp = seenRequests.slice(reqBefore).map((r) => r.body);+ expect(followUp.some((b) => b.includes('Cindy blocks reading credential or key paths'))).toBe(true);+ expect(followUp.some((b) => b.includes('CINDY_PI_SESSION_TOKEN='))).toBe(false);+ } finally {+ rmSync(workingDir, { recursive: true, force: true });+ scriptedResponses.length = 0;+ }+ },+ );+it('plain reads still pass the bridge untouched (no popup, tool executes)',{ timeout: 60_000 },diff --git a/packages/maker-core/src/agents/pi/cindy-bridge-source.ts b/packages/maker-core/src/agents/pi/cindy-bridge-source.tsindex 24f7a0da95..10ee096d21 100644--- a/packages/maker-core/src/agents/pi/cindy-bridge-source.ts+++ b/packages/maker-core/src/agents/pi/cindy-bridge-source.ts@@ -321,8 +321,17 @@ export default async function cindyBridge(pi: any) {) {return { block: true, reason: 'Cindy extra reference directories are read-only.' };}+ // 凭证/密钥路径的内置只读工具(read/grep/find/ls)在 Pi 父进程内执行,而父进程 env+ // 必须保留代理会话 token 与 BYOM keys($ENV 请求期解析、bridge client 使用)。Full+ // access 若放行 read /proc/self/environ 这类路径,模型可直接取 token 调回环代理,+ // 绕过审批盗刷当前会话额度(greptile 报)→ 即使 bypassPermissions 也硬拦。bash 无此+ // 通道(spawn 边界已按名单剥离真值),维持既有档位约束即可。+ const credentialRead = READONLY_BUILTINS.has(event.toolName) && touchesCredentialPath(event.input);+ if (credentialRead && permission.mode === 'bypassPermissions') {+ return { block: true, reason: 'Cindy blocks reading credential or key paths, even with Full access.' };+ }if (permission.mode === 'bypassPermissions') return;- if (READONLY_BUILTINS.has(event.toolName) && !touchesCredentialPath(event.input)) return;+ if (READONLY_BUILTINS.has(event.toolName) && !credentialRead) return;let approved = false;try {approved = await ctx.ui.confirm(