Repository navigation
feat(server): relay only the protocol, lift limits only for paired browsers - #71
Merged
Merged
Conversation
The bridge named its TCP peer as the client and the API relay named nobody. Behind a proxy, a published Docker port or a tunnel that peer is private, so a knock from the internet read as one from home, and every visitor shared the server's address in a host's limits. The visitor is now the strictest of the peer and every address in X-Forwarded-For and Forwarded, named by the right-most public one; an entry a caller made up can only tighten it. Behind TLS=off a request with no forwarding header is unknown, and so is one with an entry that is not an address. An IPv6 peer on one of this machine's own /64s is at home. Every relayed request and bridge dial carries it as pf-client-addr.
The relay carried any method and path to any private address and port, and the bridge dialled any of them: an open door into the LAN for anyone who reached the page, and a way for one LAN device to pose as a host. A relayed request now takes only a route in core's table: the open four, and a paired device's own with its token. An address the operator did not list, typed or found over mDNS, is reached only once this server has fetched its plane itself and checked that the identity serving its TLS signed it. Anything else hears that one request and nothing more for a minute. Typed and advertised addresses must be on a home network and never loopback. Proven pins and kept clients stop at 64.
A device token proves a browser to a host, never to this server, so the server could not tell a paired browser from a stranger and held every visitor to the same limits. A pass, minted only when a host takes the token, lets the server meter strangers, pool the bridge and keep wake and plane addresses for paired browsers. A token, and the device exchange that earns one, reach only the host the browser paired with: the page names it in pf-host and the relay checks the TLS leaf. Per-address limits count an IPv6 /64 as one. The listener caps connections in all and, when it ends TLS itself, per peer, with handshake and header deadlines.
A browser cannot pin a self-made certificate, so at a public address nothing tells this server from an impostor, and the impostor would collect the device key's signatures. A browser that reaches it straight from the internet gets one static page saying so. compose.public.yaml makes the supported way one command: Caddy with a real certificate in front, the server on the host's network. BREAKING CHANGE: a port forward to a self-signed server no longer serves the client outside your network. Use Tailscale, or a domain with a certificate (deploy/compose.public.yaml).
The Tailscale shape needs two files and two settings before its first start, TLS_NAMES holds addresses as well as domains, and a proxied page on a domain the host does not list pairs by PIN.
The server now reads the paired-route table, the address classes and the plane attestation check from punktfunk-core, which that commit adds. packages/stream keeps its own pin: it moves with the wire.
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.
The second half of hardening the page server for people who expose it, stacked on #70 (design: planning
design/web-client-exposure.md). The host half is unom/punktfunk #2293; this pinspunktfunk-coreto that branch's first commit, which is all the server needs from it.What a visitor whose browser is not paired with a host gets from an exposed server, before and after:
Commits
feat(server): tell hosts who the visitor is— the strictest of the TCP peer and every forwarded address, on every relayed request and bridge dial aspf-client-addr;unknownbehind a proxy that names nobody.feat(server): relay only the protocol, only to proven hosts— the relay forwards only routes in core's table, and reaches an address the operator did not list only after fetching its plane itself and checking the signature of the identity that served it.feat(server): give paired browsers a pass, strangers a lane— a browser whose token a host accepted gets a pass (only its hash is stored). The pass buys the paired bridge pool, wake and freedom from the rate limit. A token, and the device login itself, go only over a connection with the identity the browser paired with (pf-host). Listener caps and timeouts as on the host.feat(server): refuse a self-made certificate to the internet— anddeploy/compose.public.yaml: Caddy with a real certificate in front, one command.docs, and the pin.Breaking
compose.tailscale.yaml) or a domain with a certificate (DOMAIN=… docker compose -f compose.public.yaml up -d).X-Forwarded-For(nginx:proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;). Without it every visitor is unknown, and a host treats them as coming from the internet.Checked
server/: fmt, clippy-D warnings --locked, 46 tests--lockedagainst the pinned revision.tscin both workspaces, 90 + 4 tests.compose.public.yaml's Caddy with its internal issuer onlocalhost, in front of this branch's server: the page loads with HSTS, Caddy'sX-Forwarded-Forreaches the server and replaces a forged one, the bridge upgrade passes.Not checked
compose.public.yamlwith a real domain and certificate.