BrowserPolicy.content.disallowEval() still gives 'unsafe-eval'


I am trying to secure my meteor app by enforcing a CSP (as recommended in the the ‘secure meteor’ book) and removing ‘unsafe-eval’ from script-src.

Below my server side code (localhost on my development machine), as well as the results on the client.

It appears that the line
does not remove ‘unsafe-eval’.

Any advice?

import {BrowserPolicy} from 'meteor/browser-policy';


which gives the following result on the client:

default-src 'self';
script-src 'self' 'unsafe-eval';
connect-src * 'self';
img-src data: 'self';
style-src 'self' 'unsafe-inline';
object-src 'none';


Any help would be greatly appreciated.

Hey @ggerber, just noticed this went unanswered!

The unsafe-eval permission is set by the dynamic-import package, since it needs to eval the packages after they are received.

Unfortunately, it’s also currently impossible to remove dynamic-import as it’s required by both ecmascript and socket-stream-client (aka ddp-client / ddp / meteor-base).

Related issues:

If this is a hard policy requirement, you can try creating local forks of these packages, replacing the dynamic imports with static ones. Not sure what else you can try!


Thank you for a great reply!

I guess ‘unsafe-eval’ does not pose a major security risk, as I don’t see the rest of the community talking much about it. From what I gather it is also an implied requirement for new versions of Meteor.

Will keep my eyes open for ways to remove ‘unsafe-eval’, while keeping dynamic-imports.


1 Like