Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(plugin): keep proxied network guard public-only

liugaoweidfe0caa36ea1
diff --git a/apps/desktop/src/main/maker-host/__tests__/outboundFetch.test.ts b/apps/desktop/src/main/maker-host/__tests__/outboundFetch.test.ts
index cb0414f104..66ccea8c73 100644
--- a/apps/desktop/src/main/maker-host/__tests__/outboundFetch.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/outboundFetch.test.ts
@@ -336,6 +336,22 @@ describe('outboundFetch', () => {
expect(undiciState.fetch).not.toHaveBeenCalled();
});
+ it.each([
+ 'https://198.18.0.1/data',
+ 'https://[fc00::1]/data',
+ ])('does not treat selecting a proxy as authorization for special-use target %s', async (url) => {
+ resolverState.resolve.mockResolvedValue('http://127.0.0.1:7890');
+ loggerState.debug.mockClear();
+
+ await expect(guardedOutboundFetch(url, { method: 'GET' }, vi.fn())).rejects.toThrow(/blocked/i);
+
+ expect(undiciState.fetch).not.toHaveBeenCalled();
+ expect(loggerState.debug).not.toHaveBeenCalledWith(
+ 'creating outbound proxy dispatcher',
+ expect.anything(),
+ );
+ });
+
it('passes the proxy dispatcher through to undici fetch', async () => {
resolverState.resolve.mockResolvedValue('http://127.0.0.1:7890');
await outboundFetch('https://platform.claude.com/v1/oauth/token', { method: 'POST' });
diff --git a/apps/desktop/src/main/maker-host/outbound-fetch.ts b/apps/desktop/src/main/maker-host/outbound-fetch.ts
index d9661b5c07..bb65cb4fc0 100644
--- a/apps/desktop/src/main/maker-host/outbound-fetch.ts
+++ b/apps/desktop/src/main/maker-host/outbound-fetch.ts
@@ -50,10 +50,7 @@ import {
TunnelingHttpsAgent,
type OutboundProxyTarget,
} from '@cindy/anthropic-compat-proxy';
-import {
- fetchSingleHopWithSsrFGuard,
- type SsrFPolicy,
-} from '@cindy/browser-control-runtime/ssrf-runtime';
+import { fetchSingleHopWithSsrFGuard } from '@cindy/browser-control-runtime/ssrf-runtime';
import { createMakerLogger } from './logger-adapter.js';
import { resolveDesktopOutboundProxy } from './outbound-proxy-resolver.js';
@@ -524,13 +521,6 @@ function createPinnedProxyDispatcher(
})();
}
-const PROXIED_PUBLIC_SSRF_POLICY: SsrFPolicy = {
- // Clash / sing-box / Surge 的 fake-IP DNS 只在已经确定走代理时放行;其它
- // RFC1918、loopback、link-local 与 metadata 地址仍由默认策略阻断。
- allowRfc2544BenchmarkRange: true,
- allowIpv6UniqueLocalRange: true,
-};
-
/**
* Agent 在途访问未声明公网目标的单跳出口:沿用 Desktop 的系统/PAC/env 代理判定,
* 但无论直连还是代理都只连接 SSRF 守门已确认的地址。beforeDispatch 在代理解析与
@@ -551,7 +541,6 @@ export async function guardedOutboundFetch(
requireHttps: true,
...(proxy
? {
- policy: PROXIED_PUBLIC_SSRF_POLICY,
dispatcherFactory: ({ url: guardedUrl, pinned }) =>
createPinnedProxyDispatcher(proxy, guardedUrl, pinned.addresses),
}
diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.md
index 4142cf50f5..6b6acb15e6 100644
--- a/docs/dev-rules/plugin-security-and-authoring.md
+++ b/docs/dev-rules/plugin-security-and-authoring.md
@@ -103,7 +103,8 @@
他插件、scheduler 脚本、Panel 和后台调用都不得借此绕过自主能力声明。
对未声明公网目标,Host 必须在每一跳完成代理选择与 DNS/IP 守门后、真正 dispatch
前再次复核同一 `callId`;直连与系统代理都只能连接该次守门确认的 IP,代理不得
- 重新解析插件提供的域名。
+ 重新解析插件提供的域名。选中代理不构成私网授权;无法证明由当前代理生成的 fake-IP
+ 仍按特殊用途/私有地址拒绝。
- 安装/更新不以弹窗点击作为能力授权事实;
**prompt 和前端展示都不构成安全边界**。
- 新增或修改能力声明时,除同步编写手册与校验(下节 6)外,还必须同步 shared 类型、