First load on embedded comments fail on WebKit

AI-generated summary

A bug on WebKit and its derivatives causes the first load of embedded Discourse comments to fail. This occurs due to a JavaScript reload changing the referer to the current IFRAME location, resulting in an error as the forum’s FQDN is not allowed to embed comments. Falco proposes a workaround to always allow the forum’s own FQDN in the list of allowed referrers. codinghorror considers this fix to be safe. The issue has been fixed by Falco.

The first time an article with embedded Discourse comments is loaded we load the IFRAME with the following request:

GET https://forum.example.com/embed/comments?embed_url=https://site.example.com/article
referer: https://site.example.com/article

This will serve a page with

  (function() {
    setTimeout(function() {
      document.location.reload();
    }, 30000);
  })();

So Jobs::RetrieveTopic have time to download the page, create the topic and work it’s magic.

30 seconds after the IFRAME reloads, and if we have a topic it works, and if we don’t it will try again in 30 seconds, just fine.

However, on Webkit and derivatives, thanks to this bug the Javascript reload will change the referer to the current location of the IFRAME:

GET https://forum.example.com/embed/comments?embed_url=https://site.example.com/article
referer: https://forum.example.com/embed/comments?embed_url=https://site.example.com/article

This will result in an error, because forum.example.com is not allowed to embed comments.

My proposal to work around this bug is to always allow the forum own FQDN in the list of allowed referrers. Is it a good fix?

1개의 좋아요

That seems plenty safe to me…

1개의 좋아요

Fixed in

https://github.com/discourse/discourse/pull/5018

3개의 좋아요