Problem/Motivation
This issue is spun off from the pile-on happening in #2965979: Validate alternate domain for oEmbed iFrame.
When the oEmbed system was added to the core Media module, one of the protections added against malicious JavaScript was the suggestion that site owners configure their Drupal site to be visible through a subdomain alias (basically, oembed.example.com == example.com) so that malicious JavaScript served from an oEmbed provider would have an additional hoop to jump through. We felt strongly enough about this measure that, if oEmbed content is not served in a subdomain, we display a warning on the status report page.
However, this is tricky to set up -- it's poorly documented and the warning drives site builders crazy (as evidenced by discussion in #2965979: Validate alternate domain for oEmbed iFrame) until they get it set up properly. And even when they do, it's not clear that there is actually a security improvement here.
- If a subdomain is used, browsers consider it to be part of the main site, so it can share cookies with the main domain.
- If a completely different domain is used instead of a subdomain, users can go directly to the second domain, which, because it is the same Drupal site, is configured to use itself as the iFrame domain.
The oEmbed specification recommends that the HTML within the iFrame be hosted on another domain. The intention is for the HTML within the iFrame to be entirely separate from the main site. It does not recommend using a subdomain, or that the entire site be accessible from the other domain.
Steps to reproduce
Install the Standard profile and the Media module, then visit the status report page.
Proposed resolution
Quick fix
Given that the full fix is complex and will take some time to develop, I [AdamPS] propose that ASAP we could remove the existing warning. It has likely wasted 1000s of hours of site builder and developer time trying to follow the instructions, which a low likelihood of actually providing anyone with any protection at all. It's so complex to do correctly and lacking in accurate full documentation that I doubt even 1% of those who try do it succeed; they might even introduce security bugs by doing it incorrectly.
Full fix
- In the iFrame domain only serve pages that should be used there. Block these pages in the main domain. If there is not an iFrame domain, use a data URL and sandbox attribute to minimize the possibility of cookies leaking into the iFrame.
- Automatically set same-origin policy so that the embedding actually works
- Don't allow the iFrame domain to be a sub-domain of the main domain OR find a way to set a cookie policy so that the sub-domain cannot share cookies with the main domain
- Treat the iFrame domain as trusted specifically for the pages that it should serve without needing to set it in the list of trusted hosts
- Provide a way to disable the warning given that the site is still reasonably secure without the extra domain and not everyone will want to purchase an extra domain.
- Provide detailed documentation for site builders.
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Comments
Comment #2
longwaveThe suggestion of an alternate domain is taken from the oEmbed spec: https://oembed.com/#section3
However I agree that this is a huge technical hurdle for most sites to implement.
Comment #3
darren ohPointing the alternate domain at the same site makes the security benefit questionable.
Comment #4
phenaproximaTagging this to be reviewed by a member of the security team. To be succinct, this is what we need to know...
First, are these points from the issue summary accurate? Because if they are, it would seem that it's pointless to have a warning on the status report asking site owners to set up a subdomain alias:
Second, should we implement one or both of the following mitigations? If we did, could we remove the warning from the status report?
Comment #5
larowlanFrom the oembed docs:
> When a consumer displays HTML (as with video embeds), there's a vector for XSS attacks from the provider
And then from the Cookie docs here
So in summary it depends on the cookie domain - can we check if the cookie domain is set, and if it is, then we need to show a different warning.
For image styles we have a 'disable secure image generation' settings.php thing. I guess we could do the same here
$settings['media.accept_insecure_iframe_domain'] to turn this off.
Comment #6
darren ohI'm not sure that every browser follows the Mozilla cookie policy when the domain attribute is omitted.
Comment #7
darren ohCorrected description of security concern to account for Mozilla cookie policy.
Comment #8
larowlanFor clarity, that's not the Mozilla cookie policy, its from MDN, which is a generic documentation site
Comment #9
larowlanSee https://tools.ietf.org/html/rfc6265#section-5.1.3 for the RFC about domain name matching
Comment #10
darren ohSection of RFC discussing what happens if domain attribute is omitted: https://tools.ietf.org/html/rfc6265#section-4.1.2.3
Comment #11
darren ohComment #13
fkelly12054@gmail.com commentedHow about for simple sites the ability to just turn off OEMBED? Or does that make using the media module pointless?
Comment #17
it-cruAs 3. point in proposed resolution also avoid display of duplicate content of your Drupal site is a very critical SEO related issue, when settings this up in a right way.
Comment #19
adamps commentedI've made two edits that I would appreciate comments/feedback on from the community:
1) I propose that ASAP we should remove the existing warning. It has likely wasted 1000s of hours of site builder and developer time trying to follow the instructions, which a very low likelihood of actually providing anyone with any protection at all. It's so complex to do correctly and so lacking in documentation that I doubt even 1% of those who try do it succeed; they might even introduce security bugs by doing it incorrectly.
2) I have expanded the proposed resolution to automatically take care of as many aspects of the solution as possible to give site builders the best possible chance of getting it working.
Comment #20
tunicFeedback on #19:
1) I fully agree removing the warning. I spent hours myself trying to solve that warning without luck.
2) Full fix description sounds reasonable sounds reasonable but I don't know all the nuances of cookie behavior so I can't have a strong opinion.
Comment #21
pameeela commentedDiscovered this issue while looking into this warning, which I have seen and ignored hundreds of times, in light of Starshot.
After reading through this and #2965979: Validate alternate domain for oEmbed iFrame I totally agree that the warning should be removed given that 1) it's extremely difficult to implement and 2) of dubious value. I understand that it's a recommendation but as it stands this feels like Drupal saying "This is a potential thing that you should maybe worry about, and we can't help you but we told you so now it's on you". In other words, very un-Drupal!
What do we need to do to get a decision on this?
Comment #22
longwaveDiscussed with @xjm at Drupalcon Barcelona. As this policy needs review, I'm marking this needs review - so far we haven't heard any opposing voices that want to keep this feature, but I will raise this with the rest of the security team and give them chance to comment here.
Comment #23
ivnishI propose that ASAP we should remove the existing warning too. +1
Comment #24
krakenbite commented+1 too. Please remove it
Comment #25
marcoscano+1 for removing. Folks that know how to fix it probably don't need the reminder.
Comment #26
mxr576The outcome of this issue could make the following one "closed, won't fix".
Comment #27
longwaveI discussed this issue with @mcdruid. Some notes from the discussion:
sandboxattribute, which WordPress apparently does: https://core.trac.wordpress.org/ticket/44400 - however this may break existing embeds in some cases so will require testing.We agreed that this could be broken into three issues:
sandboxattribute to the OEmbed iframeComment #28
pameeela commentedWas reminded of this today and decided to try to move it along. Updated #2962753: Remove oEmbed security warning to be about removing the warning as the first step in #27.
I think this policy issue can be fixed?
Comment #29
martijn de witMaybe we can convert this issue to a meta ticket holding all suggested child tickets?
Comment #30
pameeela commentedSince this is a policy issue, I think it should be marked fixed once the policy is agreed. It should be referenced in the follow up issues.
Comment #31
pameeela commentedCreated a follow up for the sandbox experimentation.
Comment #32
pameeela commentedComment #34
pameeela commentedCredited everyone who contributed to this issue (beyond just saying +1) and @lauriii for discussion in person in Singapore.
Comment #35
pameeela commentedComment #36
lauriiiComment #38
longwaveAdding credit for @mcdruid for discussing with me and raising some of the points mentioned in #27.
Comment #40
xjmAdding credit for myself as per #22. Remember to credit in-person discussions, folks. :)
Comment #41
quietone commentedChanging to latest version when this was closed.
Comment #42
quietone commented