CVE-2022-24722: Cross-site Scripting Vulnerability in view_component

view_component Updated 02 Oct 2025

Summary

02/03/2022
Yes i
High
8.1

CVE-2022-24722: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in view_component. Affects view_component across 2 version ranges.

>= 2.31.0, < 2.31.2 >= 2.32.0, < 2.49.1

Fixed in 2.31.2 or 2.49.1, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

view_component is a RubyGem that provides a framework for building reusable view components in Ruby on Rails applications. It allows developers to encapsulate UI elements into reusable components, improving code organization and reusability. However, versions 2.31.0 to 2.31.2 and versions 2.32.0 to 2.49.1 of view_component are vulnerable to a cross-site scripting (XSS) attack. This vulnerability arises when user input is not properly sanitized before being passed as an argument to the translate method, which can lead to the execution of malicious scripts on the user's browser.

Vulnerability Detail

The XSS vulnerability in view_component arises due to improper neutralization of user input during web page generation. When user input is passed as an interpolation argument to the translate method without proper sanitization, it can be rendered as HTML on the page, allowing an attacker to inject and execute arbitrary scripts. This can lead to various security risks, including session hijacking, defacement of web pages, and theft of sensitive user information. The vulnerability has a CVSS score of 8.1, indicating a high severity level.

How To Fix

Latest published version: 4.19.0 as of 23 Oct 2026

gem install view_component -v 4.19.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 2.31.0, < 2.31.2 2.31.2
    gem install view_component -v 2.31.2
  • >= 2.32.0, < 2.49.1 2.49.1
    gem install view_component -v 2.49.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading to the fixed versions is not immediately feasible, developers can implement a workaround by manually sanitizing user input before passing it to the translate method. This can be done using HTML sanitization libraries or custom sanitization functions. Here's an example of how to sanitize user input using the sanitize method from the Rails framework:

# Sanitize user input before passing to translate
sanitized_input = sanitize(user_input)
translated_text = translate(sanitized_input)

It is important to note that workarounds may not provide the same level of security as upgrading to the fixed versions, so upgrading is still recommended.

Conclusion

The XSS vulnerability in view_component can have serious security implications for applications using affected versions. It is crucial for developers to upgrade to the fixed versions or implement proper input sanitization to mitigate the risk of XSS attacks. Following secure coding practices and staying updated with security advisories can help ensure the overall security of Ruby on Rails applications. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for view_component →

Share this vulnerability

FAQ

view_component is a RubyGem that enables developers to build reusable view components in Ruby on Rails applications. It helps improve code organization and reusability by encapsulating UI elements into self-contained components.

Cross-site scripting (XSS) is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. It occurs when user input is not properly sanitized and rendered as HTML on the page, enabling the execution of arbitrary scripts.

The XSS vulnerability in view_component allows attackers to inject and execute arbitrary scripts on web pages. This can lead to various security risks, including session hijacking, defacement of web pages, and theft of sensitive user information.

No, only versions 2.31.0 to 2.31.2 and versions 2.32.0 to 2.49.1 of view_component are affected by this XSS vulnerability. It is recommended to upgrade to versions 2.31.2 or 2.49.1 to mitigate the issue.

Developers can mitigate the XSS vulnerability in view_component by upgrading to versions 2.31.2 or 2.49.1, which have been released to fix the issue. Additionally, they should avoid passing user input directly to the translate function and ensure proper sanitization of all inputs before using them in interpolation arguments.

Related vulnerabilities

Recent vulnerabilities recorded for view_component.

How To Fix

Latest published version: 4.19.0 as of 23 Oct 2026

gem install view_component -v 4.19.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 2.31.0, < 2.31.2 2.31.2
    gem install view_component -v 2.31.2
  • >= 2.32.0, < 2.49.1 2.49.1
    gem install view_component -v 2.49.1

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback