{"id":"CVE-2024-21636","aliases":["CVE-2024-21636","GHSA-wf2x-8w6j-qw37"],"related":[],"kind":"vulnerability","state":"published","title":"view_component Cross-site Scripting vulnerability","summary":"view_component is a framework for building reusable, testable, and encapsulated view components in Ruby on Rails. Versions prior to 3.9.0 and 2.83.0 have a cross-site scripting vulnerability that has the potential to impact anyone rendering a component directly from a controller with the view_component gem. Note that only components that define a `#call` method (i.e. instead of using a sidecar template) are affected. The return value of the `#call` method is not sanitized and can include user-defined content. In addition, the return value of the `#output_postamble` methodis not sanitized, which can also lead to cross-site scripting issues. Versions 3.9.0 and 2.83.0 have been released and fully mitigate both the `#call` and the `#output_postamble` vulnerabilities. As a workaround, sanitize the return value of `#call`.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"view_component is a framework for building reusable, testable, and encapsulated view components in Ruby on Rails. Versions prior to 3.9.0 and 2.83.0 have a cross-site scripting vulnerability that has the potential to impact anyone rendering a component directly from a controller with the view_component gem. Note that only components that define a `#call` method (i.e. instead of using a sidecar template) are affected. The return value of the `#call` method is not sanitized and can include user-defined content. In addition, the return value of the `#output_postamble` methodis not sanitized, which can also lead to cross-site scripting issues. Versions 3.9.0 and 2.83.0 have been released and fully mitigate both the `#call` and the `#output_postamble` vulnerabilities. As a workaround, sanitize the return value of `#call`.","source":"cvelist"},{"lang":"en","text":"### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nThis is an XSS vulnerability that has the potential to impact anyone rendering a component directly from a controller with the view_component gem. Note that only components that define a [`#call` method](https://viewcomponent.org/guide/templates.html#call) (i.e. instead of using a sidecar template) are affected. The return value of the `#call` method is not sanitized and can include user-defined content.\n\nIn addition, the return value of the [`#output_postamble` method](https://viewcomponent.org/api.html#output_postamble--string) is not sanitized, which can also lead to XSS issues.\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\nVersions 3.9.0 has been released and fully mitigates both the `#call` and the `#output_postamble` vulnerabilities.\n\n### Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\nSanitize the return value of `#call`, eg:\n\n```ruby\nclass MyComponent < ApplicationComponent\n  def call\n    html_escape(\"<div>#{user_input}</div>\")\n  end\nend\n```\n\n### References\n_Are there any links users can visit to find out more?_\n\nhttps://github.com/ViewComponent/view_component/pull/1950\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\nOpen an issue in the [github/view_component](https://github.com/github/view_component) project.","format":"markdown","source":"ghsa"},{"lang":"es","text":"view_component es un framework para crear componentes de vista reutilizables, comprobables y encapsulados en Ruby on Rails. Las versiones anteriores a la 3.9.0 tienen una vulnerabilidad de cross site scripting que tiene el potencial de afectar a cualquiera que renderice un componente directamente desde un controlador con la gema view_component. Tenga en cuenta que sólo se ven afectados los componentes que definen un método `#call` (es decir, en lugar de utilizar una plantilla complementaria). El valor de retorno del método `#call` no está sanitizado y puede incluir contenido definido por el usuario. Además, el valor de retorno del método `#output_postamble` no está sanitizado, lo que también puede provocar problemas de cross site scripting. Se lanzó la versión 3.9.0 y mitiga por completo las vulnerabilidades `#call` y `#output_postamble`. Como workaround, sanitice valor de retorno de `#call`.","source":"nvd"}],"published":"2024-01-04T20:09:08.564Z","modified":"2026-09-10T03:49:24.818Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":">= 3.0.0, < 3.9.0","status":"affected"},{"version":"< 2.83.0","status":"affected"}],"vendor":"ViewComponent","product":"view_component","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.0.0","status":"affected","fixed":"3.9.0"}],"ecosystem":"RubyGems","package":"view_component","purl":"pkg:gem/view_component","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.83.0"}],"ecosystem":"RubyGems","package":"view_component","purl":"pkg:gem/view_component","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.83.0"},{"status":"affected","introduced":"3.0.0","fixed":"3.9.0"}],"vendor":"viewcomponent","product":"view_component","cpe":"cpe:2.3:a:viewcomponent:view_component:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ViewComponent/view_component/security/advisories/GHSA-wf2x-8w6j-qw37","tags":["vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ViewComponent/view_component/pull/1950","tags":["exploit","issue-tracking","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ViewComponent/view_component/pull/1962","tags":["issue-tracking","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ViewComponent/view_component/commit/0d26944a8d2730ea40e60eae23d70684483e5017","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ViewComponent/view_component/commit/c43d8bafa7117cbce479669a423ab266de150697","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-21636","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ViewComponent/view_component","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/view_component/CVE-2024-21636.yml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-01-09T21:13:15.952Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-21636","url":"https://www.cve.org/CVERecord?id=CVE-2024-21636","licence":"CVE Terms of Use","modified":"2025-06-17T20:29:11.989Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wf2x-8w6j-qw37","url":"https://github.com/advisories/GHSA-wf2x-8w6j-qw37","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:24.818Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-21636","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-21636","licence":"Public domain","modified":"2026-06-17T07:09:53.780Z"}],"updatedAt":"2026-11-25T22:58:35.920Z","epss":{"score":0.00495,"percentile":0.44096,"date":"2026-12-01T12:00:22.000Z"}}