CVE-2024-21636: View component Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-wf2x-8w6j-qw37
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-2024-21636 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting View component libraries in the RubyGems ecosystem. The issue involves view_component cross-site scripting vulnerability. Remediation is available by upgrading affected packages to version 3.9.0, 2.83.0.

CVE-2024-21636 at a Glance

CVE Identifier CVE-2024-21636
GHSA Identifier GHSA-wf2x-8w6j-qw37
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product View component
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2024-21636

To remediate this vulnerability, upgrade all affected View component dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

view_component fixed: 3.9.0
Upgrade view_component to 3.9.0
view_component fixed: 2.83.0
Upgrade view_component to 2.83.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for view_component

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-21636, inspect your project dependencies for View component:

inspect dependencies for view_component

Analyze the terminal output to locate any version of View component in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.9.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In View component, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact _What kind of vulnerability is it? Who is impacted?_ This 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. In 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. ### Patches _Has the problem been patched? What versions should users upgrade to?_ Versions 3.9.0 has been released and fully mitigates both the `#call` and the `#output_postamble` vulnerabilities. ### Workarounds _Is there a way for users to fix or remediate the vulnerability without upgrading?_ Sanitize the return value of `#call`, eg: ```ruby class MyComponent < ApplicationComponent def call html_escape("<div>#{user_input}</div>") end end ``` ### References _Are there any links users can visit to find out more?_ https://github.com/ViewComponent/view_component/pull/1950 ### For more information If you have any questions or comments about this advisory: Open an issue in the [github/view_component](https://github.com/github/view_component) project.

CVE-2024-21636 Affected View component Versions

2 component(s)
Fixed Versions:
3.9.02.83.0
Product / Package Ecosystem Affected Versions Fixed Version
view_component
RubyGems
≥ 3.0.0
< 3.9.0
3.9.0
view_component
RubyGems
< 2.83.0
2.83.0

References

Frequently Asked Questions

What is CVE-2024-21636?
CVE-2024-21636 is a security vulnerability in View component involving view_component Cross-site Scripting vulnerability under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which View component versions are affected?
Affected versions include releases prior to 3.9.0, 2.83.0 across affected packages: view_component.
What version fixes CVE-2024-21636?
Upgrading to 3.9.0, 2.83.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is view_component affected?
Yes, view_component is affected in releases prior to 3.9.0, 2.83.0. Upgrade your dependency to 3.9.0, 2.83.0 or later.
What is the CVSS score of CVE-2024-21636?
CVE-2024-21636 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2024-21636?
CVE-2024-21636 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check RubyGems dependencies for CVE-2024-21636?
Run the dependency tree command: 'inspect dependencies for view_component'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wf2x-8w6j-qw37",
  "modified" : "2024-01-04T21:54:34Z",
  "published" : "2024-01-04T21:54:34Z",
  "aliases" : [ "CVE-2024-21636" ],
  "summary" : "view_component Cross-site Scripting vulnerability",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "view_component"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.9.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "view_component"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.83.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ViewComponent/view_component/security/advisories/GHSA-wf2x-8w6j-qw37"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21636"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ViewComponent/view_component/pull/1950"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ViewComponent/view_component/pull/1962"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ViewComponent/view_component/commit/0d26944a8d2730ea40e60eae23d70684483e5017"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ViewComponent/view_component/commit/c43d8bafa7117cbce479669a423ab266de150697"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ViewComponent/view_component"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/view_component/CVE-2024-21636.yml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-04T21:54:34Z",
    "nvd_published_at" : "2024-01-04T20:15:25Z"
  }
}