question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QSelect breaks Content-Security-Policy, forcing to use `style-src "unsafe-inline"`

See original GitHub issue

What happened?

Clicking on QSelect component (and probably many more which use useVirtualScroll) will generate an error on CSP.

Refused to apply inline style because it violates the following Content Security Policy directive: “default-src ‘self’”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=’), or a nonce (‘nonce-…’) is required to enable inline execution. Note also that ‘style-src’ was not explicitly set, so ‘default-src’ is used as a fallback.

Reversing the code I understood that when the user click on QSelect, it will trigger useVirtualScroll from quasar/src/components/virtual-scroll/use-virtual-scroll.js which eventually will trigger setOverflowAnchor.

setOverflowAnchor will add a style element to the DOM and try to add some rules, which obviously will make the browser angry (because of the CSP).

The error actually doesn’t seems to break the UI.

What did you expect to happen?

QSelect and the other component affected should not throw errors if CSP style-src "self" is set

Reproduction URL

https://github.com/kael-k/quasar-with-broken-csp-demo

How to reproduce?

  1. start the app by building and running the Dockerfile (or build it yourself)
  2. click on the QSelect

Flavour

Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)

Areas

Components (quasar)

Platforms/Browsers

No response

Quasar info output

Operating System - Linux(5.16.15-arch1-1) - linux/x64
NodeJs - 16.13.0

Global packages
  NPM - 8.1.0
  yarn - 1.22.18
  @quasar/cli - undefined
  @quasar/icongenie - Not installed
  cordova - 10.0.0 (cordova-lib@10.1.0)

Important local packages
  quasar - 2.6.5 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-webpack - 3.4.7 -- Quasar Framework App CLI with Webpack
  @quasar/extras - 1.13.5 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.2.31 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.0.14
  pinia - Not installed
  vuex - Not installed
  electron - Not installed
  electron-packager - Not installed
  electron-builder - Not installed
  @babel/core - 7.17.8 -- Babel compiler core.
  webpack - 5.71.0 -- Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  webpack-dev-server - 4.7.4 -- Serves a webpack app. Updates the browser on changes.
  workbox-webpack-plugin - Not installed
  register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
  typescript - 4.5.5 -- TypeScript is a language for application scale JavaScript development
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Quasar App Extensions
  *None installed*

Relevant log output

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rstoenescucommented, Apr 4, 2022

Fix will be available in Quasar v2.6.6

0reactions
pdanpdancommented, Apr 4, 2022

Don’t ask for the same thing for morph 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

unsafe-inline CSP Guide - Content Security Policy
The unsafe-inline Content Security Policy (CSP) keyword allows the execution of inline scripts or styles. Warning. Except for one very specific case, you...
Read more >
CSP: style-src - HTTP - MDN Web Docs - Mozilla
To allow inline styles, 'unsafe-inline' , a nonce-source or a hash-source that matches the inline block can be specified.
Read more >
Are we forced to use 'unsafe-inline' in our CSP when using ...
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'strict-dynamic' 'nonce- ...
Read more >
Content Security Policy (CSP) Bypass - HackTricks
'unsafe-inline' means that you can execute any script inside the code (XSS can execute code) and img-src * means that you can use...
Read more >
Content Security Policy Level 2 - W3C
To take advantage of CSP, a web application opts into using CSP by supplying a Content-Security-Policy HTTP header. Such policies apply to the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found