[PR #7938] [MERGED] fix(server): require a login for relayed nginx, Docker and Tailscale traffic (#7914) #8013

Closed
opened 2026-10-24 04:09:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7938
Author: @Gunterlie
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/proxy-trust-7914


📝 Commits (4)

  • 5784418 fix(server): treat HTTP/1.0 and relayed-Host requests as proxied for Docker and Tailscale trust (#7914)
  • 7648c5b docs: describe HTTP/1.0 proxy detection and proxy trust rules (#7914)
  • 05db5a7 fix(server): end Tailscale trust for forwarded peers with no opt-out (#7914)
  • 4f11fc9 docs: address review of proxy trust docs (#7914)

📊 Changes

11 files changed (+165 additions, -47 deletions)

View changed files

📝 .env.example (+9 -4)
📝 README.md (+1 -1)
📝 docs/CONFIGURATION.md (+18 -18)
📝 docs/FAQ.md (+1 -1)
📝 docs/REMOTE_ACCESS.md (+19 -6)
📝 docs/TROUBLESHOOTING.md (+2 -2)
📝 packages/server/src/middleware/access-policy.ts (+12 -9)
📝 packages/server/src/middleware/ip-allowlist.ts (+11 -4)
📝 scripts/regressions/access-policy.regression.ts (+40 -0)
📝 scripts/regressions/docker-gateway-auth-security.regression.ts (+8 -2)
📝 scripts/regressions/loopback-proxy-auth-security.regression.ts (+44 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Part of #7914 (parent #7909).

Why this change

The #7914 audit found same-host and container proxy setups that still give public or LAN visitors access without a login — the same kind of setup that let unsecured installs get indexed by search engines:

  • nginx with its default config on the same computer: proxy_pass http://127.0.0.1:7860 sends Host: 127.0.0.1:7860, no forwarding headers, and HTTP/1.0. The server saw a local browser.
  • A proxy in front of Docker (an nginx container next to Marinara, or nginx on the host in front of a 127.0.0.1 publish): Docker gateway trust ended only on forwarding headers, not on a relayed Host.
  • Tailscale Serve / Funnel pointing at the node's own 100.x address: public visitors arrived as a trusted Tailscale peer.

Local use must stay passwordless, so each rule only targets traffic that a proxy relayed.

What changed

  • packages/server/src/middleware/access-policy.ts, ip-allowlist.ts (built on the shared policy from #7934):
    • New http10 fact. A loopback request over HTTP/1.0 counts as proxied (browsers, Node http, undici and Android WebView all send HTTP/1.1; default nginx proxy_pass sends 1.0).
    • Docker gateway trust ends on forwarding headers, a relayed Host, or HTTP/1.0. The host's own browser (localhost / 127.0.0.1) stays passwordless.
    • Tailscale trust ends when forwarding headers are present. There is no flag to turn this off; a login is the escape hatch. Direct 100.x:7860 stays passwordless.
    • /api/health stays reachable through an HTTP/1.0 proxy.
  • Behaviour change to note: a container that calls Marinara as http://marinara:7860 (or through the gateway with a non-local Host) now needs a login. No file in this repo does that.
  • Regressions:
    • loopback-proxy-auth-security: table run through the real hooks — local browser on localhost, ::1, ::ffff:127.0.0.1 (200); nginx HTTP/1.0, nginx with X-Forwarded-For, nginx over ::1, cloudflared, Tailscale Serve/Funnel, ngrok, LAN client faking X-Forwarded-For (401); /api/health via HTTP/1.0 proxy (200). The HTTP/1.0 case uses a test-only hook in the regression file; production reads only request.raw.httpVersion.
    • access-policy: HTTP/1.0 loopback, Docker gateway with relayed Host / HTTP/1.0, forwarded vs direct Tailscale peer, and REQUIRE_AUTH_FOR_DOCKER_PROXY=false not restoring Tailscale trust.
    • docker-gateway-auth-security: expectations changed on purpose — gateway requests now use Host 127.0.0.1 for the trusted case, and a gateway request with a LAN Host is not trusted.
  • Docs (docs/REMOTE_ACCESS.md, CONFIGURATION.md, TROUBLESHOOTING.md, FAQ.md, README.md, .env.example):
    • Describe the new detection; default nginx no longer needs an extra line to be safe (the X-Forwarded-For line stays recommended).
    • One wording for REQUIRE_AUTH_FOR_LOOPBACK_PROXY=false / REQUIRE_AUTH_FOR_DOCKER_PROXY=false: only when the proxy itself requires a login from every visitor. For a local /etc/hosts name, recommend a *.localhost name instead of the global flag.
    • Docker + proxy: keep the 127.0.0.1 publish and set a login before adding a proxy.
    • Table of the default listen address per start method.
    • Warning that ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK includes 100.64.0.0/10, which some providers give to customers.

Gaps that stay open: an HTTP/1.1 proxy that strips forwarding headers and rewrites Host to localhost, and a default nginx on another tailnet node. Both look exactly like a local browser or a direct Tailscale peer.

Validation

  • pnpm check passes locally.

  • access-policy, loopback-proxy-auth-security, docker-gateway-auth-security, docker-proxy-auth pass locally. In an earlier regression:security run, 26/27 passed; multiplayer-peer-server-security fails on this machine with ERR_TLS_CERT_ALTNAME_INVALID in its own TLS client (does not import these files).

  • Opus adversarial review: no local lockout found (Vite dev proxy, launcher health checks, ::1, Android WebView checked); its doc and test findings are fixed.

  • Local CodeRabbit could not run: the account hit its review limit. GitHub CodeRabbit must pass before merge.

  • pnpm check passes locally

  • Container (Docker / Podman) built and ran without issue

  • Ran the app, clicked through the changes manually

  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)

  • Above manual verification completed (describe below)

  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify http://localhost:7860 and http://127.0.0.1:7860 on the same computer still open without a password (native and Docker).
  • Manually verify nginx with a default proxy_pass http://127.0.0.1:7860 shows the lockdown page / asks for a login.
  • Manually verify compose with an nginx container in front of Marinara asks for a login.
  • Manually verify tailscale serve / tailscale funnel visitors are asked for a login, and direct 100.x:7860 access is not.
  • Manually verify pnpm dev (Vite proxy) on the same computer stays passwordless.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs-i18n follow-up needed for docs/REMOTE_ACCESS.md, docs/CONFIGURATION.md, docs/TROUBLESHOOTING.md, docs/FAQ.md after merge.

UI evidence (if applicable)

Server and docs only; no UI change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7938 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/proxy-trust-7914` --- ### 📝 Commits (4) - [`5784418`](https://github.com/Pasta-Devs/Marinara-Engine/commit/578441818a7a56408adbc4a8cc71cc42ab1335f7) fix(server): treat HTTP/1.0 and relayed-Host requests as proxied for Docker and Tailscale trust (#7914) - [`7648c5b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7648c5b6eac7fb0ea69eb182e8e3f163a8da16a2) docs: describe HTTP/1.0 proxy detection and proxy trust rules (#7914) - [`05db5a7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/05db5a7614c08ae3f00429c64a82e31fb6503893) fix(server): end Tailscale trust for forwarded peers with no opt-out (#7914) - [`4f11fc9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f11fc9143a3279b8e86c557c743faee838711e2) docs: address review of proxy trust docs (#7914) ### 📊 Changes **11 files changed** (+165 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+9 -4) 📝 `README.md` (+1 -1) 📝 `docs/CONFIGURATION.md` (+18 -18) 📝 `docs/FAQ.md` (+1 -1) 📝 `docs/REMOTE_ACCESS.md` (+19 -6) 📝 `docs/TROUBLESHOOTING.md` (+2 -2) 📝 `packages/server/src/middleware/access-policy.ts` (+12 -9) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+11 -4) 📝 `scripts/regressions/access-policy.regression.ts` (+40 -0) 📝 `scripts/regressions/docker-gateway-auth-security.regression.ts` (+8 -2) 📝 `scripts/regressions/loopback-proxy-auth-security.regression.ts` (+44 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Part of #7914 (parent #7909). ## Why this change The #7914 audit found same-host and container proxy setups that still give public or LAN visitors access without a login — the same kind of setup that let unsecured installs get indexed by search engines: - **nginx with its default config** on the same computer: `proxy_pass http://127.0.0.1:7860` sends `Host: 127.0.0.1:7860`, no forwarding headers, and HTTP/1.0. The server saw a local browser. - **A proxy in front of Docker** (an nginx container next to Marinara, or nginx on the host in front of a `127.0.0.1` publish): Docker gateway trust ended only on forwarding headers, not on a relayed Host. - **Tailscale Serve / Funnel** pointing at the node's own `100.x` address: public visitors arrived as a trusted Tailscale peer. Local use must stay passwordless, so each rule only targets traffic that a proxy relayed. ## What changed - `packages/server/src/middleware/access-policy.ts`, `ip-allowlist.ts` (built on the shared policy from #7934): - New `http10` fact. A loopback request over HTTP/1.0 counts as proxied (browsers, Node `http`, undici and Android WebView all send HTTP/1.1; default nginx `proxy_pass` sends 1.0). - Docker gateway trust ends on forwarding headers, a relayed Host, or HTTP/1.0. The host's own browser (`localhost` / `127.0.0.1`) stays passwordless. - Tailscale trust ends when forwarding headers are present. There is no flag to turn this off; a login is the escape hatch. Direct `100.x:7860` stays passwordless. - `/api/health` stays reachable through an HTTP/1.0 proxy. - **Behaviour change to note:** a container that calls Marinara as `http://marinara:7860` (or through the gateway with a non-local Host) now needs a login. No file in this repo does that. - Regressions: - `loopback-proxy-auth-security`: table run through the real hooks — local browser on `localhost`, `::1`, `::ffff:127.0.0.1` (200); nginx HTTP/1.0, nginx with `X-Forwarded-For`, nginx over `::1`, cloudflared, Tailscale Serve/Funnel, ngrok, LAN client faking `X-Forwarded-For` (401); `/api/health` via HTTP/1.0 proxy (200). The HTTP/1.0 case uses a test-only hook in the regression file; production reads only `request.raw.httpVersion`. - `access-policy`: HTTP/1.0 loopback, Docker gateway with relayed Host / HTTP/1.0, forwarded vs direct Tailscale peer, and `REQUIRE_AUTH_FOR_DOCKER_PROXY=false` not restoring Tailscale trust. - `docker-gateway-auth-security`: expectations changed on purpose — gateway requests now use Host `127.0.0.1` for the trusted case, and a gateway request with a LAN Host is not trusted. - Docs (`docs/REMOTE_ACCESS.md`, `CONFIGURATION.md`, `TROUBLESHOOTING.md`, `FAQ.md`, `README.md`, `.env.example`): - Describe the new detection; default nginx no longer needs an extra line to be safe (the `X-Forwarded-For` line stays recommended). - One wording for `REQUIRE_AUTH_FOR_LOOPBACK_PROXY=false` / `REQUIRE_AUTH_FOR_DOCKER_PROXY=false`: only when the proxy itself requires a login from every visitor. For a local `/etc/hosts` name, recommend a `*.localhost` name instead of the global flag. - Docker + proxy: keep the `127.0.0.1` publish and set a login before adding a proxy. - Table of the default listen address per start method. - Warning that `ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK` includes `100.64.0.0/10`, which some providers give to customers. Gaps that stay open: an HTTP/1.1 proxy that strips forwarding headers and rewrites Host to `localhost`, and a default nginx on another tailnet node. Both look exactly like a local browser or a direct Tailscale peer. ## Validation - `pnpm check` passes locally. - `access-policy`, `loopback-proxy-auth-security`, `docker-gateway-auth-security`, `docker-proxy-auth` pass locally. In an earlier `regression:security` run, 26/27 passed; `multiplayer-peer-server-security` fails on this machine with `ERR_TLS_CERT_ALTNAME_INVALID` in its own TLS client (does not import these files). - Opus adversarial review: no local lockout found (Vite dev proxy, launcher health checks, `::1`, Android WebView checked); its doc and test findings are fixed. - **Local CodeRabbit could not run**: the account hit its review limit. GitHub CodeRabbit must pass before merge. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify `http://localhost:7860` and `http://127.0.0.1:7860` on the same computer still open without a password (native and Docker). - Manually verify nginx with a default `proxy_pass http://127.0.0.1:7860` shows the lockdown page / asks for a login. - Manually verify compose with an nginx container in front of Marinara asks for a login. - Manually verify `tailscale serve` / `tailscale funnel` visitors are asked for a login, and direct `100.x:7860` access is not. - Manually verify `pnpm dev` (Vite proxy) on the same computer stays passwordless. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) docs-i18n follow-up needed for `docs/REMOTE_ACCESS.md`, `docs/CONFIGURATION.md`, `docs/TROUBLESHOOTING.md`, `docs/FAQ.md` after merge. ## UI evidence (if applicable) Server and docs only; no UI change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:09:39 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8013
No description provided.