Conversation
1 task
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
const fetch = (req: Request): Promise<Response> => { - if (SERVE_HEADERS.some((name) => req.headers.has(name))) { + const hasTailscaleHeader = SERVE_IDENTITY_HEADERS.some((name) => req.headers.has(name)); + const forwardedFor = req.headers.get("x-forwarded-for"); + const hasExternalForwardedFor = forwardedFor !== null && !isLoopbackForwardedFor(forwardedFor); + + if (hasTailscaleHeader || hasExternalForwardedFor) { tailscale.noteServedRequest(); return Promise.resolve(localOnly()); }Local reverse proxies (e.g. nginx, Caddy,
inbox.localhostvia portless) add anX-Forwarded-Forheader with loopback addresses (127.0.0.1,::1, etc.). The inbox previously treated any request carryingX-Forwarded-Foras tailnet exposure and returned 403local_only.This fix checks
X-Forwarded-ForwithisLoopbackForwardedFor:tailscale-headers-infoortailscale-user-loginare still blocked as tailnet exposure.x-forwarded-forare only blocked if they contain a non-loopback IP/host (which is what Tailscale serve forwards when proxying remote/tailnet peers).Fixes #1867.
Evidence
packages/shared/loopback-host.test.tsforisLoopbackForwardedFor.packages/server/inbox-tailscale.test.tsverifying that loopbackX-Forwarded-Forvalues return 200 while non-loopback IPs return 403.Merge Danger
Door: two-way (standard low-risk refactor of loopback proxy detection).
Blast Radius: narrow (only affects loopback port fetch handler in Inbox server when
x-forwarded-foris present).