You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Serve inline scripts as a file so Dash works with script-src 'self' #4154
Dash pages can't run under a strict script-src CSP served as one shared header (for example from a reverse proxy in front of many apps) without 'unsafe-inline'.
The index page has inline scripts:
the renderer start-up: <script id="_dash-renderer">var renderer = new DashRenderer(<hooks>);</script>
one <script> per clientside callback passed as a JS string, plus anything else in _inline_scripts
app.csp_hashes() works when the app sets its own CSP, but the hashes change per app (hooks, clientside callbacks), so a proxy or platform that sets one policy for every app can't list them. Security scanners that ban 'unsafe-inline' outright then fail the site.
_dash-config is type="application/json", so it isn't affected.
Proposal
Serve the inline scripts from a same-origin route per app (for example <requests_pathname_prefix>_dash-inline.js, with a content hash in the URL for caching) and reference it with <script src>. Then script-src 'self' is enough, with no hashes and no nonce.
Keep the order: inline scripts before the renderer start-up, as today.
Keep app.csp_hashes() working (it would return an empty list, or the hash of nothing inline).
Custom index_string keeps using {%renderer%} and {%scripts%}, so it should work unchanged.
Could be opt-in first (Dash(inline_scripts=False) or similar) if changing the default is a concern.
Test
Integration test with a strict CSP (script-src 'self', no hashes) and an app that has an inline clientside callback and renderer hooks: the app renders and the callbacks fire, with no CSP violation in the browser log.
Hi i'm a university student contributing as part of a data visualization course, and i'd like to work on this. my plan is to serve the inline scripts from a same-origin route (like _dash-inline.js), keep the script order and csp_hashes() working and add an integration test with script-src 'self'. Should this be opt-in, or the default? happy to take it if nobody's already on it.
Activity
laraib-b commentedon Nov 18, 2026
Hi i'm a university student contributing as part of a data visualization course, and i'd like to work on this. my plan is to serve the inline scripts from a same-origin route (like
_dash-inline.js), keep the script order andcsp_hashes()working and add an integration test withscript-src 'self'. Should this be opt-in, or the default? happy to take it if nobody's already on it.