Skip to content

bug: Ionic Core using unsafe eval now allowed by strict CSP #18269

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

Closed
billygerhard opened this issue May 13, 2019 · 5 comments
Closed

bug: Ionic Core using unsafe eval now allowed by strict CSP #18269

billygerhard opened this issue May 13, 2019 · 5 comments
Assignees
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@billygerhard
Copy link

billygerhard commented May 13, 2019

Bug Report

Ionic version:

[x] 4.x

Current behavior:

The ionic.core.js files, as well as ionicons.core.js files use the line new Function("w","return class extends w.HTMLElement{}") which causes EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src"

This looks like it comes from ES5 backwards compatibility. There should be an option to not include ES5 if needed. There is the option in the angular.json, but that doesn't seem to work to remove this "es5BrowserSupport": false

Expected behavior:

All unsafe evals should be removed to allow ionic to run in environments with strict CSP.

Steps to reproduce:

Generate a new ionic application

Related code:

var e;
            ! function r(n) {
              return /\{\s*\[native code\]\s*\}/.test("" + n)
            }(n.customElements.define) ? (e = function(t) {
              return n.HTMLElement.call(this, t)
            }).prototype = Object.create(n.HTMLElement.prototype, {
              constructor: {
                value: e,
                configurable: !0
              }
            }): e = new Function("w", "return class extends w.HTMLElement{}")(n), U[s].u(function i(n) {
              var t = C(n),
                e = t.s,
                r = d(n[0]);
              return t.s = function(n) {
                var t = n.mode,
                  i = n.scoped;
                return function o(n, t, e) {
                  return __webpack_require__("./node_modules/@ionic/core/dist/esm/es5/build lazy recursive ^\\.\\/.*\\.entry\\.js$ include: \\.entry\\.js$")("./" + n + (t ? ".sc" : "") + ".entry.js").then(function(n) {
                    return n[e]
                  })
                }("string" == typeof e ? e : e[t], i, r)
              }, t
            }(t), e)

Other information:

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\billy\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 9.0.0 ([email protected])
   Cordova Platforms     : none
   Cordova Plugins       : not available

System:

   NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

@ionitron-bot ionitron-bot bot added the triage label May 13, 2019
@billygerhard
Copy link
Author

Related issue from Angular which was fixed in angular's core when using AOT, but this still is present in Ionic even when using AOT. angular/angular-cli#6872

@billygerhard
Copy link
Author

This looks like this issue was also reported with Stencil stenciljs/core#1265 but the PR was rejected.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented May 14, 2019

Hi there,

Thanks for the issue. We are aware of this issue, and this is something that will be fixed in our upcoming Stencil refactor.

I will keep this issue open until Ionic has been updated with the latest Stencil update.

Thanks!

@liamdebeasi liamdebeasi added the package: core @ionic/core package label May 14, 2019
@ionitron-bot ionitron-bot bot removed the triage label May 14, 2019
@liamdebeasi liamdebeasi added triage type: bug a confirmed bug report labels May 14, 2019
@ionitron-bot ionitron-bot bot removed the triage label May 14, 2019
@liamdebeasi liamdebeasi self-assigned this May 14, 2019
@brandyscarney brandyscarney added this to the Stencil One milestone Jun 10, 2019
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I am going to close this as it has been marked as fixed with the Stencil One refactor. If you are still experiencing this behavior please open a new issue. Thanks!

@ionitron-bot
Copy link

ionitron-bot bot commented May 2, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators May 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

3 participants