Enforce CSRF protection in admin area (CVE-2024-7106) - #1441
Open
ringe wants to merge 2 commits into
Open
Conversation
The admin controllers inherit from ActionController::Base but never declared `protect_from_forgery`, unlike the frontend ApplicationController. In host apps that don't enable `default_protect_from_forgery` (e.g. apps that don't load recent Rails defaults), the entire /admin namespace — including /admin/media_folders — accepted cross-site state-changing requests, the CSRF issue reported as GHSA-wqw3-p83g-r24v / CVE-2024-7106. Declare `protect_from_forgery with: :exception` on AdminController so the admin area is self-protecting regardless of host configuration, mirroring Spina::ApplicationController. Add a regression test asserting forged (token-less) requests to an admin endpoint are rejected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bramjetten
approved these changes
Jun 16, 2026
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.
The admin controllers inherit from ActionController::Base but never declared
protect_from_forgery, unlike the frontend ApplicationController. In host apps that don't enabledefault_protect_from_forgery(e.g. apps that don't load recent Rails defaults), the entire /admin namespace — including /admin/media_folders — accepted cross-site state-changing requests, the CSRF issue reported as GHSA-wqw3-p83g-r24v / CVE-2024-7106.Declare
protect_from_forgery with: :exceptionon AdminController so the admin area is self-protecting regardless of host configuration, mirroring Spina::ApplicationController. Add a regression test asserting forged (token-less) requests to an admin endpoint are rejected.Fixes CVE-2024-7106 / GHSA-wqw3-p83g-r24v
Context
Spina CMS is affected by CVE-2024-7106 / GHSA-wqw3-p83g-r24v — a Cross-Site Request Forgery vulnerability in the admin area (reported against /admin/media_folders, medium severity, CWE-352).
Root cause: every admin controller inherits from Spina::Admin::AdminController < ActionController::Base, but that base controller never declared protect_from_forgery. The frontend Spina::ApplicationController does declare it explicitly — the admin side was relying implicitly on the host application's config.action_controller.default_protect_from_forgery (enabled by config.load_defaults).
Because Spina is a mountable engine dropped into arbitrary host apps, any host that doesn't load recent Rails defaults — or that sets default_protect_from_forgery = false — leaves the entire /admin namespace accepting cross-site, state-changing requests (create/update/destroy media folders, and every other admin action). The engine should not depend on host configuration for a security control it can guarantee itself.
Changes proposed in this pull request
Guidance to review