Skip to content

Commit

Permalink
Allow gov.uk domains to embed pages
Browse files Browse the repository at this point in the history
We initially added the strict and OWASP recommended 'none' directive based on
the assumption that only side-by-side-browser tool (retired in November 2022)
was preventing us from implementing it.

However some other internal GOV.UK apps use iframes:
- Search Admin
    - Best bets (queries)
    - External links (recommended-links)
- Content Publisher (Preview feature)

This policy will still ensure sufficient security yet will allow internal
GOV.UK domains to embed pages.  It's added to the global base policy because
given the number of frontend application it may be difficult to predict which
frontend app renders the page that we want to iframe. It will reduce the need
to apply a CSP modification in individual apps.
  • Loading branch information
AgaDufrat committed Oct 9, 2023
1 parent a4764a3 commit ba97b9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/govuk_app_config/govuk_content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ 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
# Disallow non-gov.uk domains 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.frame_ancestors :self, *GOVUK_DOMAINS

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

0 comments on commit ba97b9d

Please sign in to comment.