Make WordPress Core

Opened 11 years ago

Closed 4 months ago

Last modified 4 months ago

#29429 closed enhancement (fixed)

Support frame-ancestors directive over X-Frame-Options

Reported by: danielbachhuber's profile danielbachhuber Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Security Keywords: dev-feedback has-patch 2nd-opinion
Focuses: Cc:

Description

According to MDN, X-Frame-Options is deprecated: https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

frame-ancestors should be used instead.

Previously #12293

Attachments (3)

29429.diff (450 bytes) - added by killerbishop 6 years ago.
Patch for 29429 - adds CSP frame-ancestors self policy
29429.patch (448 bytes) - added by callumbw95 5 months ago.
Updated patch with code from a previous PR
29429-headers-sent.diff (615 bytes) - added by josephscott 4 months ago.
frame-ancestors and headers_sent check

Download all attachments as: .zip

Change History (17)

#1 @nacin
11 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

We'd need to do at a minimum both to support older browsers.

#2 @nacin
11 years ago

  • Component changed from Administration to Security

#3 @chriscct7
10 years ago

  • Keywords needs-patch added

#5 @iandunn
7 years ago

  • Status changed from new to reopened

Re-opening because this still seems relevant.

#6 @SergeyBiryukov
7 years ago

  • Milestone set to Future Release

@killerbishop
6 years ago

Patch for 29429 - adds CSP frame-ancestors self policy

#7 @killerbishop
6 years ago

  • Keywords has-patch added; needs-patch removed

I looked for any other use of X-Frame-Options - but it only appears in two spots. The customize manager class already provides both headers. This is a change to the send_frame_options_header(). Testing in the WP admin shows both headers being issued, no change to behavior from what I can tell using the latest Chrome. The original header is being kept for continued security benefit in older browsers.

Here is my repo's pull request if needed:

https://github.com/killerbishop/wordpress-develop/pull/2

#8 @callumbw95
5 months ago

  • Keywords 2nd-opinion added

Hey Everyone,

I have just taken a look into this, and it looks like the previous PR can be added without any real issues. However to make it clearer I have put this change into a .patch file which I will attach shortly. I think this is a pretty low risk patch, and would definitely be a positive to get merged into core at some point in the coming milestones, but perhaps we need a second opinion here?

@callumbw95
5 months ago

Updated patch with code from a previous PR

This ticket was mentioned in PR #9561 on WordPress/wordpress-develop by @josephscott.


4 months ago
#9

https://core.trac.wordpress.org/ticket/29429

My original concern was the lack of a headers_sent() in the send_frame_options_header() function, but after having found 29429 I think it makes sense to do both at the same time.

@josephscott
4 months ago

frame-ancestors and headers_sent check

#10 @josephscott
4 months ago

My original concern regarding the send_frame_options_header() function was the lack of a headers_sent() check. But having found this ticket, and both changes being very small, I think it makes sense to do them both at the same time.

This ticket was mentioned in Slack in #core by josephscott. View the logs.


4 months ago

#12 in reply to: ↑ description @SergeyBiryukov
4 months ago

  • Owner set to SergeyBiryukov
  • Status changed from reopened to accepted

Replying to danielbachhuber:

According to MDN, X-Frame-Options is deprecated: https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

frame-ancestors should be used instead.

It appears that X-Frame-Options is no longer marked as deprecated as of January 2025:

That said, adding Content-Security-Policy: frame-ancestors still makes sense to me.

#13 @SergeyBiryukov
4 months ago

  • Milestone changed from Future Release to 6.9

#14 @SergeyBiryukov
4 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 60657:

Security: Set the frame-ancestors directive in send_frame_options_header().

The X-Frame-Options HTTP response header is a way of controlling whether and how a document may be loaded inside of a child navigable. For sites using Content-Security-Policy, the frame-ancestors directive provides more granular control over the same situations.

Includes adding a headers_sent() check before sending the headers.

References:

Follow-up to [17826].

Props danielbachhuber, killerbishop, callumbw95, josephscott, nacin, chriscct7, iandunn, SergeyBiryukov.
Fixes #29429.

This ticket was mentioned in Slack in #core-performance by josephscott. View the logs.


4 months ago

Note: See TracTickets for help on using tickets.