-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[BUG] Potential Chrome CORS problem with local output #9773
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
Comments
Results of testing across browsers:
|
@hyles-lineata also reported on zulip that in the steps above, viewing with
Thoughts? |
FYI have re-published the 2.0.0 docs manually using the current master in order to mitigate this issue until a new release can be made (hopefully next week at latest) |
… generated by matplotlib, since there seems to be a bug with bokeh: bokeh/bokeh#9773.
Hi, Access to script at 'https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.0.1.min.js' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. This error started showing up as soon as I ran the slider example from the Bokeh guide: import numpy as np from bokeh.layouts import column, row x = np.linspace(0, 10, 500) source = ColumnDataSource(data=dict(x=x, y=y)) plot = figure(y_range=(-10, 10), plot_width=400, plot_height=400) plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6) amp_slider = Slider(start=0.1, end=10, value=1, step=.1, title="Amplitude") callback = CustomJS(args=dict(source=source, amp=amp_slider, freq=freq_slider, phase=phase_slider, offset=offset_slider), amp_slider.js_on_change('value', callback) layout = row( output_file("slider.html", title="slider.py example") show(layout) if I remove the sliders I don't see this issue in Chrome: import numpy as np from bokeh.layouts import column, row x = np.linspace(0, 10, 500) source = ColumnDataSource(data=dict(x=x, y=y)) plot = figure(y_range=(-10, 10), plot_width=400, plot_height=400) plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6) layout = row(plot) output_file("no_sliders.html", title="no_slider.py example") show(layout) I've been using Bokeh for a couple of weeks now. Thank you for the great work! |
@hmanuel1 This means at some point your browser has first loaded BokehJS resources from CDN without the SRI hashes specified, then later tried to load them with the hashes specified. I don't know where or how this happened for you. AFAIK all the docs have now been updated to always specify the hashes, but it's possible there might be something in the docs (or an example) that was missed and that generated output without the hashes that you then viewed. There's nothing for anyone to do except for you to force-reload the page (once). [1] Otherwise if you ever happed to notice a page that loads BokehJS >= 2.0.1 without specifying the [1] Many people think Chrome's SRI policy wrt cached scripts in this instance is bad/incorrect. Perhaps Chrome will change some day. |
That was it. I cleared Chrome cached browsing data and it's working now. Thank you! |
Same for me.. |
AFAIK there should not be anything on the docs site that is rendering without SRI hashes any longer, so it should not be possible to trigger this circumstance by first perusing the docs, then using Bokeh locally (which was an issue for 2.0). But if this does crop up and you know how/where you got "exposed" to non-SRI Bokeh script loads, please let us know here so we can see about updating things. |
Thanks so much! I had the issue after deleting the integrity & crossorigin attributes and running a script using bokeh and cdn. Clearing cache fixes it for me. I can reproduce the bug by running the script. As OP explained, the bug will occur when you try to plot a normal bokeh graph without using cdn. Best fix for me has been to add crossorigin attribute: |
Yes, that worked for me. |
This still seems to be happening sometimes with 2.1 even though AFAIK there is nothing in the docs published w/o hashes. I'm not sure if there is some other easy route for people to see URLs w/o the hashes (that I don't know about) that triggers this, or of there is some entirely other way mechanism to trigger (that I don't know about). I am also not really sure what to do about it but the current situation of relying on random users to know to randomly reset cache is not tenable. Some possible options off the top of my head:
Really need some help with ideas, suggestions here cc @jakirkham @martey @p-himik |
I noticed that if a Bokeh JS file is requested with a non-HTTPS Doesn't include access control headers:
Does include access control headers:
Is it possible that the S3 bucket's CORS rules are configured to only return access control headers for HTTPS origins? Could you post the current CORS configuration? |
@martey that's a surprising an interesting observation that i did not know. The CORS config on the s3 bucket is here:
But the bucket is behind a Cloudfront distribution with has a Redirect HTTP to HTTPS Behavior configured. Also the following headers are whitelisted in the CDN config:
|
@martey do you have any input or suggestions based on the configuration above? |
Otherwise, I think I am tempted to look at
as the best solution soon. I don't think it is great but I am just not sure what else to try at this point. |
I just checked again and unlike in June, both HTTP and HTTPS origin headers seem to be returning I'm no CORS guru, but it looks like the value of the |
Just to say that a few users have reported this issue to me with recent releases (all 2.2.x). Still trying to track down why this occurred. |
@martey I have set OPTIONS as an allowed header, and whitelisted the typical headers for S3-backed cloudfront: but still not seeing it in curl results:
@philippjfr (and @martey) any input or ideas are welcome. I have exhausted everything I know to try on AWS config. At present the only two things I can think of are:
Note that the last one is not foolproof if people are manually using CDN URLs nothing would prevent them from using the "wrong" one. I suppose we could also try something like I think Chrome is behaving stupidly and obtusely here (see linked issue in OP) but I would not hold out any hope for a resolution from that side of things. |
re: dropping SRI support, I'd note that projects as large as ReactJS (i.e. much larger then Bokeh) have still not changed to adding SRI hashes by default: reactjs/react.dev#1862 I know @jakirkham was very gung-ho about adding this support, but perhaps we have jumped the gun and just need to walk this back. The current situation where pages just randomly, silently fail frequently for users, offering no recourse, is not tenable. We could continue to compute and publish SRI hash tables in the release notes for users that want to use them (and perhaps offer a non-default option to include them in script tags). Ideas welcome. cc @bokeh/dev |
@bryevdv May be related to your
Some tentative searching for |
@p-himik I had thought (and previously) that perhaps OPTIONS needed to be added as allowed at the S3 Origin CORS config, but AWS will not let me do that: |
But my request is not a CORS one. |
@p-himik I think it only supports CORS options requests, perhaps. AWS explicitly mentions a configuration for
Now and actual CORS pre-flight check returns:
which I think is correct? This is a bit out of my wheelhouse though. |
FWIW I am no longer able to repro using the steps I provided in the OP (using Bokeh 2.0 env and docs since the 2.0 docs gallery examples do not have hashes). Maybe the |
My previous approach for reproducing this seems to work now but that doesn't say all that much since it seemed to be quite arbitrary before presumably due to caching which is difficult to reason about. |
Given that this issue is still occurring in the wild and we have explored all avenues of addressing this without disabling the integrity check I've opened #10877 to supersede this issue and vote for removing the checks in Bokeh 2.3. If Chrome ever fixes the bug we can readd the checks. |
I found this thread while researching this issue, and I just wanted to chime in with what seems to be the likely issue: this insane eight-year old bug that was marked "Won't Fix" in Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=158131 In my case, simply appending Hopefully this was helpful. After a full evening trying to debug why Chrome in particular is failing my code, I'm not on a personal crusade to help anyone else running into the problem. |
That Chromium bug was marked "wontfix" because the root cause of the problem was Amazon Cloudfront not supporting the right headers. That bug only concerns images, is eight years old, and Cloudfront now supports That said, your comment did make me take another crack at finding potential solutions. It looks like manually adding an Origin header to requests to Cloudfront will force CORS processing, which should prevent any cached responses without the
I am not sure what the support/troubleshooting burden with people having issues with this was before, so I will leave it to others to determine whether SRI hashes should be added back. |
@UlyssesInvictus @martey Thank you for you comments. The only reliable process that was ever discovered to repro this involved cached files and exactly matched the details of other Chrome issue I linked much earlier. Accordingly, I don't actually think any AWS-side changes can resolve this, except perhaps not allowing caching at all, and that is too costly for us. In retrospect, this conclusion probably should have occurred to me earlier. Now, it seems there may be other ways to trigger a CORS problem but there has never been any reliable way to repro them. Which means the cycle time to just "try something and see if there are still user reports" can stretch into months or years (we are already at that point!) out to "forever". Given the especially egregious "blank page" failure mode, that is just not acceptable, unfortunately. I think the decision to remove the SRI hashes in output the library generates should stand. |
This thread is a few years old, but I ran into a similar problem when I created a figure with a
This led to: Forced reload/clearing caches doesn't work. |
@devbullion that's actually something different, and possibly addressable. Please open a separate new issue. |
@bryevdv understood, apologies |
@devbullion no apologies needed, the do seem similar. A new issue will just make it possible to look at fixing this in isolation. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
cc @jakirkham @canavandl @martey
Under certain circumstances, loading local HTML Bokeh output can result in the error:
The circumstance is this: BokehJS was previously first loaded from CDN without SRI/crossorigin attributes on the script tag, and then subsequently later, was loaded with them present. Evidently Chrome uses the cached headers and decides there is a mismatch. Steps to repro:
iris.py
and open localiris.html
file in a browserWhen can this happen? For one, CDN loads in
autoload_static
were not fixed up in the last release, and still use "bare" script tags. So I think anyone who views our garllery first, thenoutput_file
output, will run in to this.Certainly, we should fix up
autoload_static
ASAP so that gallery viewing does not instigate this for users. Should be easy and can go in a 2.0.1 next week.But user generated output could also instigate this for viewers if the users use "bare" script tags in their Flask app or whatever. We don't really have control over that.
Is there another fix or mitigation we can apply to make sure it always works, regardless? Would adding an
crossorigin="anonymous"
even to script tags without SRI hashes fix this? (I will try to test out later).Thoughts welcome.
Some references:
our AWS Cloudfront/S3 setup is as described here: https://www.boxuk.com/insight/enabling-cross-domain-access-in-cloudfront/
WONTFIX issue in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=67743#c17, specifically relevant:
The text was updated successfully, but these errors were encountered: