Skip to content

6.7.x: Prevent open redirect to other hosts #7460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

taylorsilva
Copy link
Member

Backport #7459

We fell victim to this behaviour: golang/go#38642

The solution in this commit ensures that the URI we redirect to is
always a path. The TrimLeft() removes all prefixed forward slashes,
which covers the case where a redirect uri starts with two or more
slashse.

We then always add a single forward slash which will ensure that
ParseRequestURI() interprets the URI as a path.

Now if someone visits `http://ci.concourse-ci.org/sky/login?redirect_uri=//google.com/`
they'll end up redirected to `http://ci.concourse-ci.org/google.com` which
will return a 404 and redirect one more time to the homepage.

In case the behaviour of ParseRequestURI() changes or is smarter in the
future, added check to ensure that if either Host or Scheme is
populated that the URI is not used for redirecting. The tests have also
been updated so this change in behaviour will cause the tests to fail.

Signed-off-by: Taylor Silva <[email protected]>
Co-authored-by: Esteban Foronda <[email protected]>
@taylorsilva taylorsilva changed the title 6.7x: Prevent open redirect to other hosts 6.7.x: Prevent open redirect to other hosts Aug 25, 2021
@taylorsilva taylorsilva merged commit 1b73a76 into release/6.7.x Aug 30, 2021
@taylorsilva taylorsilva deleted the 67x/login_redirect branch August 30, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants