Skip to content

Unvalidated redirect_back false negatives #1851

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

Open
mattyb opened this issue Jun 14, 2024 · 2 comments
Open

Unvalidated redirect_back false negatives #1851

mattyb opened this issue Jun 14, 2024 · 2 comments

Comments

@mattyb
Copy link

mattyb commented Jun 14, 2024

Background

Rails Version: 6.1.7.7
Brakeman Version: 6.1.2
Ruby Version: 3.1.5

Issue

Checks for redirect_back were added in #1756. Currently, calls to redirect_back without allow_other_hosts: true are allowed if fallback_location is specified. Setting fallback_location however does not prevent an attack via the Referer header. As documented here, fallback_location is only used if Referer is not set.

Note that in Rails >=7.0 this protection can also be handled via configuration https://guides.rubyonrails.org/configuring.html#config-action-controller-raise-on-open-redirects

@mattyb mattyb changed the title Unvalidated redirect false negatives Unvalidated redirect_back false negatives Jun 14, 2024
@presidentbeef
Copy link
Owner

Hm, okay, I think I am following.

🤔 Under what circumstances would an attacker be controlling the Referer header and need to abuse an open redirect?

Note that in Rails >=7.0 this protection can also be handled via configuration

Yes, Brakeman checks this config.

@mattyb
Copy link
Author

mattyb commented Jun 28, 2024

There's additional discussion in rails/rails#39643. I haven't validated myself, but some googling gave an example exploit here https://trustfoundry.net/2016/08/23/referer-redirection-inconspicuous-danger/

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

No branches or pull requests

2 participants