dsh-agy-link 0.4.75 → 0.4.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.76 (2026-10-29)
4
+
5
+ ### English
6
+
7
+ - **Security(mcp): enforce `mcpToolAllowlist` at execution time, not just on `/tools`.**
8
+ - `GET /tools` filtered the served set by `mcpToolAllowlist`, but `POST /call` accepted any tool name (except the internal `run_code`/`agy_ask`). The agy child holds the bridge bearer token, so a prompt-injected or compromised child could `POST /call` for a tool the operator never exposed (e.g. `bash`, `write`) and bypass the allowlist entirely. `/call` now returns **403 `tool not allowed`** for any tool outside a non-empty allowlist, and audit-logs it as `mcp call <tool> [denied: not in allowlist]`. Empty allowlist still means "all non-internal tools" (unchanged).
9
+ - **Security(mcp): stop exposing the internal `agy_tool` mirror over the bridge.**
10
+ - The internal-tool filter only excluded `run_code`/`agy_ask`, so the activity-mirror tool `agy_tool` (which replays recorded agy tool activity back into DSH) was listed by `/tools` and executable via `/call` — letting the external agy child re-enter the bridge. The exclusion set is now centralized (`INTERNAL_TOOL_NAMES = run_code, agy_ask, agy_tool`) and enforced identically when listing and when executing, so the two can never drift.
11
+
12
+ ### 中文
13
+
14
+ - **安全(MCP):`mcpToolAllowlist` 现在在「执行时」强制生效,而不只是过滤 `/tools` 列表。**
15
+ - 此前 `/tools` 按 allowlist 过滤,但 `POST /call` 只拦内部 `run_code`/`agy_ask`,任意工具名都会被真正执行。agy 子进程本身持有桥接 token,因此被提示词注入或攻陷的子进程可以 `POST /call` 调用运维并未暴露的工具(如 `bash`、`write`),完全绕过 allowlist。现在非空 allowlist 之外的 `/call` 一律返回 **403 `tool not allowed`**,并审计为 `mcp call <tool> [denied: not in allowlist]`。空 allowlist 仍表示「全部非内部工具」(行为不变)。
16
+ - **安全(MCP):不再把内部的 `agy_tool` 镜像工具暴露给桥接。**
17
+ - 内部工具过滤此前只排除 `run_code`/`agy_ask`,导致「活动镜像」工具 `agy_tool`(把 agy 记录的工具活动回放到 DSH)会被 `/tools` 列出、并可经 `/call` 执行,等于让外部 agy 子进程重新进入桥接。现将内部工具集合集中为 `INTERNAL_TOOL_NAMES = run_code, agy_ask, agy_tool`,在「列出」与「执行」两处统一生效,避免两处漂移。
18
+
19
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.75...v0.4.76
20
+
3
21
  ## 0.4.75 (2026-10-29)
4
22
 
5
23
  ### English
package/dist/index.js CHANGED
@@ -34642,6 +34642,20 @@ var WarmupService = class {
34642
34642
  //#endregion
34643
34643
  //#region src/host/mcp-bridge.ts
34644
34644
  const MCP_SERVER_KEY = "dsh-tools";
34645
+ /**
34646
+ * Tools that must NEVER be exposed to an external MCP client. These are
34647
+ * internal transports / loopback-only helpers of the plugin itself:
34648
+ * - `run_code` — the deployment's model-only wrapper around code execution.
34649
+ * - `agy_ask` — the plugin's own ask tool (would recurse into agy).
34650
+ * - `agy_tool` — replays recorded agy tool activity back into DSH; calling it
34651
+ * over the bridge would let the agy child re-enter the bridge.
34652
+ * Kept in one place so the /tools listing and the /call guard can never drift.
34653
+ */
34654
+ const INTERNAL_TOOL_NAMES = /* @__PURE__ */ new Set([
34655
+ "run_code",
34656
+ "agy_ask",
34657
+ "agy_tool"
34658
+ ]);
34645
34659
  /** MCP tool names are [a-zA-Z0-9_-]; DSH names may contain dots. */
34646
34660
  function toMcpName(name) {
34647
34661
  return name.replace(/[^a-zA-Z0-9_-]/g, "_");
@@ -34706,7 +34720,7 @@ function startMcpBridge(opts) {
34706
34720
  const allowSet = new Set(allow);
34707
34721
  const seen = /* @__PURE__ */ new Set();
34708
34722
  sendJson(res, 200, { tools: svc.schemas().filter((t) => allow.length === 0 || allowSet.has(t.name)).filter((t) => {
34709
- if (t.name === "run_code" || t.name === "agy_ask") return false;
34723
+ if (INTERNAL_TOOL_NAMES.has(t.name)) return false;
34710
34724
  const mapped = toMcpName(t.name);
34711
34725
  if (seen.has(mapped)) return false;
34712
34726
  seen.add(mapped);
@@ -34737,7 +34751,7 @@ function startMcpBridge(opts) {
34737
34751
  return;
34738
34752
  }
34739
34753
  const dshName = typeof parsed.dshName === "string" ? parsed.dshName : "";
34740
- if (dshName === "" || dshName === "run_code" || dshName === "agy_ask") {
34754
+ if (dshName === "" || INTERNAL_TOOL_NAMES.has(dshName)) {
34741
34755
  sendJson(res, 400, { error: "bad tool name" });
34742
34756
  return;
34743
34757
  }
@@ -34748,6 +34762,12 @@ function startMcpBridge(opts) {
34748
34762
  opts.log?.("mcp call " + dshName + " [" + outcome + "] " + (Date.now() - startedAt) + "ms");
34749
34763
  } catch {}
34750
34764
  };
34765
+ const allow = opts.allowlist().split(",").map((s) => s.trim()).filter(Boolean);
34766
+ if (allow.length > 0 && !allow.includes(dshName)) {
34767
+ audit("denied: not in allowlist");
34768
+ sendJson(res, 403, { error: "tool not allowed" });
34769
+ return;
34770
+ }
34751
34771
  try {
34752
34772
  const sessionHeader = String(req.headers["x-dsh-session"] ?? "");
34753
34773
  const resolveSession = async (id) => id === "" ? void 0 : await Promise.resolve(opts.resolveAgent?.(id));
@@ -110,11 +110,31 @@ reference-counted slot is the strongest isolation the plugin can provide.
110
110
  server in the MCP registry (`~/.gemini/config/mcp_config.json` by default,
111
111
  where `agy` 1.4+ actually reads it, merged in and restored on disable).
112
112
  Bridged calls carry caller identity via `DSH_MCP_SESSION` so identity-enforcing
113
- tools (such as `agent_teams`) function correctly. `run_code` and `agy_ask`
114
- are never bridged; `mcpToolAllowlist` restricts the set further.
113
+ tools (such as `agent_teams`) function correctly. Internal loopback-only
114
+ helpers — `run_code`, `agy_ask`, and the activity-mirror `agy_tool` — are
115
+ never bridged (excluded from both `/tools` and `/call`); `mcpToolAllowlist`
116
+ restricts the served set **and is
117
+ enforced at execution time** — a `/call` for a tool outside the allowlist is
118
+ refused (403) even when the caller holds the bridge token, so a prompt-injected
119
+ agy child cannot silently reach tools the operator did not expose.
115
120
  Every bridged call is audit-logged as `mcp call <tool> [<outcome>] <ms>` with
116
121
  the caller class and the failure text (never the arguments), so a failed run
117
122
  is visible in journald instead of only in transcripts.
123
+
124
+ **Contract for external / plugin callers of `tools.execute(exec)` (see #61):**
125
+ DSH's `ToolExecutionInput` requires `callId`, `name`, `arguments` **and
126
+ `signal: AbortSignal`** — a call without `signal` throws
127
+ `Cannot read properties of undefined (reading 'aborted')` inside any tool
128
+ that awaits. Omit `agent` entirely when there is no real session (leave it
129
+ `undefined`, **never** `null`: DSH checks `exec.agent === void 0`, so `null`
130
+ takes the else branch and reads `null.session`). This plugin's host-side
131
+ `/call` handler already does both (it mints an `AbortController` per call and
132
+ resolves the caller from the `x-dsh-session` header, passing `agent` only when
133
+ one is found). A fabricated `agent.session` cannot pass DSH's live-session
134
+ store check — there is no supported way to fake a real Session from outside;
135
+ tools that require one need a real `agent` or they fail by design.
136
+ Documenting the full DSH-core `execute(exec)` contract and any official
137
+ sessionless-execution API is upstream work, not this bundle.
118
138
  - **DSH `send_message` from an agy child** - DSH's sub-agent runtime appends a
119
139
  footer telling the child to report with `send_message({ agent_id: <parent> })`.
120
140
  In an agy run that name resolves to agy's **own** `send_message`, which does
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.75",
3
+ "version": "0.4.76",
4
4
  "description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
5
5
  "type": "module",
6
6
  "license": "MIT",