-
Notifications
You must be signed in to change notification settings - Fork 928
External script intermittently loaded and causes CSP failure which breaks our app #187
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
Could you clarify what environment you're using the SDK from? Since you have a CSP I'm assuming it's not a plain webpage. FWIW- We have some exclusions to disable long-polling here:
If we're missing a case that's breaking you, a PR would be welcome. :-) In the meantime, you could work around the issue by setting your databaseUrl to "wss://cyphme.firebaseio.com/" instead of "https://cyphme.firebaseio.com/" to force the SDK to avoid long-polling. But I'd prefer an SDK fix if possible. Thanks! |
Thanks for the quick response @mikelehen! This is a plain web page that @JoshBoehm was referring to (https://cyph.ws). Anyway, we'll go ahead and test these solutions and see which one works best for us. More generally, do you know of a good way to prevent Firebase from loading any external scripts at run-time? We have nothing against long-polling in and of itself (and would prefer that it be used when necessary, as opposed to just failing completely), but it would make our lives a lot easier if Firebase never tried to load external scripts or expected such attempts to work. (As another example, I know that in some versions of Safari the Auth module will try to load https://apis.google.com/js/client.js.) |
I'm afraid not. Can you explain more about your CSP and what your use case is? The Firebase SDK targets a number of runtime environments (browsers, chrome extensions, react native, etc.), but it sounds like you're trying to do something a bit different. Can you explain more? Thanks! |
Hmm, well, that would be my #1 feature request in that case. Two related questions:
As far as our use case: right now just a web app, with additional security requirements imposed by our application's threat model such that loading remote scripts at run-time (even over TLS) would be considered a high-severity vulnerability. (See first bullet here for more information.) |
Out of curiosity, have you considered adding exclusions to your CSP for Firebase-provided content since you're already trusting Firebase code in your app? For instance, if you excluded *.firebaseio.com I believe that would enable our long-polling transport to work. |
We're trusting the Firebase since it's open source (well, mostly open source and in the process of being fully open sourced) and can be publicly reviewed and audited, but that's a little different from downloading and executing unverified payloads at run-time. Our CSP actually doesn't even allow fetching scripts from our own servers (which would also be a high-severity vulnerability for the same reason mentioned above). |
Ahh, I see. Yeah, adding exclusions probably doesn't make sense in your case. :-) Long-Polling and WebSockets are the only supported transports. The choice of which transport to use is a bit complicated, but if I recall correctly it works something like:
So it's possible you are accidentally getting into the "websocket_failed" mode and stuck trying to use Long-Polling until it succeeds (which will be never because of your CSP). So the only way to have reliable connectivity is to force websockets, which you can do via the wss:// trick I mentioned in my first reply. |
Got it. Sounds like wss:// is definitely the way to go then, and while a configuration flag to explicitly guarantee that external scripts won't be loaded would be ideal, we shouldn't have any problems for now. Thanks for all the help! |
Closing this issue as per the comments above. @buu700, please let us know if the suggested solution doesn't work for you. |
Seems to be working perfectly. Thanks! |
Describe your environment
Describe the problem
An external script is sometimes loaded (example: https://cyphme.firebaseio.com/.lp?start=t&ser=50153600&cb=11&v=5) which will break loading our application when the script is blocked (intentionally) due to our CSP.
My best guess so far is that it is only loading this script and breaking when it’s resorting to long polling instead of websockets.
Steps to reproduce:
Inconsistent: load https://cyph.ws in chrome -- maybe force long polling?
The text was updated successfully, but these errors were encountered: