Skip to content

Accept connections only over loopback - #242

Merged
mattt merged 1 commit into
mainfrom
mattt/loopback-listener
Sep 24, 2026
Merged

mattt merged 1 commit into
mainfrom
mattt/loopback-listener

Conversation

@mattt

@mattt mattt commented Sep 23, 2026

Copy link
Copy Markdown
Owner

iMCP's listener accepts connections on every IPv4 interface, so another device on the same network can reach it and trigger a connection prompt (#103). Since #229, the CLI connects over 127.0.0.1 using the port from the Bonjour TXT record.

This PR binds both listeners to the IPv4 loopback address. Bonjour still advertises the service and its port on every interface, but connections to a LAN address are refused. The CLI's fallback to the resolved service endpoint, which it uses only when the TXT record has no port, no longer connects.

Closes #103.

The listener accepted connections on every IPv4 interface,
so another device on the same network could reach it (#103).
The CLI has connected over 127.0.0.1 since #229,
so bind both listeners to the IPv4 loopback address.
Bonjour still advertises the service and its port.
@mattt
mattt marked this pull request as ready for review September 24, 2026 12:59
@mattt

mattt commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

Smoke tested with two Macs on the same network:

  • On the host, a Debug build of this branch listens on 127.0.0.1:58984 only (lsof -nP -iTCP -sTCP:LISTEN).
  • Claude on the same Mac connected through imcp-server over 127.0.0.1, and events_fetch returned today's events.
  • From the laptop, dns-sd -B _mcp._tcp local. and dns-sd -L iMCP _mcp._tcp local. still find the service, with port=58984 in its TXT record. nc -vz -G 5 <host address> 58984 gets Connection refused.
  • For comparison, a build of main (1.5.3) listens on *:56058, and the same nc from the laptop connects.

Not covered: restartWithRandomPort(), which gets the same change but has no easy manual trigger.

@mattt
mattt merged commit 0a46968 into main Sep 24, 2026
1 check passed
@mattt
mattt deleted the mattt/loopback-listener branch September 24, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security Concern: iMCP Server Exposed to Entire Local Network via Bonjour

1 participant