Cross site scripting vulnerability in ActionView
Published 19 Mar 2020 · Updated 8 Jul 2026
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.2.4.2
- Fixed in
- 5.2.4.2
bundle update --conservative actionview # Gemfile: '>= 5.2.4.2'- Affected
- >=6.0.0 <6.0.2.2
- Fixed in
- 6.0.2.2
bundle update --conservative actionview # Gemfile: '>= 6.0.2.2'Details
There is a possible cross site scripting (XSS) vulnerability in ActionView's JavaScript literal escape helpers. Views that use the j or escape_javascript methods may be susceptible to XSS attacks.
Impact
There is a possible XSS vulnerability in the j and escape_javascript methods in ActionView. These methods are used for escaping JavaScript string literals. Impacted code will look something like this:
<script>let a = `<%= j unknown_input %>`</script>
or
<script>let a = `<%= escape_javascript unknown_input %>`</script>
Releases
The 6.0.2.2 and 5.2.4.2 releases are available at the normal locations.
Workarounds
For those that can't upgrade, the following monkey patch may be used:
ActionView::Helpers::JavaScriptHelper::JS_ESCAPE_MAP.merge!(
{
"`" => "\\`",
"$" => "\\$"
}
)
module ActionView::Helpers::JavaScriptHelper
alias :old_ej :escape_javascript
alias :old_j :j
def escape_javascript(javascript)
javascript = javascript.to_s
if javascript.empty?
result = ""
else
result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
end
javascript.html_safe? ? result.html_safe : result
end
alias :j :escape_javascript
endPatches
To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.
- 5-2-js-helper-xss.patch - Patch for 5.2 series
- 6-0-js-helper-xss.patch - Patch for 6.0 series
Please note that only the 5.2 and 6.0 series are supported at present. Users of earlier unsupported releases are advised to upgrade as soon as possible as we cannot guarantee the continued availability of security fixes for unsupported releases.
Credits
Thanks to Jesse Campos from Chef Secure
Is GHSA-65cv-r6x7-79hv 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
- Linkgithub.com/rails/rails/security/advisories/GHSA-65cv-r6x7-79hv
- Advisorynvd.nist.gov/vuln/detail/CVE-2020-5267
- Linkgithub.com/rails/rails/commit/033a738817abd6e446e1b320cb7d1a5c15224e9a
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/actionview/CVE-2020-5267.yml
- Linkgroups.google.com/forum/#!topic/rubyonrails-security/55reWMM_Pg8
- Linklists.debian.org/debian-lts-announce/2020/03/msg00022.html
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XJ7NUWXAEVRQCROIIBV4C6WXO6IR3KSB
- Linklists.opensuse.org/opensuse-security-announce/2020-05/msg00019.html
- Linkwww.openwall.com/lists/oss-security/2020/03/19/1
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.