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

Add a guideline on framing protection #17

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

wbamberg
Copy link
Collaborator

Fixes #15.

@wbamberg wbamberg changed the title Add guideline on framing protection Add a guideline on framing protection Mar 22, 2025

If you don't need your site to be embeddable in other sites, or if you need only certain specific sites to embed your site, implement framing protection using the [`frame-ancestors`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors) CSP directive and the [`X-Frame-Options`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options) HTTP response header.

The `frame-ancestors` directive offers more fine-grained control, allowing you to list sites that are allowed to embed your site. However, `X-Frame-Options` has better support in older browsers. Since browsers that support `frame-ancestors` will ignore `X-Frame-Options`, it is best to include both methods.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, X-Frame-Options has better support in older browsers.

Technically it's just IE that does XFO but not f-a, should we make that more clear? (To send a clearer message that f-a is supposed to be deprecating XFO and is the much much more preferred solution)

f-a should be a part of the CSP2 spec that is very well supported on, well, almost everything that should be out there today!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just IE, it's older browsers of any variety.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've adjusted it to include IE, link to caniuse, and strengthened the wording from "older" to "obsolete".


If you don't need your site to be embeddable in other sites, or if you need only certain specific sites to embed your site, implement framing protection using the [`frame-ancestors`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors) CSP directive and the [`X-Frame-Options`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options) HTTP response header.

The `frame-ancestors` directive offers more fine-grained control, allowing you to list sites that are allowed to embed your site. However, `X-Frame-Options` has better support in older browsers. Since browsers that support `frame-ancestors` will ignore `X-Frame-Options`, it is best to include both methods.
Copy link

@ctcpip ctcpip Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `frame-ancestors` directive offers more fine-grained control, allowing you to list sites that are allowed to embed your site. However, `X-Frame-Options` has better support in older browsers. Since browsers that support `frame-ancestors` will ignore `X-Frame-Options`, it is best to include both methods.
The `frame-ancestors` directive offers more fine-grained control, allowing you to list sites that are allowed to embed your site. However, `X-Frame-Options` has better support in older browsers, so it is best to include both methods. Note that when both are provided, browsers which support `frame-ancestors` will prioritize `frame-ancestors` and ignore `X-Frame-Options`.

suggestion for clarity

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it's helpful to say "when both are included" here and I have done that. To me "prioritise" implies that the non-prioritised thing may still get attention (i.e. priorities are relative) so I have not used that particular wording.


Controlling whether your site can be embedded in another site using an [`<iframe>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) can help protect against [clickjacking](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/Clickjacking) and certain [cross-site leak attacks](https://xsleaks.dev/).

If you don't need your site to be embeddable in other sites, or if you need only certain specific sites to embed your site, implement framing protection using the [`frame-ancestors`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors) CSP directive and the [`X-Frame-Options`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options) HTTP response header.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, you would not want a production site to be embeddable elsewhere, especially unknown origins. I suggest the default recommendation would be to restrict, and provide guidance for if a user needs the site to be embeddable, and to set the configuration as narrow as possible to only exactly what they need, to minimize risk.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> 7e4c347

@torgo torgo merged commit 004adea into w3c-cg:main Mar 31, 2025
1 check was pending
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.

New guideline on framing protection?
4 participants