CVE-2019-12732
Description
The Chartkick gem through 3.1.0 for Ruby allows XSS.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Chartkick Ruby gem through v3.1.0 is vulnerable to stored XSS when JSON encoding escapes are disabled and untrusted data is passed to charts.
Vulnerability
Overview
CVE-2019-12732 is a cross-site scripting (XSS) vulnerability in the Chartkick Ruby gem, affecting versions 3.1.0 and earlier. The root cause lies in the gem's handling of chart options and data when ActiveSupport's escape_html_entities_in_json configuration is set to false (which is not the default in Rails) or when Chartkick is used with a non-Rails framework such as Sinatra [4]. Under these conditions, user-supplied strings are not properly escaped before being embedded into JavaScript as part of the chart configuration, allowing an attacker to inject arbitrary JavaScript code.
Exploitation and
Attack Surface
Exploitation requires two conditions to be met simultaneously. First, the application must have disabled JSON HTML entity escaping (escape_html_entities_in_json = false) or be running outside of Rails. Second, untrusted data—either directly from user input via parameters or indirectly through database content—must be passed to a chart helper such as line_chart or column_chart [4]. The gem does not sanitize strings supplied as chart options (e.g., min: params[:min]) or as data series labels, making them vectors for script injection [2].
Impact
A successful attack allows an attacker to execute arbitrary JavaScript in the context of the victim's browser session when the page renders the chart. This can lead to session hijacking, credential theft, defacement, or redirection to malicious sites. No authentication is required to trigger the vulnerability if the vulnerable page is publicly accessible and receives untrusted input [3].
Mitigation
Chartkick version 3.2.0 patches this vulnerability by properly escaping JSON output in all configurations [2][4]. Users should upgrade to 3.2.0 or later immediately. For users unable to upgrade, ensuring escape_html_entities_in_json is set to true (the Rails default) and validating/sanitizing all data passed to chart helpers can reduce but not eliminate risk, especially in non-Rails frameworks.
AI Insight generated on May 22, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
chartkickRubyGems | < 3.2.0 | 3.2.0 |
Affected products
2- Ruby/Chartkickdescription
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
4- github.com/advisories/GHSA-g45g-g52h-39rgghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2019-12732ghsaADVISORY
- github.com/ankane/chartkick/blob/master/CHANGELOG.mdghsax_refsource_CONFIRMWEB
- github.com/ankane/chartkick/issues/488ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.