Skip to main content

ViewComponent EUVDEUVD-2026-45333

| CVE-2026-54498 HIGH
Cross-site Scripting (XSS) (CWE-79)
2026-07-15 https://github.com/ViewComponent/view_component GHSA-97jw-64cj-jc58
8.7
CVSS 3.1 · Vendor: https://github.com/ViewComponent/view_component
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify page rendering around_render component
  2. Delivery
    Craft HTML/script payload in user-controlled field
  3. Exploit
    Submit payload to reach around_render output
  4. Execution
    Server returns raw unescaped HTML
  5. Persist
    Victim loads page, script executes in origin
  6. Impact
    Session/token theft or authenticated actions

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires that the target application defines or uses a component overriding ViewComponent::Base#around_render, and that this hook returns or wraps HTML-unsafe content derived from attacker-influenced values (request parameters, model attributes, CMS/markdown content). The component must be rendered in a browser-visible response; impact and reliability increase when rendered through ViewComponent::Collection (which additionally marks the joined output html_safe) or via controller/direct render. Limiting factors: this is NOT exploitable against a default installation - it depends on a specific downstream coding pattern; per the given CVSS the attacker holds low privileges (PR:L) and the attack needs victim user interaction (UI:R, i.e., the victim must load the rendered page). Components that only use #call, or whose around_render returns already-escaped SafeBuffers, are not affected.

Impact

The supplied CVSS 3.1 vector (AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N, base 8.7) rates this High, but that score overstates real-world exploitability because it treats the flaw as if it always applies. In practice exploitation requires a specific non-default coding pattern: the downstream application must define or use a component whose around_render returns or wraps attacker-influenced HTML-unsafe content - the library is not exploitable on its own. There is no EPSS score, KEV listing, or SSVC decision data in the provided intelligence, so widespread automated exploitation cannot be inferred; the honest signal is that a working PoC exists but active exploitation is not confirmed. The C:H/I:H impact in the given vector is aggressive for an XSS class issue, which more typically yields limited confidentiality/integrity within the victim's browser session; I assess AC as High rather than Low to reflect the required non-default app behavior. Net: a genuine defensive priority for teams running affected versions that use around_render, but not a mass-exploitable, unauthenticated, default-configuration bug.

Exploit ScenarioDerived

An application uses around_render in a component (e.g., a BannerComponent that returns "<div class=\"banner\">#{@message}</div>") for layout wrapping, feature-flag fallback, or instrumentation, and @message carries user-controlled data such as a request parameter or CMS field. An attacker supplies a payload like <img src=x onerror=alert(1)>, which the hook emits as raw HTML, executing script in the victim's browser under the application's origin. A working PoC in the advisory confirms the raw output; because AV:N and UI:R, the attacker delivers the payload remotely and the victim need only view the affected page.

This Week Schedule remediation this week. Why: HIGH severity (CVSS 7.0-8.9).
Patch available 0.5% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jul 15, 2026

Stored/reflected XSS in the ViewComponent Rails gem (versions >= 4.0.0, < 4.12.0) arises because HTML-unsafe strings returned from a component's around_render hook bypass the automatic escaping applied to normal #call output, letting attacker-controlled data reach the browser as raw HTML. The flaw is amplified in collection rendering, where Collection#render_in joins per-item output and blindly marks it html_safe, laundering unsafe content into a trusted SafeBuffer. Publicly available exploit code exists (a detailed PoC in the GitHub advisory), but there is no public exploit identified as actively used in the wild; a vendor patch is available in v4.12.0.

RemediationAI

Vendor-released patch: 4.12.0 - upgrade the view_component gem to >= 4.12.0 (release https://github.com/ViewComponent/view_component/releases/tag/v4.12.0, fixing commit https://github.com/ViewComponent/view_component/commit/48e5fd2d602344c7d33019fbc5c8b087e315bb78), which now runs around_render return values through __vc_maybe_escape_html (emitting a warning) and switches Collection#render_in to safe_join so per-item output is escaped rather than laundered into a SafeBuffer. If you cannot upgrade immediately, audit every component that overrides around_render and ensure it returns an ActiveSupport::SafeBuffer only after explicitly escaping user-controlled data (wrap interpolated values with ERB::Util.html_escape or Rails' h/sanitize before building the string), which removes the raw-output risk at the cost of manually maintaining escaping; alternatively, move wrapping/instrumentation logic out of around_render and back into #call output so it inherits automatic escaping. As a further compensating control, harden Content-Security-Policy (disallow inline scripts and restrict script-src) on responses that render these components - note this mitigates script execution but not HTML-injection/UI-redress, and preview/example routes that disable CSP should be access-restricted.

Affected VersionsENISA

view_component 4.0.0, < 4.12.0

Affected Packages

rubygems view_component fix: 4.12.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in rubygems

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

ViewComponent is a Rails view abstraction (packaged as pkg:rubygems/view_component) that renders reusable component objects. Normal inline #call return values are routed through __vc_maybe_escape_html, which escapes HTML-unsafe strings so raw markup cannot reach output. The around_render lifecycle hook - used to wrap, replace, instrument, or conditionally return rendered content - did not pass its return value through that same safety boundary, so a string returned from around_render became the render result verbatim. This is a classic CWE-79 (Improper Neutralization of Input During Web Page Generation) failure of an incomplete output-encoding boundary: two code paths for the same output had inconsistent escaping guarantees. The collection path (Collection#render_in in lib/view_component/collection.rb) compounded it by calling .join(...).html_safe on component outputs, converting raw unsafe strings into an ActiveSupport::SafeBuffer that suppresses downstream escaping.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/ViewComponent/view_component) PRIMARY 8.7 HIGH
AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N
vuln.today AI 4.7 MEDIUM

Requires a non-default downstream pattern (around_render returning attacker data), so AC:H; unauthenticated attacker delivers payload but victim must view the page (PR:N/UI:R); XSS runs in the browser giving limited scope-changed confidentiality/integrity (S:C/C:L/I:L).

3.1 AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
4.0 AV:N/AC:H/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Primary rating from Vendor (https://github.com/ViewComponent/view_component).

CVSS VectorVendor: https://github.com/ViewComponent/view_component

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

DescriptionCVE.org

Summary

ViewComponent::Base#around_render can return HTML-unsafe strings that bypass the escaping behavior applied to normal #call return values. This creates an XSS risk when downstream applications use around_render to wrap, replace, instrument, or conditionally return content that includes user-controlled data.

The issue is especially dangerous in collection rendering because ViewComponent::Collection#render_in joins the per-item results and marks the entire output as html_safe, converting raw unsafe output into a trusted ActiveSupport::SafeBuffer.

Affected Code

Validated against:

  • Repository commit: eea79445
  • Ruby: 3.4.9

Relevant locations:

  • lib/view_component/base.rb
  • render_in
  • around_render
  • __vc_maybe_escape_html
  • lib/view_component/template.rb
  • InlineCall#safe_method_name_call
  • lib/view_component/collection.rb
  • Collection#render_in

Key code paths:

ruby
# lib/view_component/base.rb
around_render do
  render_template_for(@__vc_requested_details).to_s
end
ruby
# lib/view_component/template.rb
proc do
  __vc_maybe_escape_html(send(m)) do
    Kernel.warn(...)
  end
end
ruby
# lib/view_component/collection.rb
components.map do |component|
  component.render_in(view_context, &block)
end.join(rendered_spacer(view_context)).html_safe

Root Cause

Normal inline #call output is passed through __vc_maybe_escape_html, which escapes HTML-unsafe strings. However, when around_render itself returns a string, the returned value becomes the component render result without being passed through the same HTML-safety boundary.

This creates two different output-safety behaviors:

  • #call returning unsafe string: escaped
  • #around_render returning unsafe string: raw

Collection rendering then amplifies the issue by calling .html_safe on the joined result.

Proof of Concept

Run from the repository root:

ruby
$LOAD_PATH.unshift File.expand_path("lib", Dir.pwd)
require "action_controller/railtie"
require "rack/mock"
require "view_component/base"

class PocController < ActionController::Base; end

def vc
  c = PocController.new
  c.set_request!(ActionDispatch::Request.new(Rack::MockRequest.env_for("/poc")))
  c.set_response!(ActionDispatch::Response.new)
  c.view_context
end

PAYLOAD = "<img src=x onerror=alert(1)>"

class UnsafeCallComponent < ViewComponent::Base
  def initialize(payload:) = @payload = payload
  def call = @payload
end

class UnsafeAroundComponent < ViewComponent::Base
  def initialize(payload:) = @payload = payload
  def call = "SAFE"
  def around_render = @payload
end

class UnsafeAroundCollectionComponent < ViewComponent::Base
  with_collection_parameter :payload
  def initialize(payload:) = @payload = payload
  def call = "SAFE"
  def around_render = @payload
end

view_context = vc

normal = UnsafeCallComponent.new(payload: PAYLOAD).render_in(view_context)
around = UnsafeAroundComponent.new(payload: PAYLOAD).render_in(view_context)
collection = UnsafeAroundCollectionComponent.with_collection([PAYLOAD]).render_in(view_context)

puts "normal_call=#{normal}"
puts "normal_call_raw=#{normal.include?(PAYLOAD)} html_safe=#{normal.html_safe?}"
puts "around_render=#{around}"
puts "around_render_raw=#{around.include?(PAYLOAD)} html_safe=#{around.html_safe?}"
puts "collection=#{collection}"
puts "collection_raw=#{collection.include?(PAYLOAD)} html_safe=#{collection.html_safe?}"

c = PocController.new
c.set_request!(ActionDispatch::Request.new(Rack::MockRequest.env_for("/poc")))
c.set_response!(ActionDispatch::Response.new)
out = c.render_to_string(UnsafeAroundComponent.new(payload: PAYLOAD))
puts "controller_render_to_string=#{out}"
puts "controller_raw=#{out.include?(PAYLOAD)} html_safe=#{out.html_safe?}"

Observed output:

text
normal_call=&lt;img src=x onerror=alert(1)&gt;
normal_call_raw=false html_safe=true
around_render=<img src=x onerror=alert(1)>
around_render_raw=true html_safe=false
collection=<img src=x onerror=alert(1)>
collection_raw=true html_safe=true
controller_render_to_string=<img src=x onerror=alert(1)>
controller_raw=true html_safe=false

The control case confirms that normal #call output is escaped. The around_render cases confirm that the same payload is emitted raw.

Exploit Scenario

A downstream application defines a component that uses around_render for tracing, layout wrapping, feature-flag fallback, error fallback, or instrumentation. If the hook returns a string containing request data, model attributes, CMS content, markdown output, or other attacker-controlled values, the value can be rendered as raw HTML.

Example vulnerable pattern:

ruby
class BannerComponent < ViewComponent::Base
  def initialize(message:)
    @message = message
  end

  def call
    "fallback"
  end

  def around_render
    "<div class=\"banner\">#{@message}</div>"
  end
end

If message is user-controlled, scriptable HTML reaches the browser.

Impact

Successful exploitation allows XSS in applications using affected components. Depending on application context, impact can include:

  • session or token theft where cookies/tokens are accessible
  • authenticated actions as the victim
  • CSRF bypass through same-origin script execution
  • exfiltration of page data
  • credential phishing or UI redress inside trusted application origin

The collection path is particularly risky because it converts the joined raw output to html_safe, which can suppress later escaping.

Preconditions

  • The application defines or uses a component overriding around_render.
  • around_render returns or wraps attacker-influenced HTML-unsafe content.
  • The component is rendered in a browser-visible response.
  • Higher impact when rendered through ViewComponent::Collection or controller/direct rendering.

Chaining Potential

This finding can chain with:

  • preview routes or examples that accept URL parameters and render components
  • unsafe markdown or CMS content rendered inside around_render
  • CSP-disabled preview routes
  • applications that expose admin-only pages containing affected components

Remediation

Apply the same HTML-safety enforcement to around_render return values that is applied to normal inline #call output.

Possible approaches:

  1. Wrap the result of around_render with __vc_maybe_escape_html when the current template is HTML.
  2. Require around_render to return an ActiveSupport::SafeBuffer to opt into raw HTML.
  3. In collection rendering, avoid blindly calling .html_safe on joined component outputs unless each item has been normalized through the same safety boundary.

Executive ViewAI

Why It Matters

ViewComponent, a core Rails templating library trusted by thousands of applications, contains a cross-site scripting vulnerability affecting versions 4.0.0-4.11.x for which publicly available exploit code exists. Organizations using vulnerable versions face imminent risk of user session compromise, data theft, and regulatory exposure if customer information is affected. A security patch is available and deployable within standard update procedures.

Business Impact: High
Compensating Controls

Apply vendor patch.

Threat Intelligence Overview

EPSS Score
0.5%
Top 64% exploitable
Prevalence
Medium
popular Rails view gem, common but not in every deployment
Threat Intel
1
1 source
Exploit
POC
Public exploit code exists
Social Media
1
Sightings
Data Quality
6 sources
Confidence: High

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity HIGH
CISA KEV No
Public POC Yes
EPSS 0.5%
Patch available Yes
Active threat No
Deciding rule
HIGH severity (CVSS 7.0-8.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
Poc
System Exposure· derived
Open
Automatable· derived
No
Human Impact
High

Priority Score

64
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +44
PoC: +20
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Cross-Site Request Forgery exploits the automatic credential inclusion behavior of web browsers.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy