Repository navigation
fix: redirect only to the request's own origin while REDIRECT_DOMAINS is empty - #3
Merged
Merged
Conversation
… is empty PassChallenge compared redir's host with itself when REDIRECT_DOMAINS was empty, so a solved challenge could be sent to any host. A fixed REDIRECT_DOMAINS cannot list every name a Keel Web site is reached by (a new DNS name, a 0042 site, a cloud public IP behind NAT). debian/patches/redir-same-host.patch: with REDIRECT_DOMAINS empty, redir must be relative or name the request's own scheme, host and port, and never carries userinfo; with it set, behaviour is unchanged. TestRedirectAllowed (18 cases) failed to build before the change. The autopkgtest drives pass-challenge behind nginx: same host by an unlisted name, relative and IPv6 literal allowed; another host, //evil, userinfo and another IPv6 address refused. 1.27.0-0+keel3.
marcos-mendez
added a commit
to Keel-Linux/keel-web
that referenced
this pull request
Oct 2, 2026
…gin check anubis-redirect-domains built Anubis's allowed list from hostname and ip addr at each start, never at spec apply, so a new DNS name, a 0042 site or a public IP behind NAT failed with redirect_domain_not_allowed after the challenge. anubis 1.27.0-0+keel3 (Keel-Linux/anubis#3) closes the open redirect itself while REDIRECT_DOMAINS is empty: redir must be relative or name the request's own scheme, host and port, never with userinfo. So keel-web drops the generator, its unit, the drop-in and the postinst, depends on anubis (>= 1.27.0-0+keel3), and drops iproute2. Measured on the Keel Web container (step7b image, cloud_simple, these packages): Chromium passes the challenge by unlisted.keel.test (in neither /etc/hosts nor DNS of the machine, sent as Host), by IPv6 and by IPv4. With the browser's pass-challenge rewritten to redir https://evil.example/, //evil.example/ or https://a@evil.example/, Anubis answers "Redirect domain not allowed" and the browser sends nothing to evil.example. tests: 100 bats, coverage 100 percent for the three shell files.
redirectAllowed let through a redir with neither scheme nor host, and Go parses /\evil.example that way while browsers read /\ as //, so http.Redirect sent the visitor to evil.example (review of #3). debian/patches/redir-validate.patch backports upstream's validateRedirect: no backslash, control byte or leading space, no opaque URL, no path starting with //, relative only from /, only http and https; and runs it again on the percent-decoded redir (/%2F/evil, /%5Cevil). TestPassChallengeRefusesRedirectTricks drives PassChallenge with 16 such forms (6 of them redirected before the patch) and checks that a relative and a same-origin redir still pass. The autopkgtest refuses /\evil, /%2F/evil, /%5Cevil, %09//evil and ' //evil' behind nginx.
With redir-validate.patch, //evil.example is refused as an invalid redirect before the host check, so the autopkgtest's refused() expected the wrong message and failed in CI. A refusal is either "Redirect domain not allowed" or "Invalid redirect"; allowed() still requires neither.
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.
Closes pass-challenge's open redirect without needing
REDIRECT_DOMAINS(review of Keel-Linux/keel-web#3).Root cause: with
REDIRECT_DOMAINSempty,PassChallengecompares the host ofredirwith itself, becauser.URLisredirparsed again. A solved challenge can therefore be sent to any host. SettingREDIRECT_DOMAINScloses this only for the names listed in it. Keel Web cannot list every name ahead of time: a new DNS name, a site from decision 0042, or a cloud public IP behind NAT would each hitredirect_domain_not_allowed.Change (1.27.0-0+keel3,
debian/patches/redir-same-host.patch, DEP-3): a newredirectAllowedfunction decides:redirREDIRECT_DOMAINSsetREDIRECT_DOMAINSemptyX-Forwarded-Proto, or http, plusHost, with default ports filled in)Tests:
TestRedirectAllowed, 18 cases. It covers the same host by name, by a name not in/etc/hosts, by IPv4 and by an IPv6 literal. It refuses another host,//evil,https://a@evil,https://host@evil, another port and another scheme.pass-challengebehind nginx with a made-up challenge. The redir check runs first, so the error page shows which way it went. Allowed: same host by an unlisted name, a relative redir, an IPv6 literal. Refused: another host,//evil, userinfo, another IPv6 address.Test plan
build / trixieandautopkgtest / trixiegreenREDIRECT_DOMAINSempty