Skip to content
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

Enable exceptions on open redirects #469

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

chrisroos
Copy link
Contributor

Raising an exception on open redirects is the default behaviour in Rails 7. We disabled it in ad01e1c (15 Mar 2022) with a comment saying:

allow open redirects, necessary for SSO

My guess is that this was required for the /auth/gds/sign_out path provided by gds-sso as that path redirects to Signon (i.e. a different host). The gds-sso Gem was updated in PR 250 (merged on 29 Mar 2022) to explicitly allow redirecting to a different host in /auth/gds/sign_out. I believe that change in gds-sso means we can safely remove this line.

I've checked that signing in and out continues to work as expected with this line removed.

I think the only risk of something breaking with this change is if session["redirect_to"] somehow contained a URL and not just the requested path that's stored in
GDS::SSO::FailureApp#store_location. I don't think we'd expect that to happen so it seems reasonable to raise an UnsafeRedirectError if it does.

Raising an exception on open redirects is the default behaviour in Rails
7[1]. We disabled it in ad01e1c (15 Mar
2022) with a comment saying:

> allow open redirects, necessary for SSO

My guess is that this was required for the `/auth/gds/sign_out` path
provided by gds-sso as that path redirects to Signon (i.e. a different
host). The gds-sso Gem was updated in PR 250[2] (merged on 29 Mar 2022)
to explicitly allow redirecting to a different host in
`/auth/gds/sign_out`. I believe that change in gds-sso means we can
safely remove this line.

I've checked that signing in and out continues to work as expected with
this line removed.

I think the only risk of something breaking with this change is if
`session["redirect_to"]` somehow contained a URL and not just the
requested path that's stored in
`GDS::SSO::FailureApp#store_location`[3]. I don't think we'd expect that
to happen so it seems reasonable to raise an UnsafeRedirectError if it
does.

[1]: https://guides.rubyonrails.org/configuring.html#config-action-controller-raise-on-open-redirects
[2]: alphagov/gds-sso#250
[3]: https://github.com/alphagov/gds-sso/blob/v18.1.0/lib/gds-sso/failure_app.rb#L47
Copy link
Contributor

@chrislo chrislo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@chrisroos chrisroos merged commit 239dadc into main Oct 17, 2023
@chrisroos chrisroos deleted the enable-exceptions-on-open-redirects branch October 17, 2023 13:20
@chrisroos
Copy link
Contributor Author

Thanks @chrislo! 👍

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.

2 participants