Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Security-Policy: :self isn't turned into 'self' when returned inside an array from a lambda #44536

Closed
asterite opened this issue Feb 23, 2022 · 2 comments · Fixed by #44578

Comments

@asterite
Copy link

Steps to reproduce

Sorry, I don't have a lot of time to create actual repro steps, but...

If you do something like this:

class ApplicationController < ActionController::Base
  content_security_policy do |policy|
    policy.frame_ancestors lambda { [:self, "https://example.com"] }
  end
end

Then the content-security-policy HTTP header will look like this:

content-security_policy: frame-ancestors self https://example.com

Note that it says self instead of 'self'.

This only happens when you return an array from that lambda. If you return :self it works fine. Also moving :self to outside the lambda (passed directly to frame_ancestors works as expected.

Expected behavior

content-security_policy: frame-ancestors 'self' https://example.com

Actual behavior

content-security_policy: frame-ancestors self https://example.com

System configuration

Rails version: 6.0.4.4 (but I see no diff between the relevant file and main)

Ruby version: 2.6.8

@asterite
Copy link
Author

asterite commented Mar 1, 2022

Thank you! 🥳

@byroot
Copy link
Member

byroot commented Mar 1, 2022

Welcome. Backported to 6-1-stable and 7-0-stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants