run_code: process.stdout writes from agent code corrupt the stdio transport

Aperta
#209 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
tooling

Direzione di ricerca

Start at packages/wdio-session/src/exec/context.ts lines 180-200 where process is handed to agent code, and compare with the console.* reassignment in src/server.ts to see why one is captured and the other is not. Option 1 is the stated home: make the context's stdout/stderr write into the same capture that exec already uses, which also means checking every write still reaching the real stdio JSON-RPC stream. The tricky part is Option 2's process-wide swap and concurrent sessions, so expect reading the transport code before deciding. Done looks like a run_code call whose agent code writes to process.stdout leaving the MCP connection intact.

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

Descrizione

bug

Target: feature/v5. Depends on: #197 (run_code exists only in #197, on feature/v5), and webdriverio/webdriverio#16495 for the engine fix.

Problem. Code run by run_code runs in the MCP server's own process. @wdio/session routes console inside exec to its output capture, but the context also exposes process, and process.stdout.write isn't captured. src/server.ts reassigns only console.* to stderr (src/server.ts:100). One process.stdout.write('…') in agent-written code puts bytes into the stdio JSON-RPC stream and breaks the connection.

This isn't specific to the model being malicious: libraries imported with await import(…) inside run_code can write to stdout too.

Fix. Blocked on webdriverio/webdriverio#16495 (opt-in restricted exec context without process). That is the right home: it protects the stdio transport and the CLI's JSON output alike. On release, bump @wdio/session and add a test that process.stdout.write inside run_code doesn't reach the transport.

Interim. Swapping process.stdout.write inside the MCP server was rejected: the swap is process-wide, so it races the transport's own writes and concurrent sessions. Until the bump, document the hazard in the run_code tool description.

Acceptance

  • After the bump: a test shows that process.stdout.write inside run_code does not reach the transport.
Lingua principale
TypeScript
Stelle
45
Fork
20
Merge medio
2g 9h
PR unite (30g)
16

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

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 webdriverio/mcp

Tutte le issue di webdriverio/mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.