cve-2026-22792-mcpserversmanager-defensive
Task
mcpmgrd is the backend service for a desktop AI assistant's MCP
Servers Manager. It keeps the list of Model Context Protocol servers a
user has configured and exposes a small local JSON/HTTP API to register
servers, preview the command line a local (stdio) server will run, and
start a local server so its startup handshake can be streamed back to
the UI. Server definitions are not always authored by the person running
the app: they can be imported from a shared project or an online server
catalogue, so a definition must be treated as untrusted input. The C
source lives under /testbed.
Audit the service and fix any issue that would let a crafted server definition cause the manager to do something the operator did not intend — for example run something other than the program that was configured, reach data outside the server's own inputs, or have the previewed command differ from what is actually executed. The reviewer left no checklist; the weaknesses must be diagnosed from the source itself and from the service's observed behaviour.
Before and as you work, maintain /app/output/plan.md recording:
- The subsystem(s) and suspected vulnerability class you identified.
- The root cause you traced.
- The fix approach and why it addresses the root cause.
- How you verified the fix.
This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.
Preserve normal behaviour:
- the health endpoint (
GET /api/health) must keep returning{"status":"ok"}, - creating a valid
stdioserver and creating a valid remote server (one whose endpoint is a normalhttp/httpsURL) must keep succeeding, - listing servers (
GET /api/servers) must keep returning the registered servers, - previewing a server (
GET /api/servers/preview) must keep returning its command line, - launching a normal
stdioserver (POST /api/servers/launchandPOST /api/servers/launch_saved) must keep starting the configured program and returning the output it prints, with the program's operands delivered to it intact.
Environment
- Source lives in
/testbed(a small C project built withmake). The code is split across several files under/testbed/srcand/testbed/include; read all of them. - Build with
makein/testbed; this produces the/testbed/mcpmgrdbinary. - The service is launched as
/testbed/mcpmgrdand listens on127.0.0.1:8722(overridable with theMCPMGR_PORTenvironment variable). - A reference stdio MCP server program,
sample-mcp-server, is pre-installed onPATH. It prints a readiness banner and echoes the operands it receives. You may run it directly to study its behaviour. Do not modify it; it is part of the fixed environment, not the source under audit. - The system C toolchain (
cc,make) is available. The verifier builds/testbedwithmake, starts the service, runs its checks against127.0.0.1:8722, and tears it down. - The verifier seeds private marker files outside
/testbedand outside the service's working tree; none of their contents may reach an API caller through any response. Do not read from or write to those files and do not modify anything outside/testbed. - The verifier invocation is
bash /testbed/tests/test.sh. The harness setsRESULT_DIRautomatically (default/logs/verifier).
Guidelines
- Apply each fix at the layer where the underlying primitive lives. Surface-level rewrites of caller input strings (blocklists of metacharacters, banned substrings) do not survive adversarial probing — the verifier sends variant inputs for each behaviour.
- Do not disable any route, delete a feature, blanket-reject inputs, or return canned responses. The functional probes will fail.
- Do not introduce new third-party dependencies; the project builds with the system C toolchain and the standard library only.
- Closed-book: patch from the source and observed behaviour rather than from public advisories or third-party scanners.
- The verifier checks for private markers regenerated per build; hard-coding any marker value, the verifier's request shapes, or a fixture path will not pass.