CSRF Vulnerability in rails-ujs
Published 7 Jul 2020 · Updated 16 Feb 2024
Is your project on an affected actionview?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- >=5.0.0 <5.2.4.3
- Fixed in
- 5.2.4.3
bundle update --conservative actionview # Gemfile: '>= 5.2.4.3'- Affected
- >=6.0.0 <6.0.3.1
- Fixed in
- 6.0.3.1
bundle update --conservative actionview # Gemfile: '>= 6.0.3.1'Details
There is a vulnerability in rails-ujs that allows attackers to send CSRF tokens to wrong domains.
Versions Affected: rails <= 6.0.3 Not affected: Applications which don't use rails-ujs. Fixed Versions: rails >= 5.2.4.3, rails >= 6.0.3.1
Impact ------
This is a regression of CVE-2015-1840.
In the scenario where an attacker might be able to control the href attribute of an anchor tag or the action attribute of a form tag that will trigger a POST action, the attacker can set the href or action to a cross-origin URL, and the CSRF token will be sent.
Workarounds -----------
To work around this problem, change code that allows users to control the href attribute of an anchor tag or the action attribute of a form tag to filter the user parameters.
For example, code like this:
link_to params
to code like this:
link_to filtered_params
def filtered_params # Filter just the parameters that you trust end
Is GHSA-xq5j-gw7f-jgj8 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected actionview, and gives you the command that fixes it.
More advisories for actionview
- MediumCVE-2026-126078Action View: Possible XSS vulnerability in highlight helper · 12 Nov 2026
- MediumCVE-2026-126070Action View: Possible XSS vulnerability in strip_tags · 12 Nov 2026
- MediumCVE-2026-126079Action View: Possible XSS vulnerability in text helpers · 12 Nov 2026
- MediumCVE-2026-126069Action View: Possible XSS vulnerability in tag helpers · 12 Nov 2026
- LowCVE-2026-33168Rails has a possible XSS vulnerability in its Action View tag helpers · 23 Mar 2026
- MediumCVE-2023-23913rails-ujs vulnerable to DOM Based Cross-site Scripting contenteditable HTML Elements · 9 Jun 2023
References
- Advisorynvd.nist.gov/vuln/detail/CVE-2020-8167
- Linkhackerone.com/reports/189878
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/actionview/CVE-2020-8167.yml
- Linkgroups.google.com/forum/#!topic/rubyonrails-security/x9DixQDG9a0
- Linkgroups.google.com/g/rubyonrails-security/c/x9DixQDG9a0
- Linkwww.debian.org/security/2020/dsa-4766
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.