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

Disallow any domain from embeding a page to prevent clickjacking #322

Merged
merged 1 commit into from Oct 5, 2023

Conversation

AgaDufrat
Copy link
Contributor

@AgaDufrat AgaDufrat commented Oct 4, 2023

Context

Other sites could iframe GOV.UK into theirs and potentially use CSS/JS clickjacking to capture keystrokes etc. It was not done before because in 2020 there were a couple of instances where non-origin framing was a valid use case (e.g. we used to a side-by-side browser for sites transitioning content to GOV.UK so the departments could see where their pages will redirect to)

In 2023, the side-by-side browser is now retired, and we now have the GOV.UK Account in place and a potential move towards personalisation, so the likelihood of an attacker attempting to steal GOV.UK credentials is growing.

Trello card

Changes proposed

Disallow any domain from embeding a page to prevent clickjacking with the HTTP Content-Security-Policy frame-ancestors. Decided to use frame-ancestors directive rather than X-Frame-Options HTTP response header as they have more drawbacks the main one being the fact that they are now deprecated.

Considerations

We also have some different options for X-Frame-Options set in the apps. They will take priority so this PR is safe to merge and release the gem. There will be follow up work to look into these.

List of individual directives

Signon: SAMEORIGIN
Collections: ALLOWALL
Frontend: ALLOWALL in application config, DENY in content_item controller
Finder Frontend: ALLOWALL
Authenticating proxy: Deletes X-Frame-Options headers
Content tagger: has an iframing allowing proxy
Asset manager: DENY, nginx config in govuk-helm-charts
govuk_publishing_components (Components guide): ALLOWALL
datagovuk_find: DENY
datagovuk_publish: SAMEORIGIN

Other sites could iframe GOV.UK into theirs and potentially use CSS/JS
clickjacking to capture keystrokes etc.  It was not done before because in 2020
there were a couple of instances where non-origin framing was a valid use case
(e.g. we used to a side-by-side browser for sites transitioning content to
GOV.UK so the departments could see where their pages will redirect to)

In 2023, the side-by-side browser
(https://docs.publishing.service.gov.uk/repos/side-by-side-browser.html) is now
retired, and we now have the GOV.UK Account in place and a potential move
towards personalisation, so the likelihood of an attacker attempting to steal
GOV.UK credentials is growing.

Decided to use `frame-ancestors` directive rather than `X-Frame-Options` HTTP
response header as they have more drawbacks the main one being the fact that
they are now deprecated.
@AgaDufrat AgaDufrat merged commit 6438507 into main Oct 5, 2023
5 checks passed
@AgaDufrat AgaDufrat deleted the add-frame-ancestors-csp branch October 5, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants