Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer issue: "Blocked a frame with origin <hostname> from accessing a cross-origin frame." #6560

Closed
ryan953 opened this issue Dec 15, 2022 · 31 comments · Fixed by getsentry/rrweb#201
Assignees
Labels
Package: replay Issues related to the Sentry Replay SDK Type: Bug

Comments

@ryan953
Copy link
Member

ryan953 commented Dec 15, 2022

Private ticket with customer info: https://getsentry.atlassian.net/browse/FEEDBACK-1689

The customer is getting this "Blocked a frame with origin from accessing a cross-origin frame" error which is preventing any replay from being captured.

@m-nathani
Copy link

The same issue is happening on my side as well

@Lms24
Copy link
Member

Lms24 commented Jan 4, 2023

I tried to reproduce this by adding an iframe to a small plain-JS test app of mine. I pointed it to various 3rd party websites and noticed that these "Blocked a frame" and a few other CSP errors only occur on some websites. So my guess is that this might be rather specific to certain websites that perhaps somehow test if they're used in an iframe?

@m-nathani could you elaborate a little on what's happening for you? For instance how you're using iFrames and how the error message looks for you. Also, does this error crash replays for you, too? Or is it just an error that's being logged to your console?

@Lms24
Copy link
Member

Lms24 commented Jan 4, 2023

@m-nathani I'm realizing, you already told me about your setup here, right? So I'm wondering if this is only an issue in situations where replay is used inside an iframe and not the base site.

@m-nathani
Copy link

m-nathani commented Jan 5, 2023

@m-nathani I'm realizing, you already told me about your setup here, right? So I'm wondering if this is only an issue in situations where replay is used inside an iframe and not the base site.

@Lms24 it appears that the error i faced on the websites does not use replay inside an iframe.

This is exact error i faced using 7.28.1:
https://sentry.io/organizations/umai/issues/3808100150/?project=5264087&referrer=slack

Failed to read the 'contentDocument' property from 'HTMLIFrameElement':
 Blocked a frame with origin "https://letsumai.com" from accessing a cross-origin frame.

This is the site address which cause this error. Furthermore, you can check in the chrome dev tools Elements tab that the only iframe used in it for stripejs which we are using internally for payments.

Addiotnally, for the issue mentioned here, would appreciate if can help me resolve, as i am still facing it 🙏🏼

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@m-nathani
Copy link

The issue still happens, check here for details: https://sentry.io/organizations/umai/issues/3808100150/?project=5264087&referrer=slack

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2023

I'm not sure if I'm missing some crucial information here but according to your description in #6542, your app is a modal that is embedded in your clients' websites. As we saw in #6542, the Replay integration interacts with your host website as it's accessing the base website's hub. So in this case, I can imagine that the browser detects a coss-origin frame access which could explain the error.

Something else I came across while checking your last linked error: There appear to be two script origins (https://letsumai.com vs widget.letsumai.com). Any chance that this is in fact responsible for the cross-origin access?

@m-nathani
Copy link

Yeah its possible for embedded clients website's hub conflicting with ours. However as discussed #6542, we can't do anything about it yet...

Thanks for highlighting for (https://letsumai.com vs widget.letsumai.com), i need to check on it. However, it's working for most of embedded sites, so need to dig more if these could be a issue.

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2023

Also, as mentioned in #6542 (I know, you know this already, but just for transparency), I want to mention that Replay currently (and in the forseeable future) doesn't support partially recording a web site or similar multi-hub/origin scenarios. I'm afraid, there's nothing we can do here at this time.

cc @bruno-garcia I suggest we close this issue for the time being and re-open, if we get more cross-origin iframe error reports. wdyt?

@jirizavadil
Copy link

Hi @Lms24, i'm getting these:

when using firebase/auth
Blocked a frame with origin "https://tralala.la" from accessing a frame with origin "https://tralala-project.firebaseapp.com". Protocols, domains, and ports must match.
&
when using @stripe/stripe-js
Blocked a frame with origin "https://tralala.la" from accessing a frame with origin "https://js.stripe.com". Protocols, domains, and ports must match.

Both inject an iframe inside body. When i remove Sentry.Replay() from integrations in Sentry.init(), both disappear.

I'd be more than happy if i could just tell Replay to ignore these frames/origins, as i don't care what happens inside, because it wouldn't be rendered anywhere anyway.

Ideas?

@pfdzm
Copy link

pfdzm commented Feb 20, 2023

Hi @Lms24, i'm getting these:

when using firebase/auth Blocked a frame with origin "https://tralala.la" from accessing a frame with origin "https://tralala-project.firebaseapp.com". Protocols, domains, and ports must match. & when using @stripe/stripe-js Blocked a frame with origin "https://tralala.la" from accessing a frame with origin "https://js.stripe.com". Protocols, domains, and ports must match.

Both inject an iframe inside body. When i remove Sentry.Replay() from integrations in Sentry.init(), both disappear.

I'd be more than happy if i could just tell Replay to ignore these frames/origins, as i don't care what happens inside, because it wouldn't be rendered anywhere anyway.

Ideas?

We have a similar issue in our setup, Replay seems to want to peek into any other frame embedded in our page - would it be possible to whitelist only specific frames/origins for Replay to hook into?

@billyvg
Copy link
Member

billyvg commented Feb 23, 2023

@jirizavadil @pfdzm You should be able to use block with a selector that targets the iframes in question. Alternatively you can add data-sentry-block attribute to the iframe.

@jirizavadil
Copy link

@billyvg Sentry.replay({block: 'iframe'}) did the trick. For some reason this wasn't clear to me from the docs wording and was looking for something like 'ignore'.
Thanks!

@billyvg
Copy link
Member

billyvg commented Feb 23, 2023

@jirizavadil Glad to hear -- I'm assuming that snippet is a typo? block should be an array.

@jirizavadil
Copy link

@billyvg well... 😅 yeah, let's call it a late night typo. But it ain't stupid if it works, right? 😂

@mydea
Copy link
Member

mydea commented Feb 27, 2023

Maybe we should by default block all iframe, and allow users to opt-in into capturing (first-party) iframes. As currently the experience is not ideal with iframes... maybe a captureFirstPartyIframes option or something along these lines?

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2023
@JarnoLeConte
Copy link

It's a problem with the Replay package and Safari web browser. Safari is blocking the replay's actions on iframes. When I enable the Replay integration, the following errors appear on my site:

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://consentcdn.cookiebot.com". Protocols, domains, and ports must match.

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://googleads.g.doubleclick.net". Protocols, domains, and ports must match.

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://auth.shimejis.xyz". Protocols, domains, and ports must match.

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://tpc.googlesyndication.com". Protocols, domains, and ports must match.

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://www.google.com". Protocols, domains, and ports must match.

[Error] Blocked a frame with origin "https://shimejis.xyz" from accessing a frame with origin "https://googleads.g.doubleclick.net". Protocols, domains, and ports must match.

I do not control these dynamically created iframes and are not able to mark them with a data-sentry-block attribute. Also adding the selector iframe and [src] to the Replay configuration does not make any difference.

Sentry.init({
      dsn: 'XXX',
      replaysSessionSampleRate: 0.001,
      replaysOnErrorSampleRate: 1.0,
      integrations: [
        new Sentry.Replay({
          maskAllText: true,
          blockAllMedia: true,
          block: ["iframe", '[src]'],
        }),
      ],
    });

These errors are not logged in Google Chrome.

I hope this issue will be fixed, because I don't want to make use of a package that is logging errors.

@bourquep
Copy link

@billyvg Sentry.replay({block: 'iframe'}) did the trick. For some reason this wasn't clear to me from the docs wording and was looking for something like 'ignore'.
Thanks!

This does not work for me, unfortunately.

@mydea
Copy link
Member

mydea commented Aug 31, 2023

@billyvg Sentry.replay({block: 'iframe'}) did the trick. For some reason this wasn't clear to me from the docs wording and was looking for something like 'ignore'.
Thanks!

This does not work for me, unfortunately.

Could you open a new issue with details on your setup & what is not working?

@bourquep
Copy link

I am not 100% sure my bug is with Sentry, but I'll open a new issue if I ever confirm.

@Talb2005
Copy link

I'm also getting this error in my Angular app.
This error occurs only on Safari and only when Sentry replayIntegration is enabled.
Blocked a frame with origin <hostname> from accessing a frame with origin "https://www.googletagmanager.com". Protocols, domains, and ports must match.
Adding block: ['iframe'] to the ReplayConfiguration doesn't make any difference.

@Talb2005
Copy link

Ok I now managed to solve it.
Instead of block: ['iframe'] I used the iframe id as the selector block: ['#GTMiframe'] and now the error is gone. :)

@jakst
Copy link

jakst commented Feb 19, 2024

I'm seeing these errors with Sentry replayIntegration together with Stripe. I have had no success with block: ['iframe'] or targeting any of the HTML attributes of the iframes. The iframes that Stripe generates have no stable identifiers, so I can't use an ID or class. I tried more involved targeting like [src*="stripe.com"], but to no avail.

Anyone had any luck with getting rid of these errors with Stripe? This is a Safari only issue like others in the thread have mentioned.

Blocked a frame with origin "https://our.domain.com" from accessing a frame with origin "https://js.stripe.com". Protocols, domains, and ports must match.

@HofmannZ
Copy link

HofmannZ commented Apr 8, 2024

@billyvg & @mydea - I'm confused about why this issue was closed. We have Firebase and Stripe generating iframes on our page, which we can't block. At the moment, there doesn't seem to be a viable solution for Safari.

@mydea mydea reopened this Apr 9, 2024
@mydea
Copy link
Member

mydea commented Apr 9, 2024

I guess this flew under the radar because it was already closed - in the future, please just open a new issue in such cases, if you are still experiencing an issue for something that was previously closed, then it is easier for us to keep track of this!

We'll need to look more into this, we're quite busy at the moment but will hopefully have some more time on our hands to investigate this further soon!

@jakst
Copy link

jakst commented Jun 12, 2024

I found a workaround, that is not optimal, but at least works for our use case where the iframes are only present on some pages.

What I do here is block the whole body element whenever there's an iframe on the page with a name containing the value Stripe.

block: ['body:has(iframe[name*="Stripe"])']

This works for us, since Stripe is only mounted on the payments page. That means we got no replays on the payments page. But for iframes that need to be mounted on every page this workaround will not work, unfortunately.

@mydea
Copy link
Member

mydea commented Jun 14, 2024

I think @billyvg identified the problem and has a possible fix for it in the works! 🎉

billyvg added a commit to getsentry/rrweb that referenced this issue Jun 14, 2024
…ontentDocument` (#201)

Do not attempt to access `contentDocument` of iframe if element is
blocked, otherwise it will trigger a browser warning. e.g.

`Blocked a frame with origin "<foo>" from accessing a frame with origin
"<bar>". Protocols, domains, and ports must match.`

Fixes getsentry/sentry-javascript#6560
@jakst
Copy link

jakst commented Jun 17, 2024

@mydea @billyvg how do I follow the release status of rrweb#201? I can't figure out how the rrweb repo relates to the sentry-javascript repo

@mydea
Copy link
Member

mydea commented Jun 17, 2024

It will be part of the release notes of sentry-javascript, and hopefully in the next/an upcoming release!

@jakst
Copy link

jakst commented Aug 2, 2024

I tried out the latest release (8.22.0) with our app, but the issue isn't fixed for us. I created a new issue with a minimal reproduction, since this issue was closed. #13173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: replay Issues related to the Sentry Replay SDK Type: Bug
Projects
Archived in project