Skip to content

Commit

Permalink
Merge pull request #322 from alphagov/add-frame-ancestors-csp
Browse files Browse the repository at this point in the history
Disallow any domain from embeding a page to prevent clickjacking
  • Loading branch information
AgaDufrat authored Oct 5, 2023
2 parents 4db5992 + e845ded commit 6438507
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/govuk_app_config/govuk_content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def self.build_policy(policy)
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src
policy.frame_src :self, *GOVUK_DOMAINS, "www.youtube.com", "www.youtube-nocookie.com" # Allow youtube embeds

# Disallow any domain from embeding a page using <frame>, <iframe>, <object>, or <embed> to prevent clickjacking
#
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
policy.frame_ancestors :none

policy.report_uri ENV["GOVUK_CSP_REPORT_URI"] if ENV.include?("GOVUK_CSP_REPORT_URI")
end

Expand Down

0 comments on commit 6438507

Please sign in to comment.