Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 Jun 2015 at 17:15 UTC
Updated:
12 Jul 2016 at 04:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedComment #2
pwolanin commentedComment #3
fabianx commentedRTBC, we will need a change-record detailing how a contributed module / site builder can use iframes, e.g. how to extend this header.
Adding the information that they can implement their own Response subscriber and pointing to FinishResponseSubscriber should be enough as there are a variety of docs available.
Comment #4
pwolanin commentedComment #5
fabianx commentedCR created: https://www.drupal.org/node/2514152
Comment #6
pwolanin commentednote that this header is rather standard now:
Comment #7
pwolanin commentedIt seems the fully capitalized value is the more standard one, so let's use that.
Comment #8
fabianx commentedYes, looks great. Back to RTBC.
Comment #9
pwolanin commentedComment #10
tim.plunkettComment #11
wim leersThis also documents X-Frame-Options, which is why we don't need to update the docs at all :)
RTBC+1
Comment #12
webchickHm. Is it possible to write a test that actually attempts to embed the Drupal site in an iframe and verify the iframe is empty? That's what we actually want to test, IMO, not just that a header is output.
Comment #13
fabianx commentedThat is unfortunately not possible as we need a real browser for that, that supports that header.
However it is possible to manually test this on simplytest.me:
')
Result:
Dance a happy dance!
Comment #14
webchickOk, cool, had to ask. :)
Given that this is "merely" outputting a new header, doesn't seem too invasive, so since it's a security improvement I think this is fine to go in. I was a bit worried about what some services like e.g. HootSuite/ow.ly would do but I see that they've changed their behaviour to stop embedding crap in an iframe (thank goodness).
Committed and pushed to 8.0.x. Thanks!
Comment #16
David_Rothstein commentedWondering if this could be backported in some form or another? Seems at least worth discussing.
Comment #17
pwolanin commentedYes, i think we could default on for new installs? Maybe set a variable for existing installs?
Comment #18
pwolanin commentedHere's a trivial patch for D7. Doesn't address whether we want to disable for existing sites, or simply add release notes about how to disable.
Comment #19
gregglesMy suggestion is to enable it by default and provide release notes about how to disable it. It would break a few sites, but being secure by default seems worth it. We could write a specific book page for "Drupal site not loading in iframe" to explain the variable (I'll do that if it's a blocker to committing this as a default).
On the D8 version of the patch, it seems ideal to have a comment for the motivation (like in the D7 patch). As it stands this line is lumped together with something about mime and xss...which is not related. It also seems ideal to explain how to override this - moreso than other options this seems like something that people will want to override.
Comment #20
fabianx commentedRTBC per #19
Comment #21
David_Rothstein commentedSecurity wins out here, I think. Let's try it and see what happens :)
However I don't understand why we would only do this if Content-Type isn't set yet... Here's a new version that moves it outside of that if() statement. (Haven't checked if that's relevant for Drupal 8 since the code is so different.) Not sure if we want tests here too, maybe not if we expect some sites to override this in settings.php.
I have a revision to https://www.drupal.org/node/2514152 written up locally to make it apply to Drupal 7 also, which I can add once this is committed.
Will someone be able to update https://www.drupal.org/node/1863034 to reflect the changes from this issue? Based on the comment from @greggles above we should probably also have a followup issue to improve the Drupal 8 documentation...
Comment #22
gregglesI can edit https://www.drupal.org/node/1863034 once this is committed :)
Comment #23
David_Rothstein commentedSo I realized the patches above all have a problem when combined with the Security Kit module, since they clobber whatever setting it had. This could be especially bad if you're using that module to have a more restrictive setting (i.e., "Deny").
Here's a version that works better, although still breaks the ability to turn off X-Frame-Options entirely via the Security Kit admin UI (since when you set it to "Disabled", Security Kit just doesn't set the header at all, and thus the core code added here still runs). Ideally we would find a way to fix that.
Comment #24
David_Rothstein commentedFor reference and so I don't lose it, here's the rewrite I was going to do to https://www.drupal.org/node/2514152. But right now this is written assuming the above issue is fixed (i.e., that Security Kit can always be used to override).
Comment #25
pwolanin commentedSounds like seckit can always override by setting the core variable to an empty value?
Comment #26
fabianx commentedI agree with #25, security kit can in addition set the core variable when its disabled via $conf directly.
Comment #27
luksakCould someone point me in the right direction on how to remove this header in D8? The change record doesn't explain where the code in the example should go.
Comment #28
luksakI solved my issue. I had to set the X-Frame-Options header to allow embedding on a certain URL. Below is an example EventSubscriber that does that in case someone else needs it. Maybe this could be added in the change record?
Comment #30
pwolanin commentedAny update here on 7.x?
Comment #31
David_Rothstein commentedI went ahead and created an issue for the Security Kit module now (with a patch).
Given that it was just created now, we should wait a bit more to get this into core. Especially because it's a potentially disruptive change, waiting one more release is a good idea anyway if we wind up doing #2598382: [policy] Adopt a 6-month feature release schedule for Drupal 7 (similar to Drupal 8) and use pseudo-semantic versioning since a change like this one is a perfect fit for that type of release (which would be on April 20).
Comment #32
David_Rothstein commentedCommitted to 7.x - thanks!
The release that includes this will probably be labeled Drupal 7.50 to indicate it contains some big changes (including this issue).
Comment #35
jaydee1818 commentedSo we render our help site as an iframe in our web application. This change has prevented it from working as per usual. Can you please just clarify what I need to add to allow the site to be displayed in an iframe? Is it a configuration in setting.php?
Comment #36
jaydee1818 commentedok sorry, I found the answer to my own question:
$conf['x_frame_options'] = '';Comment #37
David_Rothstein commentedThat will result in allowing the site to be embedded as an iframe in any other site. If you want to limit it to a particular site (which is better for security) you could use the ALLOW-FROM option for the header instead (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options).
Probably the easiest way to do that is using the Security Kit module, since it provides an administrative interface for setting this header.
I'll edit the change record at https://www.drupal.org/node/2735873 now to add a pointer to the above resources.