Skip to content

fix(transit): limit the redirects the feed proxy follows - #990

Open
Medformatik wants to merge 2 commits into
fix/nominatim-own-database-passwordfrom
fix/feed-proxy-redirect-targets
Open

Medformatik wants to merge 2 commits into
fix/nominatim-own-database-passwordfrom
fix/feed-proxy-redirect-targets

Conversation

@Medformatik

@Medformatik Medformatik commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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 Location header 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.ts passes with new structural checks and a table of followed and refused redirect targets evaluated against the same patterns the configuration uses; the data-manager gen-full-config test passes (78 tests in both files).
  • check-types and Biome pass for the package.
  • A rendered configuration passed nginx -t in 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.
  • Not checked: the https-to-http refusal at runtime (covered by the pattern test only), real cross-host fetches, and MOTIS against a live stack.

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.

@Medformatik Medformatik self-assigned this Nov 16, 2026
@Medformatik
Medformatik added this pull request to stack #985 November 16, 2026 09:05
@Medformatik
Medformatik force-pushed the fix/feed-proxy-redirect-targets branch from 601645a to 1fafb19 Compare November 16, 2026 10:00
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
Medformatik force-pushed the fix/feed-proxy-redirect-targets branch from 1fafb19 to 17c44ec Compare November 16, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant