Closed
Description
Consider the following Rails controller action which overwrites the frame ancestors based on some user input:
def show
user_input_domain1 = URI.parse "https://google.com;script-src"
user_input_domain2 = URI.parse "https://*;.;"
user_input_domains = [user_input_domain1, user_input_domain2]
override_content_security_policy_directives(frame_ancestors: whitelisted_domains)
end
This results into the following response header:
frame-ancestors: https://google.com;script-src *;
This shows unexpected output, because by setting the frame ancestors the user is able to change the script-src
opening possibilities for XSS.
One solution to this would be to filter out the CSP rules inside of specific CSP rules:
frame_ancestor = value.gsub('script-src','').gsub('img-src', '')
Metadata
Metadata
Assignees
Labels
No labels