Skip to content

Dashboard blocked under a strict (nonce-based) Content Security Policy — layout omits the csp-nonce meta tag #4

Description

@infused

Summary: Under a strict CSP that nonces style-src/script-src and disallows unsafe-inline, the dashboard's Turbo-injected progress-bar <style> (and async-import <script> shim) are blocked, because the engine layout never renders a csp-nonce meta tag.

Root cause: The bundled Turbo build reads the nonce from <meta name="csp-nonce"> (getMetaContent("csp-nonce")) and stamps .nonce on the elements it injects. app/views/layouts/flightdeck/application.html.erb renders csrf_meta_tags but no csp-nonce meta, so the nonce is never available and the injected style/script are rejected.

Repro: Mount the engine in an app with a nonce-based CSP (Rails' default generator + content_security_policy_nonce_directives including style-src, and style-src without unsafe-inline); load /flightdeck. The browser reports a violation:

  • effective-directive: style-src-elem
  • blocked-uri: inline
  • source-file: …/flightdeck/assets/flightdeck-*.js

Suggested fix: render Rails' csp_meta_tag in the layout <head>. It emits the meta only when a CSP is configured, so it's a no-op for apps without one. PR to follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions