Page MenuHomePhabricator

Allow the Wikidata Query Builder to be embedded in an iframe
Open, Needs TriagePublic

Description

At Wikimédia France, we are working on a second MOOC about Wikidata, this new one dedicated to SPARQL queries. We would like to embed the Query Builder in an iframe, so learners will not have to go back and forth the training website and the Query Builder.

At the moment, the Wikidata Query Builder returns an HTTP header x-frame-options with the value SAMEORIGIN. This prevents the page to be embedded in an iframe if the page with the iframe is not on wikidata.org. This header should be removed so other websites could embed the Query Builder.

Sample web page that should work:

<html>
  <head>
  </head>
  <body>
    <iframe src="https://query.wikidata.org/querybuilder/" width="800" height="600"></iframe>
  </body>
</html>

Note that this is only about the Query Builder. The main page of the Wikidata Query Service does not have this limitation and can already be embedded in an iframe.

Event Timeline

Triage Notes:

  • I @ItamarWMDE or other engineers in the team will try and asses the security risks involved with enabling this feature before we proceed

Unfortunately, it seems like we cannot do this as these headers were requested by the WMF security team it seems. In addition, this might expose us to some forms of clickjacking attacks, where other embedding sites will be able to steal some information from the embedded page.

If we were able to limit the iframe to the domain of the mooc we might have had grounds to consider this. However, there is no longer an option to have an allow list of embedding origins, as this is deprecated from modern browsers.

We might be able to try and set a Content-Security-Policy header with a frame-ancestors directive set to the domain of the MOOC. But I would still defer to advice from the WMF Security Team (tagging @sbassett here since they are the only contact I have in the team so far)

Unfortunately, it seems like we cannot do this as these headers were requested by the WMF security team it seems. In addition, this might expose us to some forms of clickjacking attacks, where other embedding sites will be able to steal some information from the embedded page.

This is all correct, and why we'd discourage a revert of the status quo or, at the very least, likely rate it as at least a medium risk.

We might be able to try and set a Content-Security-Policy header with a frame-ancestors directive set to the domain of the MOOC. But I would still defer to advice from the WMF Security Team (tagging @sbassett here since they are the only contact I have in the team so far)

This is likely feasible, if it doesn't interfere with any potential X-Frame-Options: deny|sameorigin headers, and if the source list is kept to a minimum of absolutely necessary URLs that the Security-Team could review and assign any potential risk ratings.

That being said, the query builder is just static files. It could potentially just run on their page natively, maybe needs a few changes and a bit of documentation from us. Or am I missing some fundamental consideration?

That being said, the query builder is just static files. It could potentially just run on their page natively, maybe needs a few changes and a bit of documentation from us. Or am I missing some fundamental consideration?

Static files... which include a hefty amount of client-side JS, no? That's the security concern. If it can be bundled and deployed from just about anywhere, setting up a demo site on wmcs, etc. would likely be fine. As long as there was no confusion for users that it was, indeed, a demo site.

This is likely feasible, if it doesn't interfere with any potential X-Frame-Options: deny|sameorigin headers, and if the source list is kept to a minimum of absolutely necessary URLs that the Security-Team could review and assign any potential risk ratings.

Thank you, this sounds promising, I'll dig deeper into it. I suppose we will be talking about exactly one URL from WMFR, is that correct @Lydia_Pintscher?

UPDATE: The second part of this Stack overflow response seems to suggest that this might be possible (where CSP is used and XFO will only be the fallback). I didn't proof this myself yet, however, and I'm not sure if I'll have time to get around to it soon.

Thank you, this sounds promising, I'll dig deeper into it. I suppose we will be talkin about exactly one URL from WMFR, is that correct @Lydia_Pintscher?

I believe so. @Envlh, can you confirm?

I'm not sure there will be exactly one URL, but there should be only one subdomain (formations.wikimedia.fr). I'm awaiting confirmation from @mickeybarber.

Yes only this subdomain formations.wikimedia.fr.

Have you been able to advance on the subject @Lydia_Pintscher?