Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Remove eval and Function from build to support strict CSP #6872
Comments
This was referenced Jul 3, 2017
Brocco
assigned
filipesilva
Jul 17, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
filipesilva
Jul 17, 2017
Member
There are, unfortunately, some eval usage right now that I don't know if we can easily get rid of. One such example is using script-loader to load scripts. This needs some investigation to see what can be done and where are the offending bits.
|
There are, unfortunately, some eval usage right now that I don't know if we can easily get rid of. One such example is using |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
justingrayston
Aug 3, 2017
Contributor
For me, the report is coming from webpack code trying to load the modules.
e.exports=function(e){"undefined"!=typeof execScript?execScript(e):eval.call(null,e)}}
Which I believe is the compiled version of
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(src) {
if (typeof execScript !== "undefined")
execScript(src);
else
eval.call(null, src);
}
This issue in Webpack webpack/webpack#4094 kind of implies that it should be possible to resolve, but to be honest I am no webpack expert. If I have some time I may do some reading.
|
For me, the report is coming from webpack code trying to load the modules.
Which I believe is the compiled version of
This issue in Webpack webpack/webpack#4094 kind of implies that it should be possible to resolve, but to be honest I am no webpack expert. If I have some time I may do some reading. |
filipesilva
referenced this issue
Aug 15, 2017
Merged
feat(@angular/cli): support sourcemaps and minification in scripts #7279
added a commit
to filipesilva/angular-cli
that referenced
this issue
Aug 15, 2017
added a commit
to filipesilva/angular-cli
that referenced
this issue
Aug 16, 2017
added a commit
to filipesilva/angular-cli
that referenced
this issue
Aug 17, 2017
added a commit
that referenced
this issue
Aug 17, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
moiz-h
Aug 31, 2017
+1 for getting rid of eval() and new Function calls. We get the evalError when trying to use an Angular component in an existing AngularJS app.
moiz-h
commented
Aug 31, 2017
|
+1 for getting rid of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
appeality
Sep 7, 2017
+1 - There's a single call to eval.call(...) in scripts.bundle.js that prevents proper use of a CSP response header in Angular apps.
appeality
commented
Sep 7, 2017
|
+1 - There's a single call to eval.call(...) in scripts.bundle.js that prevents proper use of a CSP response header in Angular apps. |
ankemp
referenced this issue
in alexabbott/firebase-cms
Sep 8, 2017
Open
Security, Pen Testing & Scaling #10
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
danielmapar
commented
Sep 13, 2017
|
Beside AOT, any temporary fix for this guys? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
xnnkmd
commented
Oct 23, 2017
|
@filipesilva Is this fixable ? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
runes83
commented
Nov 15, 2017
|
Any news on this? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
filipesilva
Dec 7, 2017
Member
@clydin can you weigh in with the results from when you tested CSP last pleast?
|
@clydin can you weigh in with the results from when you tested CSP last pleast? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
darrenmothersele
commented
Dec 13, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
saulshanabrook
Dec 13, 2017
@darrenmothersele I was still able to create a WebExtension, I just couldn't get it accepted into the Firefox store. You might be able to set the content_security_policy in your manifest.json to allow evals?
saulshanabrook
commented
Dec 13, 2017
|
@darrenmothersele I was still able to create a WebExtension, I just couldn't get it accepted into the Firefox store. You might be able to set the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
intellix
Jan 6, 2018
Contributor
Scary article regarding CSP being absolutely necessary: https://medium.com/@david.gilbertson/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5
|
Scary article regarding CSP being absolutely necessary: https://medium.com/@david.gilbertson/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
clydin
Jan 9, 2018
Contributor
With a production build and the removal of the reflection polyfills (these are not needed if using AOT which is enabled by default for production builds), eval is only used in two locations due to the use of the global object webpack shim. This shim is planned to be disabled in the next major CLI release. However, the use is guarded in a try/catch and includes fallback code so the usage is not required for a functioning application. Unfortunately, the warnings will still appear when running static analysis tools.
Also, please note that nothing in this issue precludes the use of CSP as a whole.
|
With a production build and the removal of the reflection polyfills (these are not needed if using AOT which is enabled by default for production builds), Also, please note that nothing in this issue precludes the use of CSP as a whole. |
hansl
unassigned
filipesilva
Feb 6, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
sherlock1982
Mar 9, 2018
Even with AOT styles created in Components are rendered as inline. Is it intended? If yes I will rewrite it of course.
sherlock1982
commented
Mar 9, 2018
|
Even with AOT styles created in Components are rendered as inline. Is it intended? If yes I will rewrite it of course. |

saulshanabrook commentedJul 3, 2017
•
Edited 1 time
-
saulshanabrook
Jul 10, 2017
Bug Report or Feature Request (mark with an
x)Versions.
Repro steps.
Create
src/manifest.jsonwith:{ "manifest_version": 2, "name": "test-csp", "version": "1.0", "browser_action": { "default_title": "test-csp", "default_popup": "/index.html" } }Add
manifest.jsonto theapps[0].assetsin the.angular-cli.json.Repo available here https://github.com/saulshanabrook/test-csp
The log given by the failure.
Regular build:
Production build:
Desired functionality.
We should be able to build the project with no CSP errors. That means eliminating all uses of
evalandFunction. This is needed in order for Mozilla to let any Angular 2 apps be submitted as extensions on their store. For example, I got this response when trying to submit an extension:Mention any other details that might be useful.
Moved from #1279 (comment).
This might be blocked on Angular core angular/angular#6361 angular/angular#1744.