mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7920] [MERGED] fix(server): treat a relayed Host on a loopback socket as remote #8005
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#8005
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/7920
Author: @Gunterlie
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @Gunterlie
Base:
staging← Head:fix/loopback-relayed-host📝 Commits (3)
5676850fix(server): treat a relayed Host on a loopback socket as remoted47dc01fix(server): document relayed-Host detection and harden its regression5d38b6efix(client): mark LAN visitors of the Vite dev proxy as forwarded📊 Changes
8 files changed (+93 additions, -6 deletions)
View changed files
📝
.env.example(+2 -1)📝
docs/REMOTE_ACCESS.md(+1 -1)📝
docs/TROUBLESHOOTING.md(+1 -0)📝
packages/client/vite.config.ts(+8 -1)📝
packages/server/src/middleware/host-validation.ts(+1 -1)📝
packages/server/src/middleware/ip-allowlist.ts(+25 -2)📝
packages/server/src/routes/generate/prompt-preview.ts(+2 -0)📝
scripts/regressions/loopback-proxy-auth-security.regression.ts(+53 -0)📄 Description
Linked issue
Part of #7909. @SpicyMarinara
Why this change
REQUIRE_AUTH_FOR_LOOPBACK_PROXYtreats a loopback request as a remote visitor only when it carries proxy forwarding headers. A proxy or tunnel on the same computer that passes the visitor's public Host but adds no forwarding headers still looked like the owner's own browser, so its visitors skipped Basic Auth, the allowlist and admin-secret checks.A browser on this computer always addresses Marinara by a local name. A loopback socket that announces a domain or a LAN address was relayed, so it now gets the same checks as other proxied traffic.
What changed
Hostis notlocalhost,*.localhost, a loopback/unspecified IP, or the machine's own hostname (<hostname>,<hostname>.local, e.g. Debian's127.0.1.1mapping) counts as relayed by a local proxy.REQUIRE_AUTH_FOR_LOOPBACK_PROXY=falsestill turns this off.docker-gateway-auth-security).Host, so it stays a local call.Host(changeOrigin: false), so LAN devices usingpnpm devare no longer seen as local.docs/REMOTE_ACCESS.md,docs/TROUBLESHOOTING.mdand.env.exampledescribe the Host-based detection and the custom/etc/hostsalias case.localhost,LOCALHOST.,[::1],[::ffff:127.0.0.1],0.0.0.0,[::],127.0.1.1, own hostname) stay local; relayed Host with correct Basic Auth works;:authority-only requests; prompt-preview inner Host.Known limit, unchanged by design: a relay that rewrites
Hostto a loopback name and adds no forwarding headers (for example nginx with defaultproxy_passand noX-Forwarded-For, or raw TCP forwards) cannot be told apart from a local browser. The docs already require forwarding headers or Basic Auth for those setups.Validation
Run by the agent on devbox:
loopback-proxy-auth-security,docker-proxy-auth,docker-gateway-auth-security,basic-auth-throttle-securityregressions: passpnpm regression:android-local-auth: passserver
tsc --noEmit: pass; client typecheck: passpnpm regression:security:multiplayer-peer-server-securityfails withERR_TLS_CERT_ALTNAME_INVALIDin this environment; it fails the same way on the unchanged treepnpm check: pass (exit 0; 1 existing lint warning, 0 errors)pnpm checkpasses locallyContainer (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.mdManual verification notes
http://localhost:7860,http://127.0.0.1:7860andhttp://<hostname>:7860on the host computer still open without a password when no auth is configured.X-Forwarded-Fornow asks for Basic Auth.pnpm devonlocalhost:5173works as before. LAN phone testing throughpnpm devnow needs Basic Auth orALLOW_UNAUTHENTICATED_PRIVATE_NETWORK=true, like a direct LAN connection.Local review
Host, so any pass-through proxy already lets them sendHost: localhost; removing the exemption closes nothing there. It only matters for a proxy routed by the machine's own LAN-only name without forwarding headers, which belongs to the documented header-less relay limit above. Removing it would lock out the default Debian/Ubuntu local URLhttp://<hostname>:7860.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Docs-i18n follow-up: #7921
UI evidence (if applicable)
Not applicable: server-side access check, docs and dev proxy only.
Summary by CodeRabbit
Bug Fixes
Documentation
127.0.0.1.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.