Skip to main content
Menu
Advisories

CLI and TUI print server-controlled C1 controls to the terminal

GHSA-2MR9-588X-F57XPublished Updated GitHub

Description

Our code review of modelcontextprotocol/inspector at commit 2069a1a4d8c777360621f4c90c04017012bd5fae (tag 2.17.0, current main HEAD, ahead_by 0) found that the CLI and several TUI paths print server-controlled C1 control characters to the terminal. This is source review only; nothing was compiled or run.

The Inspector writes tool names, descriptions, results, resource and prompt output, and other server text to the developer's terminal. The shared CLI writer (core/cli/handlers/format-output.ts:14, :17) and the one-shot writers at clients/cli/src/handlers/emit-result.ts:35, :71, :79, consume-outcome.ts:40, :85, and the --load json and non-TTY branches at clients/cli/src/cli.ts:2512, :2522 all use JSON.stringify. That call escapes C0 but leaves U+0080–U+009F literal, so an 8-bit CSI (U+009B) or OSC (U+009D) in a server response can reach the terminal as a command. The schema-lint stderr report interpolates the raw tool name (schema-lint-report.ts:63, :68; core/json/schemaLint.ts:679-683). The human-format --load branch already calls sanitizeDeep (cli.ts:2518). The --load summary can carry server error text (core/cli/handlers/load-test.ts:212).

The project already documents this class of issue. core/cli/sanitize.ts:8-19 covers C0 and C1, but its comment at :13 says "--format json is safe (JSON escapes them)", which is not true for C1. clients/tui/src/utils/eventsDisplay.ts:102-115 already notes that JSON.stringify escapes only C0 and defines escapeControls over C0 and C1; that helper is used only in eventsDisplay.ts and EventsTab.tsx (EventsTab.tsx:306 already covers the input-schema JSON lines). Other TUI sinks we read still render server text raw, including ToolsTab.tsx:233, :292-300, :342; ToolTestModal.tsx:482; ResourceTestModal.tsx:365; PromptTestModal.tsx:306; TasksTab.tsx:321; HistoryTab.tsx:169, :209, :214, :242, :253, :278; BodyLines.tsx:28; App.tsx:1462, :1508, :1533, :1540, :1628, :1635; errorText.ts; ResourcesTab.tsx:322, :350, :359, :367, :376, :383, :401, :441, :450, :458, :468; SubscriptionsTab.tsx:227, :252, :262, :330; and RequestsTab.tsx:222, :229, :293. RequestsTab.tsx:258 is the client's own request headers and was left as-is. This is the set we found by reading those components, not a full TUI audit.

#2984 and PR #3015 (closed 2026-11-18) bumped Ink to v8 after measuring that Ink 8 strips bare C0 and the OSC/CSI sequences they tested from <Text>, which Ink 6 did not fully do. That change is in 2.17.0. The CLI writers do not go through Ink. We did not run Ink, and we did not check which terminals interpret 8-bit CSI/OSC from UTF-8. The leftover is the CLI JSON.stringify paths and the TUI sinks that do not call escapeControls. SECURITY.md has no known-limitation note for this, and we found no published advisory, OSV, or NVD entry covering it.

Harm stays inside the terminal (window title, cursor/erase, and clipboard sequences some terminals honour only with opt-in). We do not claim code execution, credential theft, or a sandbox escape. The party in a position to supply the text is the MCP server the developer has already chosen to inspect; tool names and descriptions can be printed before any tool is called.

An untested patch is available on request as inspector-373.patch. It adds stringifySafe / escapeJsonControls next to the existing sanitizer and points the CLI writers at it, and wraps the enumerated TUI sinks with escapeControls. The four constituent diffs plus the combined patch apply cleanly in order on the pinned commit (git apply --check and --whitespace=error-all; combined sha256 3f5dc081e3cdc6f4a843f5877a7409d04fcbca5c944ef87e98e1a495f12e4f7a). The patch has not been typechecked or run. Two items a maintainer should check: stringifySafe's replacer type against JSON.stringify's overloads, and a new import between errorText.ts and eventsDisplay.ts that looks safe from reading (each uses the other only inside a function body) but was never compiled. Apply with git apply, not git am.

Please keep this report private until the issue is resolved.

Credit: Ugur Celik (ucsurf), @ucsurf — Ugur Celik (ucsurf) · uc.surf We find and report security issues in open source before attackers do. If our work helped you, a small contribution keeps it going and makes the internet a little safer for everyone: buymeacoffee.com/ucsurf

Affected versions

References

GitHub · modelcontextprotocol/inspector