# Open Redirect (6.0.0 < rails < 6.0.3.2)

Unvalidated `location` param in Rails ActionableExceptions middleware caused an open redirect via POST to /rails/actions, redirecting victims to attacker-controlled URLs.

- Payout: $1,000
- Severity: high
- Program: Ruby on Rails
- Found by: ooooooo_q
- Disclosed: 2020-12-22
- CVE: CVE-2020-8264, CVE-2020-8185
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/904059
- Library page: https://bugbountylibrary.com/r/h1%3A904059
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:high tech:ruby technique:incomplete-fix technique:source-review vuln:open-redirect

**Target:** Rails ActionDispatch::ActionableExceptions middleware endpoint /rails/actions
**Root cause:** The middleware passed request.params[:location] directly into the Location header without validating it was a relative/safe path.
**Steps:**
1. Run a Rails 6.0.3.1 app in production with show_exceptions enabled
2. Host an HTML page with `<form method="post" action="http://localhost:3000/rails/actions?error=ActiveRecord::PendingMigrationError&action=Run%20pending%20migrations&location=https://www.hackerone.com/">`
3. Serve it via `python3 -m http.server 8000`
4. Victim opens http://localhost:8000/attack.html and submits the form
5. Server responds 302 with `Location: https://www.hackerone.com/`
**How found:** While reading the changelog/commit for CVE-2020-8185, the researcher reviewed the patched actionable_exceptions.rb source and noticed `location` was still taken from request params unvalidated.
**Exploitation:** Attacker lures victim to a page that auto-submits a POST to the target's /rails/actions endpoint with a crafted `location` param; the app issues a 302 to the attacker-chosen external URL.
**Escalation:** Author notes it can bypass referrer checks or feed SSRF, though POST-to-GET conversion limits phishing utility.
**Insight:** When a CVE fix lands, diff the surrounding code for sibling unvalidated params in the same middleware—patches often narrow one condition while leaving adjacent sinks exposed.

## Proof of concept (copied exactly from the original report)

**Malicious HTML form posting location param**

```
<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>
```

