Repository navigation
fix(transit): limit the redirects the feed proxy follows - #990
Open
Medformatik wants to merge 2 commits into
Open
Medformatik wants to merge 2 commits into
Medformatik wants to merge 2 commits into
Conversation
Medformatik
force-pushed
the
fix/feed-proxy-redirect-targets
branch
from
November 16, 2026 10:00
601645a to
1fafb19
Compare
The proxy followed any upstream redirect, including ones to internal names and addresses. It now follows one redirect that is relative, to the feed's own host, or to another host with a public-looking name, never from https to http, and answers anything else with 502. Relative redirects keep the feed's scheme and port.
The proxy validated the redirect host but passed the raw Location on, so nginx could read a different host out of it. The target is now rebuilt from the matched scheme, authority and path, a Location with a fragment or other non-URL characters is refused, and names under this stack's Compose networks no longer count as public.
Medformatik
force-pushed
the
fix/feed-proxy-redirect-targets
branch
from
November 16, 2026 17:23
1fafb19 to
17c44ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The MOTIS feed proxy followed every redirect a realtime feed host answered with, to any scheme and host. A feed host could therefore point the proxy at an internal service name or a private address on the shared container network, and the response was cached and handed to MOTIS as the feed.
The generated nginx configuration now follows one redirect per request, and only when it is relative, goes to the feed's own host, or goes to another host whose name looks public (dotted, no IP literal, no port, no user info, none of the local or internal suffixes). An https feed is never followed onto http. The target is rebuilt from the checked scheme, host and path instead of passing the raw
Locationheader on, a header with a fragment, backslash, whitespace or control characters is refused, and names under this stack's Compose networks do not count as public. Any other redirect, and any second redirect, is answered with 502 and is not cached. Per-feed headers still do not reach a redirect target.Two smaller defects in the same block are fixed along the way: a relative redirect used the scheme of the incoming request, which downgraded https feeds to http and dropped a non-default port, and a relative redirect with
://in its query string was treated as absolute.Known limit: a hostname check cannot tell where a public name resolves. Moving the proxy onto its own network would close that and is left for a separate change.
Related work
Fourth layer of the stack that starts with #983.
Verification
build.test.tspasses with new structural checks and a table of followed and refused redirect targets evaluated against the same patterns the configuration uses; the data-managergen-full-configtest passes (78 tests in both files).check-typesand Biome pass for the package.nginx -tin the pinned nginx image without network access. With a local upstream in the same container, relative, same-host and 303 redirects were followed, internal names, IP literals, ports, user info, protocol-relative and non-http targets were refused with 502, a second redirect was refused, a per-feed header was not forwarded, and refusals were not cached.Release and upgrade impact
No operator action and no migration. A feed whose host redirects to an internal name, an IP address or a non-default port on another host stops updating until its URL is corrected.
No package release: the extension CLI is counted through the shared feed-proxy configuration package, but it does not render or ship that nginx configuration.