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

breaks angular nonce based content-security-policy #38

Closed
yogeshgadge opened this issue Sep 13, 2023 · 0 comments · Fixed by #39
Closed

breaks angular nonce based content-security-policy #38

yogeshgadge opened this issue Sep 13, 2023 · 0 comments · Fixed by #39

Comments

@yogeshgadge
Copy link
Contributor

yogeshgadge commented Sep 13, 2023

Bug Report

<style></style> elements are inserted without honoring CSP_NONCE or ngCspNonce.

It inserted following style tag but missing nonce attribute.

<style type="text/css">
/*
  @ngbracket/ngx-layout - workaround for possible browser quirk with mediaQuery listeners
  see http://bit.ly/2sd4HMP
*/
@media screen and (min-width: 600px), screen and (min-width: 960px), screen and (min-width: 1280px), screen and (min-width: 1920px), screen and (min-width: 1920px) and (max-width: 4999.98px), screen and (max-width: 1919.98px), screen and (min-width: 1280px) and (max-width: 1919.98px), screen and (max-width: 1279.98px), screen and (min-width: 960px) and (max-width: 1279.98px), screen and (max-width: 959.98px), screen and (min-width: 600px) and (max-width: 959.98px), screen and (max-width: 599.98px), screen and (min-width: 0px) and (max-width: 599.98px), print {.fx-query-test{ }}
</style>

What is the expected behaviour?

Inserts nonce attribute for styles that it inserts just like other angular platform.

What is the current behaviour?

No nonce attribute.

What are the steps to reproduce?

Follow any of the 2 strategies to prepare app with nonce from https://angular.io/guide/security#content-security-policy when bootstraping or in index.html (ngCspNonce)

Try this
https://stackblitz.com/edit/rng372?file=src%2Fmain.ts

Inspect elements /head/styles/ - the style inserted by this package does not have nonce attribute.

Notice 3 <style> tags. The first 3 are from ngx-flexlayout. The 4th one behaves correctly is from @angular/material inserted.

image

What is the use case or motivation for changing an existing behaviour?

Stay secure/ CSP secure and be able to use this package that is now finally transferred here.

Which versions of Angular, Material, OS, TypeScript, and browsers are affected?

x16

Is there anything else we should know?

  1. code point
    styleEl.setAttribute('type', 'text/css');

could add the nonce here but not sure how to get that value.

  1. if we don't use media observer or responsive directives e.g. fxLayout.lt-md then I don;t see that happening. But then whats the point.
yogeshgadge added a commit to yogeshgadge/ngx-layout that referenced this issue Sep 13, 2023
yogeshgadge added a commit to yogeshgadge/ngx-layout that referenced this issue Sep 14, 2023
DuncanFaulkner pushed a commit that referenced this issue Sep 17, 2023
* fix(media-observer) honor nonce in style tag(#38)

* fix(media-observer) unit tests(#38)
DuncanFaulkner added a commit that referenced this issue Sep 17, 2023
* Merge main back into 16.x.x (#37)
* fix(media-observer) honor nonce in style tag(#38) (#39)
* fix(media-observer) honor nonce in style tag(#38)
* fix(media-observer) unit tests(#38)
Co-authored-by: ygopensource <yogeshgadge@users.noreply.github.com>
DuncanFaulkner added a commit that referenced this issue Sep 18, 2023
* Merge main back into 16.x.x (#37)

* chore(changelog): create a tag for updating the changelog

* docs(home): update home document

* chore(change log): update to changelog

* chore(changelog): update version & changelog

* chore(docs): update docs

* chore(docs): update docs

* chore(changelog): fix issues with change log

* chore(changlelog): update changelog issues

* Update README.md

* fix(media-observer) honor nonce in style tag(#38) (#39)

* fix(media-observer) honor nonce in style tag(#38)

* fix(media-observer) unit tests(#38)

* chore(changelog): update change log

* chore(changelog): update change log

* chore(media): fix unit test

* chore(version):release version 16.1.2

* chore(version): update version to 16.1.3

---------

Co-authored-by: ygopensource <yogeshgadge@users.noreply.github.com>
DuncanFaulkner added a commit that referenced this issue Sep 18, 2023
* Merge main back into 16.x.x (#37)

* chore(changelog): create a tag for updating the changelog

* docs(home): update home document

* chore(change log): update to changelog

* chore(changelog): update version & changelog

* chore(docs): update docs

* chore(docs): update docs

* chore(changelog): fix issues with change log

* chore(changlelog): update changelog issues

* Update README.md

* fix(media-observer) honor nonce in style tag(#38) (#39)

* fix(media-observer) honor nonce in style tag(#38)

* fix(media-observer) unit tests(#38)

* chore(changelog): update change log

* chore(changelog): update change log

* chore(media): fix unit test

* chore(version):release version 16.1.2

* chore(version): update version to 16.1.3

---------

Co-authored-by: ygopensource <yogeshgadge@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant