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

Content Security Policy (CSP) prevents vue-multiselect from loading due to eval function use #1673

Open
h3xstream opened this issue Mar 3, 2023 · 2 comments

Comments

@h3xstream
Copy link

h3xstream commented Mar 3, 2023

Reproduction Link

(jsfiddle can't be used because the vue template are not compiled)

Steps to reproduce

Use the header

Content-Security-Policy: script-src 'self'; object-src 'self';

Include the component in your template (no special configuration needed)

<Multiselect v-model="selection" :options="optionsList"></Multiselect>

Expected behaviour

VueJs use eval to compile its template. However, the template and component can generally be pre-compiled to JS to avoid those runtime eval.

CSP is used by website to prevent unexpected XSS.
In my case, when developping a Chrome extension, pages are runned with the header include above. (script-src 'self'; ...)

Actual behaviour

The error that is shown in the console :

Screen Shot 2023-03-03 at 11 04 52 AM

The Content Security Policy (CSP) prevents the evaluation of arbitrary strings as JavaScript to make it more difficult for an attacker to inject unathorized code on your site.

To solve this issue, avoid using eval(), new Function(), setTimeout([string], ...) and setInterval([string], ...) for evaluating strings.

If you absolutely must: you can enable string evaluation by adding unsafe-eval as an allowed source in a script-src directive.

...

I think the faulty code is the following:

Screen Shot 2023-03-03 at 11 06 45 AM

@mattelen
Copy link
Collaborator

mattelen commented Mar 3, 2023

Can you please confirm which version of the multiselect this is occurring for?

@gazben
Copy link

gazben commented Aug 9, 2023

This occures to me with version 2.1.7.

Problematic statement in the bundle:

Function("return this")()

If I try to do the same from the console it will fail too:

image

I could only find this in the dist folder, so maybe it's a problem with the compilation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants