Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(security): require exec for A2A loopback discovery

Abdurrahman Fakhruled8e60303faf
diff --git a/lib/mcp/tools-a2a.test.ts b/lib/mcp/tools-a2a.test.ts
index e2943ef4..34cd7de2 100644
--- a/lib/mcp/tools-a2a.test.ts
+++ b/lib/mcp/tools-a2a.test.ts
@@ -67,3 +67,25 @@ describe("MCP A2A tools", () => {
expect(JSON.stringify(mocks.send.mock.calls[0])).not.toContain("hidden-session");
});
});
+
+
+describe("A2A discovery network authority", () => {
+ it("keeps public HTTPS discovery readable but requires exec for loopback HTTP", async () => {
+ mocks.discover.mockResolvedValue(peer);
+ const tool = byName.get("a2a_agent_discover")!;
+ await expect(tool.run({ url: "https://peer.example" }, {
+ principal: "mcp-client:test", scope: "read", actor: "test",
+ })).resolves.toMatchObject({ name: "Peer" });
+ expect(mocks.discover).toHaveBeenCalledWith("https://peer.example");
+
+ mocks.discover.mockClear();
+ await expect(tool.run({ url: "http://127.0.0.1:4555/card" }, {
+ principal: "mcp-client:test", scope: "read", actor: "test",
+ })).rejects.toThrow(/requires exec/);
+ expect(mocks.discover).not.toHaveBeenCalled();
+
+ await expect(tool.run({ url: "http://127.0.0.1:4555/card" }, {
+ principal: "mcp-client:test", scope: "exec", actor: "test",
+ })).resolves.toMatchObject({ name: "Peer" });
+ });
+});
diff --git a/lib/mcp/tools-a2a.ts b/lib/mcp/tools-a2a.ts
index 3e8725b2..d9f66459 100644
--- a/lib/mcp/tools-a2a.ts
+++ b/lib/mcp/tools-a2a.ts
@@ -1,3 +1,4 @@
+import { isA2ALoopbackUrl } from "@/lib/a2a/network";
import { createHash } from "node:crypto";
import { cancelA2ATask, discoverA2AAgent, getA2ATask, handoffA2A, listA2AAgents, registerA2AAgent, removeA2AAgent, resolveA2AAgent, sendA2AMessage } from "@/lib/a2a";
import type { A2ADiscoveredAgent, A2ARegisteredAgent } from "@/lib/a2a";
@@ -30,10 +31,14 @@ export const A2A_TOOLS: McpTool[] = [
},
{
name: "a2a_agent_discover",
- description: "Discover and validate a public A2A v1 Agent Card using the standard /.well-known/agent-card.json path. Only public HTTPS endpoints are allowed; private/loopback targets and DNS rebinding are blocked.",
+ description: "Discover and validate an A2A v1 Agent Card. Public HTTPS discovery is read-scoped; exact loopback HTTP additionally requires exec authority and the host opt-in. Private/LAN targets and DNS rebinding are blocked.",
scope: "read", annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true }, limit: { key: "a2a.discovery", max: 20, windowMs: 60_000 },
inputSchema: S({ url: { type: "string", description: "Public agent origin or direct Agent Card URL." } }, ["url"]),
- run: async (a) => cardSummary(await discoverA2AAgent(str(a, "url"))),
+ run: async (a, context) => {
+ const url = str(a, "url");
+ if (isA2ALoopbackUrl(url) && context.scope !== "exec") throw new Error("A2A loopback discovery requires exec authority");
+ return cardSummary(await discoverA2AAgent(url));
+ },
},
{
name: "a2a_agent_register",