[PR #8046] [MERGED] fix(server): stop treating CGNAT as a trusted private network #8073

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

📋 Pull Request Information

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

Base: staging ← Head: fix/private-network-no-cgnat


📝 Commits (3)

  • 8e01e43 fix(server): stop treating CGNAT as a trusted private network
  • 7d64f44 docs: say TRUSTED_PRIVATE_NETWORKS replaces the default ranges
  • 795048d test(server): pin CGNAT as non-routable after leaving the private-network list

📊 Changes

6 files changed (+20 additions, -11 deletions)

View changed files

📝 docs/CONFIGURATION.md (+1 -1)
📝 docs/REMOTE_ACCESS.md (+2 -2)
📝 packages/server/src/config/runtime-config.ts (+1 -1)
📝 packages/server/src/middleware/csrf-protection.ts (+2 -2)
📝 packages/server/src/middleware/ip-allowlist.ts (+5 -4)
📝 scripts/regressions/access-policy.regression.ts (+9 -1)

📄 Description

Why

ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=true also trusted 100.64.0.0/10 (carrier-grade NAT). Some internet providers hand out addresses from this range, so a host with such an address would skip the login for unrelated customers of that provider. This hardens the default: Tailscale keeps its own trust rule (real Tailscale interface check, BYPASS_AUTH_TAILSCALE), so CGNAT does not need to be in the private-network list.

What changed

  • Removed 100.64.0.0/10 from DEFAULT_PRIVATE_NETWORK_CIDRS (ip-allowlist.ts), so isPrivateNetworkIp and the access policy no longer trust it.
  • CGNAT stays "never public": non-routable check, broad-allowlist check, reserved-address check and CSRF literal-host auto-trust still treat it as non-public, so Tailscale URLs and small CGNAT allowlists behave as before.
  • Operators who really want it can list 100.64.0.0/10 in TRUSTED_PRIVATE_NETWORKS (documented in docs/CONFIGURATION.md and docs/REMOTE_ACCESS.md).
  • Regression in access-policy.regression.ts: a 100.64.x.x peer needs a login with the flag on, a 192.168.x.x peer does not, and TRUSTED_PRIVATE_NETWORKS=100.64.0.0/10 restores it. It fails on staging without the fix.

Validation

  • access-, docker-proxy, loopback-proxy regressions: pass. pnpm check: exit 0.
  • Local CodeRabbit: 2 doc findings, both fixed.

Manual verification

  • Manually verify a Tailscale peer (direct) still skips the login in automatic mode.
  • Manually verify a 100.64.x.x non-Tailscale peer is asked to log in with the flag on.
  • Manually verify a LAN peer (192.168.x.x) still skips the login with the flag on.

Notes

  • Part of #7914
  • docs-i18n follow-up needed for docs/REMOTE_ACCESS.md (translated packs on the docs-i18n branch).

🔄 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/8046 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/private-network-no-cgnat` --- ### 📝 Commits (3) - [`8e01e43`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8e01e43282a295e469cbae0a8cc07138b4352690) fix(server): stop treating CGNAT as a trusted private network - [`7d64f44`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7d64f447280adb20e9ebe6e06f5b035648003bf8) docs: say TRUSTED_PRIVATE_NETWORKS replaces the default ranges - [`795048d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/795048d5e98f4cba1f3bfd6878765ef09063d4c5) test(server): pin CGNAT as non-routable after leaving the private-network list ### 📊 Changes **6 files changed** (+20 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/CONFIGURATION.md` (+1 -1) 📝 `docs/REMOTE_ACCESS.md` (+2 -2) 📝 `packages/server/src/config/runtime-config.ts` (+1 -1) 📝 `packages/server/src/middleware/csrf-protection.ts` (+2 -2) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+5 -4) 📝 `scripts/regressions/access-policy.regression.ts` (+9 -1) </details> ### 📄 Description ## Why `ALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=true` also trusted `100.64.0.0/10` (carrier-grade NAT). Some internet providers hand out addresses from this range, so a host with such an address would skip the login for unrelated customers of that provider. This hardens the default: Tailscale keeps its own trust rule (real Tailscale interface check, `BYPASS_AUTH_TAILSCALE`), so CGNAT does not need to be in the private-network list. ## What changed - Removed `100.64.0.0/10` from `DEFAULT_PRIVATE_NETWORK_CIDRS` (`ip-allowlist.ts`), so `isPrivateNetworkIp` and the access policy no longer trust it. - CGNAT stays "never public": non-routable check, broad-allowlist check, reserved-address check and CSRF literal-host auto-trust still treat it as non-public, so Tailscale URLs and small CGNAT allowlists behave as before. - Operators who really want it can list `100.64.0.0/10` in `TRUSTED_PRIVATE_NETWORKS` (documented in `docs/CONFIGURATION.md` and `docs/REMOTE_ACCESS.md`). - Regression in `access-policy.regression.ts`: a `100.64.x.x` peer needs a login with the flag on, a `192.168.x.x` peer does not, and `TRUSTED_PRIVATE_NETWORKS=100.64.0.0/10` restores it. It fails on `staging` without the fix. ## Validation - `access-`, `docker-proxy`, `loopback-proxy` regressions: pass. `pnpm check`: exit 0. - Local CodeRabbit: 2 doc findings, both fixed. ## Manual verification - [ ] Manually verify a Tailscale peer (direct) still skips the login in automatic mode. - [ ] Manually verify a `100.64.x.x` non-Tailscale peer is asked to log in with the flag on. - [ ] Manually verify a LAN peer (`192.168.x.x`) still skips the login with the flag on. ## Notes - Part of #7914 - docs-i18n follow-up needed for `docs/REMOTE_ACCESS.md` (translated packs on the `docs-i18n` branch). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:09 +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#8073
No description provided.