security: only accept inbound connections from the configured host#32
Open
pankaj512 wants to merge 2 commits into
Open
security: only accept inbound connections from the configured host#32pankaj512 wants to merge 2 commits into
pankaj512 wants to merge 2 commits into
Conversation
The client listened on all interfaces and accepted any inbound TCP connection, gated solely by knowledge of the shared key. On an untrusted network (public Wi-Fi) or a shared LAN, any host that could reach the port could attempt the key handshake and, on success, inject keyboard/mouse input. ListenAndAccept now takes the configured host (cfg.Host) and rejects inbound connections whose source IP does not match it (isAllowedPeer). The host may be an IP literal or a hostname (resolved to handle DHCP changes); an empty value disables the check. Outbound connect is unchanged, so normal use needs no new config. Adds TestIsAllowedPeer covering match/mismatch, loopback, IPv6, and the disabled case.
Documents the trusted-peer behavior (inbound connections accepted only from the configured host), firewall guidance, key secrecy, and the non-authenticated transport caveat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The client listened on all interfaces and accepted any inbound TCP connection, gated solely by knowledge of the shared key. On an untrusted network (public Wi-Fi) or a shared LAN, any host that could reach the port could attempt the key handshake and, on success, inject keyboard/mouse input.
Change
ListenAndAcceptnow takes the configured host (cfg.Host) and rejects inbound connections whose source IP does not match it (isAllowedPeer). The client only ever talks to one peer, so this closes the "anyone on the network can knock" door while the key remains the authentication secret.hostyou already set.Compatibility
Docs
Scope
internal/network/client.go,cmd/mwb/main.go,internal/network/client_test.go,README.md.TestIsAllowedPeercovering match/mismatch, loopback rejection, IPv6, and the disabled case.Testing
go build ./...,go vet ./..., andgo test ./...all pass.