Skip to content

HTTP Bridge Should Bind to Localhost Only #33

Description

@jojastahl

Claude Code crafted this issue:

Security Issue: HTTP Bridge Should Bind to Localhost Only

Description

The HTTP Bridge server in src/mcp/http-bridge.ts does not explicitly bind to localhost, which may allow access from other devices on the local network depending on firewall configuration.

Current Implementation

File: src/mcp/http-bridge.ts:87

this.httpServer!.listen(this.port, () => {
  console.log(`VS Code HTTP Bridge running on port ${this.port}`);
  resolve();
});

When no hostname is specified in Node.js http.Server.listen(), the server binds to all network interfaces (0.0.0.0 by default), not just localhost.

Security Impact

Severity: Medium

If the user's firewall allows it, other devices on the local network could potentially:

  • Access the HTTP bridge on port 8991
  • Execute any of the 25 exposed tools
  • Read the entire VSCode workspace source code
  • View debugging session data (variables, call stacks)
  • Rename symbols and modify files across the workspace
  • Evaluate expressions in active debug sessions

The CORS header Access-Control-Allow-Origin: * (line 19) further allows any origin to connect via browser-based requests.

Recommended Fix

Explicitly bind to localhost to ensure the server is only accessible from the local machine:

this.httpServer!.listen(this.port, 'localhost', () => {
  console.log(`VS Code HTTP Bridge running on localhost:${this.port}`);
  resolve();
});

Alternatively, use 127.0.0.1 for IPv4-only binding:

this.httpServer!.listen(this.port, '127.0.0.1', () => {
  console.log(`VS Code HTTP Bridge running on 127.0.0.1:${this.port}`);
  resolve();
});

Additional Considerations

  1. CORS Configuration: Consider restricting CORS to localhost origins only, or removing CORS headers entirely since the MCP standalone server uses direct HTTP requests (not browser-based)

  2. Authentication: For defense-in-depth, consider adding a simple authentication token that must be provided via environment variable

  3. Documentation: Update README to clearly document the security model and trust boundaries

References

Affected Versions

All versions up to and including v0.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions