MCP gateway conversion silently drops a server named `__proto__`

Aperta Adatta ai principianti
#80,189 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github-actions, javascript, node.js
Ambito
devtools

Direzione di ricerca

Inizia da filterAndTransformServers in actions/setup/js/convert_gateway_config_shared.cjs, dove result[name] = transformServer(name, entry) assegna valori a un oggetto semplice. Confronta con loadCopilotSDKMCPServers in actions/setup/js/copilot_sdk_tool_config.cjs, che usa Object.defineProperty, e con il suo test su __proto__ in copilot_sdk_tool_config.test.cjs. Il lavoro è completato quando un server proto sopravvive in entrambi i cataloghi e il numero di server inclusi corrisponde al numero di server di origine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

ai-inspected

Summary

The shared gateway-to-Copilot converter copies MCP servers into its result object with a plain property assignment. When a workflow declares an MCP server named __proto__, that assignment mutates the result object's prototype instead of creating an own key, so the server silently disappears from both generated Copilot catalogs: the CLI catalog at $HOME/.copilot/mcp-config.json and the SDK catalog at $RUNNER_TEMP/gh-aw/mcp-config/copilot-sdk.json. The SDK catalog loader in the same repository is explicitly implemented and unit-tested to preserve exactly such names, and the compiler accepts the name, so the producer and the consumer of the same catalog disagree about which servers exist.

Environment

  • Repository: github/gh-aw, commit e507073a5b3dca9ed1e859e9af837561f8652f81; the same converter assignment is still present on the default branch.
  • Files: actions/setup/js/convert_gateway_config_copilot.cjs, actions/setup/js/convert_gateway_config_shared.cjs (function filterAndTransformServers), actions/setup/js/copilot_sdk_tool_config.cjs (function loadCopilotSDKMCPServers).
  • Runtime: Node.js 22.23.5 on Linux.
  • Input: a workflow that declares two MCP servers, one of them named __proto__, and the gateway-output catalog for that configuration.

Expected behavior

A workflow may legally declare an MCP server named __proto__: compilation succeeds and the generated gh-aw-manifest lists it, and the generated gateway configuration contains that server. Conversion should carry the server into the Copilot CLI catalog and the SDK catalog unchanged, and the SDK session loader should register it. That is the contract the repository already asserts in actions/setup/js/copilot_sdk_tool_config.test.cjs with the test named "preserves a literal proto server as an own property without changing the dictionary prototype", and the loader's own comment says it preserves "names such as proto as own keys without invoking inherited setters".

Actual behavior

The compiler accepts the name and emits the server:

compiled manifest mcp server names: ['__proto__', 'github', 'safeoutputs']
gateway configuration emitted for the agent:
  "__proto__": {

The converter then drops it and reports an incorrect filter count, because it computes the filtered number by subtraction from the input size:

[info] Converting gateway configuration to Copilot format...
[info] Target domain: host.docker.internal:80
[info] Servers: 1 included, 1 filtered (CLI-mounted)
[info] Converted servers: github

Both generated catalogs contain only the second server:

{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "http://host.docker.internal:80/mcp/github",
      "timeout": 30000,
      "tools": [
        "*"
      ]
    }
  }
}

The SDK session therefore cannot register the missing server:

registered server names: ["github"]
__proto__ registered: false

Root cause

filterAndTransformServers in actions/setup/js/convert_gateway_config_shared.cjs builds the converted catalog with a plain object and a dynamic assignment:

const result = {};
for (const [name, value] of Object.entries(servers)) {
  if (cliServers.has(name)) continue;
  const entry = { ...value };
  result[name] = transformServer(name, entry);
}
return result;

When name is __proto__, result["__proto__"] = ... invokes the inherited Object.prototype.__proto__ accessor: it replaces the prototype of result with the transformed server object instead of defining an own enumerable property. JSON.stringify({ mcpServers: result }) only serializes own enumerable properties, so the server is absent from both catalogs that are written from this result. The negative side effect is also visible in the log line "1 included, 1 filtered (CLI-mounted)", which reports a filter that never happened because the count is computed as total minus Object.keys(result).length.

The consumer side already handles the same name correctly: loadCopilotSDKMCPServers in actions/setup/js/copilot_sdk_tool_config.cjs registers each entry with Object.defineProperty(servers, name, { value: server, enumerable: true, configurable: true, writable: true }) and has a dedicated test for __proto__. The converter that produces the catalog read by that loader does not follow the same rule.

Suggested fix

Define own properties in filterAndTransformServers instead of assigning them, for example by building the result from Object.defineProperty(result, name, { value: transformServer(name, entry), enumerable: true, configurable: true, writable: true }), or by returning Object.fromEntries over the filtered entries, which also creates data properties and never invokes inherited setters. Add a regression test that runs a gateway-output catalog containing a __proto__ server through the full conversion pipeline and asserts that the name survives serialization in both the CLI and SDK catalogs, and that the "included" count matches the number of source servers.

Lingua principale
Go
Stelle
5.7k
Fork
635
Merge medio
3h 43m
PR unite (30g)
838

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/gh-aw

Tutte le issue di github/gh-aw

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.