-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Remove all uses of "new Function" and "eval" #559
Comments
Note that this is a hot function, it should be really fast. Are you seeing a non-eval approach that is not considerably slower? I'd drop CSP environment support for now instead. |
I haven't tried anything out yet, just wanted to flag this. |
Is there any chance this will be fixed? Many organizations, including the one I work for, operate with a strict CSP, and if Mapbox is introducing potential security holes through forcing us to make our CSP more lax, it's unlikely we can consider using it. |
It is unlikely that we will resolve the issues outlined in this ticket soon. Eval, via |
Might be worthwhile adding somewhere on the website what CSP rules you need to be able to use MapBox. I had to figure this out by trial and error. FYI they are connect-src https://api.mapbox.com https://*.tiles.mapbox.com data: blob:; The nasty ones in question here are the 'data: blob:' ones, which are required for you to use |
Can you demonstrate this in practice? |
CSP allows a developer to completely disable the |
You're correct that this would increase the attack surface area, however, the code needs to get to the page somehow and trick existing code on the page to eval it. Limiting the script-src, connect-src and other directives to trusted domains will prevent a malicious script that finds a way to execute from communicating with a malicious server. CSP is about defense in depth. Without a CSP policy, or with a wide-open CSP policy, the browser's default safeguards are still protecting your site. Mapbox Studio uses a fairly restrictive CSP, you can view the source of https://www.mapbox.com/studio (it's a meta tag) to see what hosts we've white-listed. As always, it's up to you to decide how much risk is acceptable for your use case. |
I believe the non-
Plus whatever @scothis, please correct me if I'm wrong here.
It's true that |
FWIW, these are the CSP errors I'm getting now using Chrome 51.0.2704.84, Mapbox GL v0.20.0 and loading scripts from https://api.tiles.mapbox.com/mapbox-gl-js Has worked previously. (not my expertise, feel free to delete this if I'm not adding anything new to this thread) |
We have determined that removing the remaining uses of |
Just a note for future: we can get rid of |
…s in transitions (#559) * Don't rely on splitting on periods; explicitly disallow arbitrary keys only in transitions * Fix some uncaught errors with light validation * Disallow arbitrary keys in light transition validator * There are no functions in "light" * Stricter on functions * Remove TODO * Flip: from 'disallowArbitrary' (so, allowed by default) to 'allowArbitrary' (so, disallowed by default) * allowArbitrary -> allowArbitraryKeys * Define a clear order of operations for object element validation, remove "allowArbitraryKeys" option (#580) * Define a clear order of operations for object element validation, remove "allowArbitraryKeys" option * Rename "validate" to "validateSpec"
|
Is there any update on the CSP-safe version? Having this CSP requirement is definitely a strain for our organization. It's not that there is necessarily a vulnerability in mapbox itself, but any page which wants to use mapbox, doesn't have the CPS's guarantee that certain malicious content won't run. So if there's a vulnerability in any code on that page (mapbox or not) it's difficult to use the CSP to detect/prevent it. |
@winstonhowessc (and others), besides
|
|
Mapbox GL JS is included as part of applications, and CSP is a very effective security measure. It would be great if we can enable people who build those applications to use all reasonable CSP rules. Right now we use the Function form of eval via 2 downstream modules.
filter-function upstream in feature-filter
The bucket filter evaluator uses
new Function()
(a form of eval) which is prohibited under Content Security Policy. We should switch to a non-eval'ing interpreter.web workers
webworkify also uses the Function constructor to bundle webworker sources in the bundle.
The text was updated successfully, but these errors were encountered: