Skip to content

Commit

Permalink
Pass values to CSP frame_ancestors as individual arguments (#1929)
Browse files Browse the repository at this point in the history
* Pass values to CSP frame_ancestors as individual arguments

Rails core has patched a CVE preventing passing a string
with whitespace as an argument.

rails/rails@3da2479

This patch passes the arguments individually instead
which achieves the same result whilst meeting the new
requirements.

* Reimplement frame_ancestors proc to fix tests

@sle-c has pointed out that the tests rely on the proc
and suggests reimplemeting the proc and returning an array.

This patch implements the recommendation and achieves the
same result.
  • Loading branch information
matoakley authored Dec 11, 2024
1 parent 7411e62 commit e8798eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/shopify_app/controller_concerns/frame_ancestors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ module FrameAncestors
content_security_policy do |policy|
policy.frame_ancestors(-> do
domain_host = current_shopify_domain || "*.#{::ShopifyApp.configuration.myshopify_domain}"
"#{ShopifyAPI::Context.host_scheme}://#{domain_host} https://admin.#{::ShopifyApp.configuration.unified_admin_domain}"
[
"#{ShopifyAPI::Context.host_scheme}://#{domain_host}",
"https://admin.#{::ShopifyApp.configuration.unified_admin_domain}",
]
end)
end
end
Expand Down

0 comments on commit e8798eb

Please sign in to comment.