mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #346] [MERGED] feat(server): auto-trust private networks in basic-auth lockdown #4570
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4570
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/346
Author: @LukaTheHero
Created: 5/1/2026
Status: ✅ Merged
Merged: 5/1/2026
Merged by: @LukaTheHero
Base:
main← Head:feat/auto-trust-private-networks-in-lockdown📝 Commits (2)
1ead801feat(server): auto-trust private networks in basic-auth lockdown382a19efeat(server): TRUSTED_PRIVATE_NETWORKS override for lockdown bypass list📊 Changes
5 files changed (+143 additions, -20 deletions)
View changed files
📝
.env.example(+12 -3)📝
docs/CONFIGURATION.md(+30 -5)📝
packages/server/src/config/runtime-config.ts(+9 -0)📝
packages/server/src/middleware/basic-auth.ts(+25 -11)📝
packages/server/src/middleware/ip-allowlist.ts(+67 -1)📄 Description
Summary
Follow-up to #343. The safe-by-default lockdown shipped in that PR blocks all non-loopback / non-allowlisted IPs when no Basic Auth is configured — which protects accidentally-exposed public ports, but also breaks legitimate LAN, Docker, Kubernetes, and Tailscale users who were never the target of the lockdown.
This PR narrows the lockdown so it blocks only public-internet IPs. Private networks pass through automatically when no auth is configured:
127.0.0.1,::1) — already allowed.10.0.0.0/8,172.16.0.0/12(covers Docker default bridge172.17.0.0/16),192.168.0.0/16.169.254.0.0/16,fe80::/10.fc00::/7.100.64.0.0/10(Tailscale, carrier NAT).IP_ALLOWLISTentries — already allowed.These seven ranges are defaults, not hardcoded — operators can override the entire list via
TRUSTED_PRIVATE_NETWORKS(see below).Why
Discord feedback after #343 merged: a Docker user reported a 403 from a container on the same bridge network, and reasonably called it a breaking change. Same problem applies to anyone reaching Marinara from their phone on the LAN, from a Kubernetes pod, from a reverse proxy in another container, or from a Tailscale peer. None of those callers were the threat model of the lockdown — the threat model is "port 7860 got NAT'd onto the public internet by accident."
By restricting the lockdown to public IPs, the safety win is preserved (public exposure is still safe) without breaking any of the "I just want to use it from my phone" workflows that have always worked.
Principle of least surprise
The private-network exemption applies only to the no-auth lockdown. If the operator sets
BASIC_AUTH_USER/BASIC_AUTH_PASS, the password is required from every IP except loopback and explicitIP_ALLOWLISTmatches — including from the LAN. Reasoning: if you went out of your way to set a password, you meant it; the LAN-bypass would be a surprising security regression for someone trying to lock out a roommate on the same Wi-Fi.New env var:
TRUSTED_PRIVATE_NETWORKSThe seven default ranges cover the vast majority of LAN / Docker / Kubernetes / Tailscale setups. For operators whose network doesn't match — e.g. a publicly-routable corporate
/16they trust, or a shared10/8in a hostile datacenter they don't —TRUSTED_PRIVATE_NETWORKSaccepts a comma-separated list of IPs / CIDRs that replaces the defaults entirely (matchesIP_ALLOWLISTsemantics — what you type is what you get):When unset, the defaults are used. Invalid entries are logged with a warn and skipped.
Behaviour matrix
Files
packages/server/src/middleware/ip-allowlist.ts— addsDEFAULT_PRIVATE_NETWORK_CIDRS, a cached resolver that respects the override, and an exportedisPrivateNetworkIp(ip)helper. Existing IP allowlist hook is unchanged.packages/server/src/middleware/basic-auth.ts— lockdown branch now callsisPrivateNetworkIp(ip)before refusing. Updated docblock, lockdown 403 message, and warn-once log to reflect "public-only" semantics.packages/server/src/config/runtime-config.ts— addsgetTrustedPrivateNetworksOverride().docs/CONFIGURATION.md— rewrites the "Safe-by-default lockdown" section to list the auto-allowed ranges, clarifies that the exemption only applies in no-auth mode, and documentsTRUSTED_PRIVATE_NETWORKS..env.example— addsTRUSTED_PRIVATE_NETWORKSexample.Summary by CodeRabbit
New Features
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.