[PR #464] [MERGED] feat(security): trust Tailscale and Docker traffic by default (with opt-out) #4630

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/464
Author: @LukaTheHero
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @LukaTheHero

Base: main ← Head: feat/tailscale-docker-bypass


📝 Commits (2)

  • a17bfef feat(security): opt-in bypass that trusts Tailscale or Docker traffic
  • 24ab338 feat(security): default the Tailscale and Docker bypass flags to true

📊 Changes

6 files changed (+202 additions, -14 deletions)

View changed files

📝 .env.example (+24 -0)
📝 docs/CONFIGURATION.md (+30 -4)
📝 docs/REMOTE_ACCESS.md (+39 -5)
📝 packages/server/src/config/runtime-config.ts (+38 -0)
📝 packages/server/src/middleware/basic-auth.ts (+6 -4)
📝 packages/server/src/middleware/ip-allowlist.ts (+65 -1)

📄 Description

Summary

  • Two new flags, BYPASS_AUTH_TAILSCALE and BYPASS_AUTH_DOCKER, treat traffic from 100.64.0.0/10 (Tailnet CGNAT) and 172.16.0.0/12 (Docker bridge networks) as trusted — those clients skip both the IP allowlist and Basic Auth, the same way loopback already does.
  • Both flags default to true so a fresh install with no .env works over Tailscale or from same-host Docker containers without any setup.
  • Combines cleanly with BASIC_AUTH_*: bypassed clients skip the prompt, ordinary LAN / public-internet clients still authenticate. The first request that exercises a bypass logs an [auth-bypass] warning so the operator has a paper trail.

Why

Two recurring user-friction patterns:

  1. "I just installed Marinara and want to reach it from my phone over Tailscale." Today the lockdown page blocks them; they have to read the docs, generate a password, restart the server. For tailnet access — where joining the tailnet already required the operator's Tailscale account — that's needless friction. Tailnet membership is a stronger trust signal than "any LAN," so trusting 100.64.0.0/10 by default doesn't violate the safe-by-default ethos the way trusting 192.168.0.0/16 would.
  2. "My Marinara container is being called by another container on the same Docker bridge." Bridge IPs (172.16.0.0/12) are unreachable from outside the host — external traffic NATs through the bridge gateway and arrives with a different source — so a request that actually shows up with a 172.x.x.x source genuinely came from a container on the same host. Trusting that range is also safe by default.

What changed

  • packages/server/src/config/runtime-config.ts — added isTailscaleBypassEnabled() / isDockerBypassEnabled() getters using !isDisabledFlag(...) so unset / "true" / "yes" / "1" all enable, only "false" / "no" / "0" / "off" disable.
  • packages/server/src/middleware/ip-allowlist.ts — extracted the Tailscale and Docker CIDRs as named constants, added isTailscaleIp() / isDockerIp() predicates and isTrustedInterfaceIp() (which checks the bypass flag and logs a one-shot [auth-bypass] warning the first time each range is exercised). Wired into ipAllowlistHook after the loopback short-circuit.
  • packages/server/src/middleware/basic-auth.ts — isBasicAuthSatisfied() and basicAuthHook() treat isTrustedInterfaceIp(ip) exactly like loopback or IP_ALLOWLIST matches.
  • .env.example — both flags listed with =true, with inline caveats so users see when to disable.
  • docs/REMOTE_ACCESS.md — rewrote the intro / TL;DR / decision table; new "Option 4: Tailscale or Docker bypass (interface-scoped, on by default)" section; updated Option 1's exemption list.
  • docs/CONFIGURATION.md — new "Trusted-interface bypass" subsection under Access Control; updated the "Safe-by-default lockdown" so its exempt-list is accurate.

Caveats (documented)

  • 100.64.0.0/10 is also used by some carrier-grade-NAT ISPs. If your server's public uplink is itself behind CGNAT, an internet client could appear with a Tailscale-shaped source IP — set BYPASS_AUTH_TAILSCALE=false or bind HOST to your tailscale0 IP.
  • 172.16.0.0/12 also covers some private LAN deployments that aren't Docker. If your non-Docker LAN uses 172.16.x.x / 172.20.x.x, set BYPASS_AUTH_DOCKER=false.
  • The broader ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK (which trusts the entire RFC 1918 + CGNAT + ULA + link-local set) stays default-off. This PR only narrows the auto-trust to two interfaces where the access path itself is authenticated.

Notes

  • No linked issue. Per CONTRIBUTING.md, one should be opened describing the user-facing problem (Tailscale users hitting the lockdown page on a fresh install) before this is merged.
  • Rebased on top of main after #463 (env hot-reload) merged, so the runtime-config and docs edits coexist cleanly.

Test plan

  • Manually verify a fresh install with no .env file is reachable from a Tailscale device. Server log shows [auth-bypass] BYPASS_AUTH_TAILSCALE=true … once on first request.
  • Manually verify the same fresh-install scenario from a regular LAN phone (non-Tailscale, non-Docker) still hits the lockdown HTML page — confirms we narrowed the trust to just Tailscale/Docker, not the whole LAN.
  • Manually verify loopback (http://127.0.0.1:7860) on the host still works regardless of these flags' values.
  • Manually verify the bypass coexists with Basic Auth: set BASIC_AUTH_USER / BASIC_AUTH_PASS, refresh from Tailscale → loads with no prompt; refresh from a regular LAN phone → password prompt.
  • Manually verify explicit opt-out works: set BYPASS_AUTH_TAILSCALE=false, restart, refresh from Tailscale → lockdown page (or password prompt if Basic Auth is configured).
  • Manually verify the bypass beats the IP allowlist: set IP_ALLOWLIST=192.168.1.0/24 (LAN only, NOT including Tailscale), keep defaults, hit from Tailscale → loads; hit from a non-allowlisted, non-Tailscale device → 403.
  • Manually verify the [auth-bypass] warning fires only once per range per process, not on every subsequent request.
  • Manually verify Docker bypass from inside a container on the default bridge: curl http://<host-bridge-ip>:7860/api/health from a sidecar container → 200, server logs [auth-bypass] BYPASS_AUTH_DOCKER=true … once.

Summary by CodeRabbit

  • New Features

    • Added automatic trust for Tailscale and Docker network traffic by default
    • Introduced configuration options to disable Tailscale and Docker interface bypasses if needed
  • Documentation

    • Updated configuration guides to document new trusted interface bypass options and their default behavior

🔄 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/464 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 5/6/2026 **Status:** ✅ Merged **Merged:** 5/6/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `feat/tailscale-docker-bypass` --- ### 📝 Commits (2) - [`a17bfef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a17bfef4297184f629a0d3bdb5fa728d6a7661e1) feat(security): opt-in bypass that trusts Tailscale or Docker traffic - [`24ab338`](https://github.com/Pasta-Devs/Marinara-Engine/commit/24ab3387eb35b47b9aa5f45e3ab117942c7311ec) feat(security): default the Tailscale and Docker bypass flags to true ### 📊 Changes **6 files changed** (+202 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+24 -0) 📝 `docs/CONFIGURATION.md` (+30 -4) 📝 `docs/REMOTE_ACCESS.md` (+39 -5) 📝 `packages/server/src/config/runtime-config.ts` (+38 -0) 📝 `packages/server/src/middleware/basic-auth.ts` (+6 -4) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+65 -1) </details> ### 📄 Description ## Summary - Two new flags, `BYPASS_AUTH_TAILSCALE` and `BYPASS_AUTH_DOCKER`, treat traffic from `100.64.0.0/10` (Tailnet CGNAT) and `172.16.0.0/12` (Docker bridge networks) as trusted — those clients skip both the IP allowlist *and* Basic Auth, the same way loopback already does. - **Both flags default to `true`** so a fresh install with no `.env` works over Tailscale or from same-host Docker containers without any setup. - Combines cleanly with `BASIC_AUTH_*`: bypassed clients skip the prompt, ordinary LAN / public-internet clients still authenticate. The first request that exercises a bypass logs an `[auth-bypass]` warning so the operator has a paper trail. ## Why Two recurring user-friction patterns: 1. **"I just installed Marinara and want to reach it from my phone over Tailscale."** Today the lockdown page blocks them; they have to read the docs, generate a password, restart the server. For tailnet access — where joining the tailnet already required the operator's Tailscale account — that's needless friction. Tailnet membership is a stronger trust signal than "any LAN," so trusting `100.64.0.0/10` by default doesn't violate the safe-by-default ethos the way trusting `192.168.0.0/16` would. 2. **"My Marinara container is being called by another container on the same Docker bridge."** Bridge IPs (`172.16.0.0/12`) are unreachable from outside the host — external traffic NATs through the bridge gateway and arrives with a different source — so a request that actually shows up with a `172.x.x.x` source genuinely came from a container on the same host. Trusting that range is also safe by default. ## What changed - `packages/server/src/config/runtime-config.ts` — added `isTailscaleBypassEnabled()` / `isDockerBypassEnabled()` getters using `!isDisabledFlag(...)` so unset / "true" / "yes" / "1" all enable, only "false" / "no" / "0" / "off" disable. - `packages/server/src/middleware/ip-allowlist.ts` — extracted the Tailscale and Docker CIDRs as named constants, added `isTailscaleIp()` / `isDockerIp()` predicates and `isTrustedInterfaceIp()` (which checks the bypass flag and logs a one-shot `[auth-bypass]` warning the first time each range is exercised). Wired into `ipAllowlistHook` after the loopback short-circuit. - `packages/server/src/middleware/basic-auth.ts` — `isBasicAuthSatisfied()` and `basicAuthHook()` treat `isTrustedInterfaceIp(ip)` exactly like loopback or `IP_ALLOWLIST` matches. - `.env.example` — both flags listed with `=true`, with inline caveats so users see when to disable. - `docs/REMOTE_ACCESS.md` — rewrote the intro / TL;DR / decision table; new "Option 4: Tailscale or Docker bypass (interface-scoped, on by default)" section; updated Option 1's exemption list. - `docs/CONFIGURATION.md` — new "Trusted-interface bypass" subsection under Access Control; updated the "Safe-by-default lockdown" so its exempt-list is accurate. ## Caveats (documented) - `100.64.0.0/10` is also used by some carrier-grade-NAT ISPs. If your server's public uplink is itself behind CGNAT, an internet client could appear with a Tailscale-shaped source IP — set `BYPASS_AUTH_TAILSCALE=false` or bind `HOST` to your `tailscale0` IP. - `172.16.0.0/12` also covers some private LAN deployments that aren't Docker. If your non-Docker LAN uses `172.16.x.x` / `172.20.x.x`, set `BYPASS_AUTH_DOCKER=false`. - The broader `ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK` (which trusts the entire RFC 1918 + CGNAT + ULA + link-local set) **stays default-off**. This PR only narrows the auto-trust to two interfaces where the access path itself is authenticated. ## Notes - No linked issue. Per `CONTRIBUTING.md`, one should be opened describing the user-facing problem (Tailscale users hitting the lockdown page on a fresh install) before this is merged. - Rebased on top of `main` after #463 (env hot-reload) merged, so the runtime-config and docs edits coexist cleanly. ## Test plan - [ ] Manually verify a fresh install with **no `.env` file** is reachable from a Tailscale device. Server log shows `[auth-bypass] BYPASS_AUTH_TAILSCALE=true …` once on first request. - [ ] Manually verify the same fresh-install scenario from a regular LAN phone (non-Tailscale, non-Docker) still hits the lockdown HTML page — confirms we narrowed the trust to just Tailscale/Docker, not the whole LAN. - [ ] Manually verify loopback (`http://127.0.0.1:7860`) on the host still works regardless of these flags' values. - [ ] Manually verify the bypass coexists with Basic Auth: set `BASIC_AUTH_USER` / `BASIC_AUTH_PASS`, refresh from Tailscale → loads with no prompt; refresh from a regular LAN phone → password prompt. - [ ] Manually verify explicit opt-out works: set `BYPASS_AUTH_TAILSCALE=false`, restart, refresh from Tailscale → lockdown page (or password prompt if Basic Auth is configured). - [ ] Manually verify the bypass beats the IP allowlist: set `IP_ALLOWLIST=192.168.1.0/24` (LAN only, NOT including Tailscale), keep defaults, hit from Tailscale → loads; hit from a non-allowlisted, non-Tailscale device → 403. - [ ] Manually verify the `[auth-bypass]` warning fires only **once per range per process**, not on every subsequent request. - [ ] Manually verify Docker bypass from inside a container on the default bridge: `curl http://<host-bridge-ip>:7860/api/health` from a sidecar container → 200, server logs `[auth-bypass] BYPASS_AUTH_DOCKER=true …` once. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added automatic trust for Tailscale and Docker network traffic by default * Introduced configuration options to disable Tailscale and Docker interface bypasses if needed * **Documentation** * Updated configuration guides to document new trusted interface bypass options and their default behavior <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:18 +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#4630
No description provided.