chore(deps): update dependency view_component to v4.9.0 [security]#7013
Open
renovate[bot] wants to merge 1 commit into
Open
chore(deps): update dependency view_component to v4.9.0 [security]#7013renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
4.8.0→4.9.0view_component: Preview Route Can Dispatch Inherited Helper Methods
CVE-2026-44836 / GHSA-7f3r-gwc9-2995
More information
Details
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::Previeware route-reachable. The most important one isrender_with_template, which acceptstemplate:andlocals:. Those values can come from request params and are later passed to Rails asrender 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.erbRelevant Code
app/controllers/concerns/view_component/preview_actions.rb:lib/view_component/preview.rb:app/views/view_components/preview.html.erb:The UI only lists direct preview methods via:
But
render_argsdoes not enforce that list before dispatching.Exploit Flow
Example request:
Flow:
my_componentresolves to a valid preview.File.basename(params[:path])returnsrender_with_template.render_argscalls inheritedViewComponent::Preview#render_with_template.template: "internal/secret"andlocals: {...}.internal/secretwith attacker-controlled locals.Impact depends on what internal templates render. In the worst case this can expose secrets, config, debug data, admin-only partials, or request/session-derived values.
PoC Test
This checkout already contains a PoC at:
test/sandbox/test/security_preview_template_poc_test.rbtest/sandbox/app/views/internal/secret.html.erbThe test proves that
/internal/secretis not directly routable, but can still be rendered through the preview endpoint by invoking inheritedrender_with_template.If reproducing manually, run:
bundle exec ruby -Itest test/sandbox/test/security_preview_template_poc_test.rbEquivalent standalone test:
Fixture template:
Suggested Fix
Only dispatch explicitly declared preview examples:
Add a regression test that
/rails/view_components/my_component/render_with_templatefails unlessrender_with_templateis explicitly defined as a preview example on that class.Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
view_component: System Test Entry Point Path Check Allows Sibling Directory Escape
CVE-2026-44837 / GHSA-hg3h-g7xc-f7vp
More information
Details
Summary
The system test entrypoint canonicalizes a user-controlled file path with
File.realpath, then checks whether the resolved path starts with the temp directory path. This is not a safe containment check because sibling directories can share the same string prefix.Severity: Medium; test-route scoped.
Example:
The outside path is not inside the base directory, but it passes:
@​path.start_with?(base_path)Relevant Code
app/controllers/view_components_system_test_controller.rb:The route then renders the resolved file:
Exploit Flow
Example request:
Flow:
base_pathresolves to.../tmp/view_components..../tmp/view_components_evil/secret.html.erb.The route is mounted only in
Rails.env.test?, which is why Medium is more appropriate than P1. The issue matters if test routes are reachable in shared CI, staging, review apps, or any accidentally exposed test-mode deployment.Targeted Fuzz Result
The following sibling paths passed an equivalent
realpathplusstart_with?harness while resolving outside the base directory:PoC Test
Create
test/sandbox/test/system_test_entrypoint_path_traversal_poc_test.rb:Run:
bundle exec ruby -Itest test/sandbox/test/system_test_entrypoint_path_traversal_poc_test.rbVulnerable behavior: the response succeeds and contains
VC_SYSTEM_TEST_TRAVERSAL_POC.Fixed behavior: the request raises
ViewComponent::SystemTestControllerNefariousPathErroror otherwise fails without rendering the file.Suggested Fix
Use path-aware containment instead of a raw string prefix. For example:
Or require a separator boundary:
Add regression tests for:
tmp/view_components../../README.md../view_components_evil/secret.html.erbSeverity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
viewcomponent/view_component (view_component)
v4.9.0: 4.9.0Compare Source
Fix path traversal vulnerability in
ViewComponentsSystemTestControllerwhere sibling directories sharing a string prefix with the allowed temp directory could bypass the path containment check. Thestart_with?check has been replaced with a separator-aware prefix check, and nefarious path errors now return a 404 instead of an unhandled exception.Joel Hawksley
Fix preview route vulnerability where inherited methods on
ViewComponent::Preview(such asrender_with_template) could be invoked via the preview URL, allowing arbitrary internal Rails templates to be rendered with attacker-controlled locals and request parameters.render_argsnow raisesAbstractController::ActionNotFoundfor any example not explicitly declared on the preview subclass.Joel Hawksley
Add
yard-lintto CI.Joel Hawksley
Configuration
📅 Schedule: (in timezone America/Los_Angeles)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.