Repository navigation
Conversation
Peer._setIP checked cf-connecting-ip first and trusted it unconditionally. On any instance not behind Cloudflare that header is a plain client-supplied value, so a remote client could send cf-connecting-ip: <victim public IP> to join an arbitrary peer's IP auto-discovery room. The documented nginx reverse proxy overwrites only X-Forwarded-For, so it does not neutralize this header. Gate cf-connecting-ip behind a new CF_CONNECTING_IP option (default off). Operators behind Cloudflare set CF_CONNECTING_IP=true; everyone else falls back to the proxy-overwritten X-Forwarded-For or the socket address.
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.
Fixes #510.
Problem
Peer._setIP(server/peer.js) checkscf-connecting-ipfirst and trusts it unconditionally. On any instance not behind Cloudflare that header is a plain client-supplied value, so a remote client can sendcf-connecting-ip: <victim public IP>and be placed in that victim's IP auto-discovery room (_joinIpRoom->_joinRoom(peer, 'ip', peer.ip)), crossing the intended same-network boundary.The documented nginx reverse proxy overwrites only
X-Forwarded-For(proxy_set_header X-Forwarded-for $remote_addr;), so it does not neutralizecf-connecting-ip, and_setIPchecks that header first.Change
Gate
cf-connecting-ipbehind a newCF_CONNECTING_IPoption (default off):server/index.js:conf.cfConnectingIp = process.env.CF_CONNECTING_IP === "true";server/peer.js: only readcf-connecting-ipwhenthis.conf.cfConnectingIpis set; otherwise fall back tox-forwarded-for(proxy-overwritten in the documented setup) or the socket address.Operators genuinely behind Cloudflare set
CF_CONNECTING_IP=trueand keep the current behavior; all other deployments stop honoring the spoofable header.Scope is limited to the
cf-connecting-ipgap, since the documented$remote_addroverwrite already coversX-Forwarded-For.