CVE-2026-44836 - view_component: Preview Route Can Dispatch Inherited Helper Methods
CVE-2026-44836 - view_component: Preview Route Can Dispatch Inherited Helper Methods
GHSA-7f3r-gwc9-2995 MEDIUM rubygems/view_component
CVE: CVE-2026-44836
Summary
The preview route derives an example name from the URL and calls it with public_send. The code does not verify that the requested method is one of the preview examples explicitly defined by the preview class.
As a result, inherited public methods on ViewComponent::Preview are route-reachable. The most important one is render_with_template, which accepts template: and locals:. Those values can come from request params and are later passed to Rails as render template:.
If previews are exposed, an attacker can render internal Rails templates that are not otherwise routable.
Severity: High if preview routes are externally reachable; Medium otherwise.
Affected files:
lib/view_component/preview.rbapp/controllers/concerns/view_component/preview_actions.rbapp/views/view_components/preview.html.erb
Relevant Code
app/controllers/concerns/view_component/preview_actions.rb:
@example_name = File.basename(params[:path])
@render_args = @preview.render_args(@example_name, params: params.permit!)lib/view_component/preview.rb:
example_params_names = instance_method(example).parameters.map(&:last)
provided_params = params.slice(*example_params_names).to_h.symbolize_keys
result = provided_params.empty? ? new.public_send(example) : new.public_send(example, **provided_params)app/views/view_components/preview.html.erb:
<%= render template: @render_args[:template], locals: @render_args[:locals] || {} %>The UI only lists direct preview methods via:
public_instance_methods(false).map(&:to_s).sortBut render_args does not enforce that list before dispatching.
Exploit Flow
Example request:
GET /rails/view_components/my_component/render_with_template?template=internal/secret&locals[poc_local]=attacker-controlled-local&request_marker=attacker-controlled-requestFlow:
1. my_component resolves to a valid preview.
2. File.basename(params[:path]) returns `rend
📌 来源: GitHub-Advisory | 🆔 CVE-2026-44836 | 📅 2026-05-08